Everybody Codes, the 2025 event, quest 11-15

I’ve done Everybody Codes, back in November.

The Song of Ducks and Dragons [ 2025 ]

All my code is available .

 Step 1 [1,2]    Step 2 [2,3]    Step 3 [3,4]    Step 4 [4,5]    Step 5 [5,6]
  1 2 3 4 5 6     1 2 3 4 5 6     1 2 3 4 5 6     1 2 3 4 5 6     1 2 3 4 5 6
  * * * * * *     * * * * * *     * * * * * *     * * * * * *     * * * * * *
  *(*)  * * *     *  (*)* * *     *   * * * *     *   * * * *     *   * * * *
  *     * * *     *     * * *     *     * * *     *     * * *     *     * * *
  *     * * *     *     * * *     *     * * *     *     * * *     *     * * *
  *       * *     *       * *     *       * *     *       * *     *       * *
  *       * *     *       * *     *       * *     *       * *     *       * *
  *       *       *       *       *       *       *       *       *       *(*)
  *       *       *       *       *       *       *       *       *       *
          *               *               *               *

Quest 11. Given a list of numbers, interpret them as columns of ducks. A column will check whether the next columns has fewer birds, and if so, move a duck. This happens to all columns. And until no more moves are possible. Then the check goes the other way. The result is a balanced set of columns. Do this for 10 rounds (part 1). Or until balanced (part 2 and 3).

For part 1 and 2, the hardest part was probably to understand what was going on. For part 3… There is a shortcut. I’ve written about why it works. I made a video! Anyway, once the shortcut was in place, it was, again, easy.

989601     989601     989601     989601     989601     989601     989601
857782 857782 857782 857782 857782 857782 857782
746543 746543 746543 746543 746543 746543 746543
766789 766789 766789 766789 766789 766789 766789

Quest 12. Given a map of numbers and a starting point, add numbers to the group of points by adding numbers that are less than or equal to an already added numbers. Do this until no more can be added (part 1). Again with 2 starting points (part 2). Again, with 3 starting points chosen for maximum effect (part 3).

A bit fiddly, but straightforward. In part 3 it turned out to be important, that a good starting point was also a local maximum. If a < b, a can’t set b on fire.

72
58
47
61
67

Quest 13. Given a list of numbers, construct a dial and turn it 2025 times (part 1). Given a list of intervals, construct a dial and turn it 20252025 times (part 2). Again, but 202520252025 times.

In part 3 the numbers got too big. It was important not to construct the whole dial as an array. So, only note beginnings and ends of intervals.

 Round 1     Round 2     Round 3     Round 4     Round 5
.#.#.. .###.. #.#.#. #####. ..###.
##.##. #.#### ###.## ...##. ##.###
#.#... #..### #.#.## .#..#. .#.#.#
....## ##...# .#..#. ##.##. .#.###
#.#### #.#.#. #..#.# .####. #...#.
##..#. ...#.. ###.#. .###.# .#...#

Quest 14. A map of tiles. In a game of life way, determine which tiles will be active in the next round. Run some rounds (part 1 and 2). Run a lot of rounds, noting when a certain pattern matches (part 3).

The interesting bit is part 3. Run a few rounds, and keep track of repetitions. Then calculate the rest of the rounds instead of actually going through them. A few interesting questions like how to represent the tiles in a manageable way when recording “I have seen this before”, and then the actual math at the end, trying very hard not to get any off by 1 errors.

 start             R3              R4              L3
S S### S### S###
# #
# #
# #
# ####

Quest 15. Given a list of instructions about how to walk (turn right and walk 3, turn right again and walk 4…), interpret the walked segments as walls and find the shortest path from start to end (part 1-3).

Dijkstra! And then in part 3, it was necessary to not just build the whole map. Similar to day 13, only build the interesting bits. This was fiddly! A lot of small steps, a lot of testing and correcting errors.

Skriv en kommentar