❌ About FreshRSS

Normal view

There are new articles available, click to refresh the page.
Before yesterdayNews from the Ada programming language world

HAC at work with shiny gold bags (Advent of Code, Day 7)

7 December 2020 at 14:13

Day 7 of the Advent of Code, titled "Handy Haversacks" is nice pair of puzzles involving recursion.

The data is a set of rules, beginning with

wavy green bags contain 1 posh black bag, 1 faded green bag, 4 wavy red bags.

dotted chartreuse bags contain 1 light beige bag.

dark white bags contain 2 dotted white bags.

... 

There are hundreds of such rules.

The puzzles involve recursion, which makes them fun.

You can see below HAC at work on the problem, from the LEA editor.

There is also a "full Ada" version. I began with that one, because the current limitations of HAC would have been too time-consuming (in terms of development time) for submitting a solution quickly enough. The limitations are not around recursion, that HAC masters like a big one, but mostly around the enumeration type I/O which is currently non-existent in HAC (v.0.081).

Click to enlarge

Solutions will be soon be posted on the HAC repositories.

Advent of Code 2020 with HAC and LEA

2 December 2020 at 20:27

First use of HAC, via the LEA editor, for the famous Advent of Code contest.

LEA screenshot: a parser for Day 2 Advent of Code's puzzle

In my (of course biased) opinion, LEA is perfect (among other tasks...) for developing quickly Ada solutions to the Advent of Code problems.

After the rush, I tidy up the source code with GNAT's style checks. Hence the presence of a GNAT project file, aoc_2020.gpr .

Then I post my solutions as HAC examples, here and here


The Three Lakes Problem

24 May 2020 at 16:56
Played with a old numerics code of mine rescued from a backup CD, cleaned up, and put now on SourceForge and GitHub (spot the file "three_lakes.adb" in the diff_eq/ode/ directory)...

The problem is to predict the evolution of levels of three lakes connected by two channels, given some knowledge of the inflows and outflows.
Thanks to the magic of differential equations, it is possible!
The variation of each level is a function of the in- and out-flows, and of the flow from / to neighboring lakes.
If lake X is connected to Y, there is a flow from X to Y if X's level is higher than Y's.
When X's level is lower than Y's, the flow reverses.
Obvious, isn't it?


So, the program solves a vectorial differential equation, with the famous Runge-Kutta method.
The unknown x is a vector containing the levels of three lakes (Bienne, Neuchâtel, Morat in Switzerland).
The lakes are connected by two channels (marked with "in out" on the map).
Boundary conditions take the form of natural inflows (marked "in") into the lakes,
and a single, controlled outflow (marked "out") out of one of the lakes (Bienne).
The variation of all levels is x', a function of x and of the boundary conditions.

Even with static boundary conditions, we can have situations where one of the lakes' level goes up, then down, then up again. Finally (due to the artificial static conditions) the flows find an equilibrium.

Click to enlarge

A change in level direction (up/down) of one of the lakes (Neuchâtel) happens at the moment when two connected lakes have the same level, and the connecting channel changes its direction (points marked with arrows). You see also a change of direction of lake of Bienne's level, a bit later.

Of course in reality, the boundary conditions vary all the time, so we can have much more complex situations if these conditions are injected into the simulation.

Related publication:
   Évolution simulée des niveaux dans le système des Trois-Lacs,
   F. & G. de Montmollin,
   Bulletin de la Société vaudoise des sciences naturelles.
   88.2: 121-129, ISSN 0037-9603, 2002

Here is a wonderful picture of the lake of Bienne taken a few days ago (courtesy of Stéphane Perret).

Click to enlarge


New GitHub mirrors

17 September 2019 at 08:32


New GitHub mirrors, for open-source projects I'm administrator or developer of, are located here.
Please ignore the old mirrors that relied on svn2github. If you see "svn2github" somewhere on a repository address, it's the old one → trash it!

You can find the same projects on SourceForge too, here.

The projects are...

Ada Bar Codesbar code (1D and 2D) generator in pure Ada
Ada PDF Writera standalone, portable package for producing dynamically PDF documents
AZipa free, portable Zip Archive Manager
Corporate Bullshit Generatorthe Corporate Bullshit Generator
Engine_3Da real-time, pure software, 3D engine for DOS-talgics
Excel Writera standalone, portable Ada package for producing Excel spreadsheets
GIDGeneric Image Decoder
GLOBE_3Da real-time 3D Engine written in Ada
GNAVI: GNU Ada Visual Interfacethe GNU Ada Visual Interface
GNOGAthe GNU Omnificent GUI for Ada
HACHAC Ada Compiler
Ini file managera standalone, portable Ada package for configuration files
LEALightweight Editor for Ada
Mathpaqscollection of mathematical, 100% portable, packages in Ada
Pascal-to-AdaPascal to Ada translator
TeXCADa program for drawing or retouching {picture}s in LaTeX
Wasabeea Web browser with safety focus
Zip-Adaa standalone, portable Ada library for Zip archives
❌
❌