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.