From 6aa605a0deee534f0fc080b34664181040618077 Mon Sep 17 00:00:00 2001 From: Bruno Raoult Date: Thu, 24 Mar 2022 18:41:28 +0100 Subject: [PATCH] init days{24,25} --- 2021/day24/EXAMPLE.txt | 11 ++ 2021/day24/EXAMPLE1.txt | 2 + 2021/day24/EXAMPLE2.txt | 4 + 2021/day24/INPUT.txt | 252 +++++++++++++++++++++++++++++++++++ 2021/day24/Makefile | 77 +++++++++++ 2021/day24/README.txt | 62 +++++++++ 2021/day25/EXAMPLE.txt | 7 + 2021/day25/EXAMPLE2.txt | 9 ++ 2021/day25/INPUT.txt | 137 +++++++++++++++++++ 2021/day25/Makefile | 77 +++++++++++ 2021/day25/README.txt | 285 ++++++++++++++++++++++++++++++++++++++++ 11 files changed, 923 insertions(+) create mode 100644 2021/day24/EXAMPLE.txt create mode 100644 2021/day24/EXAMPLE1.txt create mode 100644 2021/day24/EXAMPLE2.txt create mode 100644 2021/day24/INPUT.txt create mode 100644 2021/day24/Makefile create mode 100644 2021/day24/README.txt create mode 100644 2021/day25/EXAMPLE.txt create mode 100644 2021/day25/EXAMPLE2.txt create mode 100644 2021/day25/INPUT.txt create mode 100644 2021/day25/Makefile create mode 100644 2021/day25/README.txt diff --git a/2021/day24/EXAMPLE.txt b/2021/day24/EXAMPLE.txt new file mode 100644 index 0000000..6b1b0e6 --- /dev/null +++ b/2021/day24/EXAMPLE.txt @@ -0,0 +1,11 @@ +inp w +add z w +mod z 2 +div w 2 +add y w +mod y 2 +div w 2 +add x w +mod x 2 +div w 2 +mod w 2 diff --git a/2021/day24/EXAMPLE1.txt b/2021/day24/EXAMPLE1.txt new file mode 100644 index 0000000..a41747d --- /dev/null +++ b/2021/day24/EXAMPLE1.txt @@ -0,0 +1,2 @@ +inp x +mul x -1 diff --git a/2021/day24/EXAMPLE2.txt b/2021/day24/EXAMPLE2.txt new file mode 100644 index 0000000..ae8792a --- /dev/null +++ b/2021/day24/EXAMPLE2.txt @@ -0,0 +1,4 @@ +inp z +inp x +mul z 3 +eql z x diff --git a/2021/day24/INPUT.txt b/2021/day24/INPUT.txt new file mode 100644 index 0000000..6290d6a --- /dev/null +++ b/2021/day24/INPUT.txt @@ -0,0 +1,252 @@ +inp w +mul x 0 +add x z +mod x 26 +div z 1 +add x 13 +eql x w +eql x 0 +mul y 0 +add y 25 +mul y x +add y 1 +mul z y +mul y 0 +add y w +add y 10 +mul y x +add z y +inp w +mul x 0 +add x z +mod x 26 +div z 1 +add x 11 +eql x w +eql x 0 +mul y 0 +add y 25 +mul y x +add y 1 +mul z y +mul y 0 +add y w +add y 16 +mul y x +add z y +inp w +mul x 0 +add x z +mod x 26 +div z 1 +add x 11 +eql x w +eql x 0 +mul y 0 +add y 25 +mul y x +add y 1 +mul z y +mul y 0 +add y w +add y 0 +mul y x +add z y +inp w +mul x 0 +add x z +mod x 26 +div z 1 +add x 10 +eql x w +eql x 0 +mul y 0 +add y 25 +mul y x +add y 1 +mul z y +mul y 0 +add y w +add y 13 +mul y x +add z y +inp w +mul x 0 +add x z +mod x 26 +div z 26 +add x -14 +eql x w +eql x 0 +mul y 0 +add y 25 +mul y x +add y 1 +mul z y +mul y 0 +add y w +add y 7 +mul y x +add z y +inp w +mul x 0 +add x z +mod x 26 +div z 26 +add x -4 +eql x w +eql x 0 +mul y 0 +add y 25 +mul y x +add y 1 +mul z y +mul y 0 +add y w +add y 11 +mul y x +add z y +inp w +mul x 0 +add x z +mod x 26 +div z 1 +add x 11 +eql x w +eql x 0 +mul y 0 +add y 25 +mul y x +add y 1 +mul z y +mul y 0 +add y w +add y 11 +mul y x +add z y +inp w +mul x 0 +add x z +mod x 26 +div z 26 +add x -3 +eql x w +eql x 0 +mul y 0 +add y 25 +mul y x +add y 1 +mul z y +mul y 0 +add y w +add y 10 +mul y x +add z y +inp w +mul x 0 +add x z +mod x 26 +div z 1 +add x 12 +eql x w +eql x 0 +mul y 0 +add y 25 +mul y x +add y 1 +mul z y +mul y 0 +add y w +add y 16 +mul y x +add z y +inp w +mul x 0 +add x z +mod x 26 +div z 26 +add x -12 +eql x w +eql x 0 +mul y 0 +add y 25 +mul y x +add y 1 +mul z y +mul y 0 +add y w +add y 8 +mul y x +add z y +inp w +mul x 0 +add x z +mod x 26 +div z 1 +add x 13 +eql x w +eql x 0 +mul y 0 +add y 25 +mul y x +add y 1 +mul z y +mul y 0 +add y w +add y 15 +mul y x +add z y +inp w +mul x 0 +add x z +mod x 26 +div z 26 +add x -12 +eql x w +eql x 0 +mul y 0 +add y 25 +mul y x +add y 1 +mul z y +mul y 0 +add y w +add y 2 +mul y x +add z y +inp w +mul x 0 +add x z +mod x 26 +div z 26 +add x -15 +eql x w +eql x 0 +mul y 0 +add y 25 +mul y x +add y 1 +mul z y +mul y 0 +add y w +add y 5 +mul y x +add z y +inp w +mul x 0 +add x z +mod x 26 +div z 26 +add x -12 +eql x w +eql x 0 +mul y 0 +add y 25 +mul y x +add y 1 +mul z y +mul y 0 +add y w +add y 10 +mul y x +add z y diff --git a/2021/day24/Makefile b/2021/day24/Makefile new file mode 100644 index 0000000..07fc3b7 --- /dev/null +++ b/2021/day24/Makefile @@ -0,0 +1,77 @@ +# AOC daily Makefile - GNU make only. +# +# Copyright (C) 2021 Bruno Raoult ("br") +# Licensed under the GNU General Public License v3.0 or later. +# Some rights reserved. See COPYING. +# +# You should have received a copy of the GNU General Public License along with this +# program. If not, see . +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +INPUT := INPUT.txt +SHELL := /bin/bash + +CC := gcc + +LIB := aoc_$(shell uname -m) +INCDIR := ../include +LIBDIR := ../lib +LDFLAGS := -L$(LIBDIR) +#LDLIB := -l$(LIB) -lm +LDLIB := -l$(LIB) + +export LD_LIBRARY_PATH = $(LIBDIR) + +CFLAGS += -std=gnu99 +CFLAGS += -O2 +CFLAGS += -g +# for gprof +#CFLAGS += -pg +CFLAGS += -Wall +CFLAGS += -Wextra +CFLAGS += -march=native +# Next one may be useful for valgrind (some invalid instructions) +# CFLAGS += -mno-tbm +CFLAGS += -Wmissing-declarations +CFLAGS += -Wno-unused-result + +CFLAGS += -DDEBUG_DEBUG # activate general debug (debug.c) +CFLAGS += -DDEBUG_POOL # memory pools management + +TIME := \time -f "\ttime: %E real, %U user, %S sys\n\tcontext-switch:\t%c+%w, page-faults: %F+%R\n" +export PATH := .:$(PATH) + +.PHONY: clean all compile assembly memcheck memcheck1 memcheck2 ex1 ex2 + +all: ex1 ex2 + +memcheck: memcheck1 memcheck2 + +memcheck1: + @valgrind -q -s --track-origins=yes aoc-c -p 1 < $(INPUT) + +memcheck2: + @valgrind -q -s --track-origins=yes aoc-c -p 2 < $(INPUT) + +compile: aoc-c + +assembly: aoc-c.s + +ex1: aoc-c + @$(TIME) aoc-c -p 1 < $(INPUT) + +ex2: aoc-c + @$(TIME) aoc-c -p 2 < $(INPUT) + +clean: + @rm -f aoc-c core* vgcore* gmon.out aoc-c.s + +.c: + @echo compiling $< + @$(CC) $(CFLAGS) $(LDFLAGS) -I $(INCDIR) $< $(LDLIB) -o $@ + +.c.s: + @echo generating $@ + @$(CC) -S -fverbose-asm $(CFLAGS) -I $(INCDIR) $< -o $@ diff --git a/2021/day24/README.txt b/2021/day24/README.txt new file mode 100644 index 0000000..d5c4c9b --- /dev/null +++ b/2021/day24/README.txt @@ -0,0 +1,62 @@ +--- Day 24: Arithmetic Logic Unit --- + +Magic smoke starts leaking from the submarine's arithmetic logic unit (ALU). Without the ability to perform basic arithmetic and logic functions, the submarine can't produce cool patterns with its Christmas lights! + +It also can't navigate. Or run the oxygen system. + +Don't worry, though - you probably have enough oxygen left to give you enough time to build a new ALU. + +The ALU is a four-dimensional processing unit: it has integer variables w, x, y, and z. These variables all start with the value 0. The ALU also supports six instructions: + + inp a - Read an input value and write it to variable a. + add a b - Add the value of a to the value of b, then store the result in variable a. + mul a b - Multiply the value of a by the value of b, then store the result in variable a. + div a b - Divide the value of a by the value of b, truncate the result to an integer, then store the result in variable a. (Here, "truncate" means to round the value toward zero.) + mod a b - Divide the value of a by the value of b, then store the remainder in variable a. (This is also called the modulo operation.) + eql a b - If the value of a and b are equal, then store the value 1 in variable a. Otherwise, store the value 0 in variable a. + +In all of these instructions, a and b are placeholders; a will always be the variable where the result of the operation is stored (one of w, x, y, or z), while b can be either a variable or a number. Numbers can be positive or negative, but will always be integers. + +The ALU has no jump instructions; in an ALU program, every instruction is run exactly once in order from top to bottom. The program halts after the last instruction has finished executing. + +(Program authors should be especially cautious; attempting to execute div with b=0 or attempting to execute mod with a<0 or b<=0 will cause the program to crash and might even damage the ALU. These operations are never intended in any serious ALU program.) + +For example, here is an ALU program which takes an input number, negates it, and stores it in x: + +inp x +mul x -1 + +Here is an ALU program which takes two input numbers, then sets z to 1 if the second input number is three times larger than the first input number, or sets z to 0 otherwise: + +inp z +inp x +mul z 3 +eql z x + +Here is an ALU program which takes a non-negative integer as input, converts it into binary, and stores the lowest (1's) bit in z, the second-lowest (2's) bit in y, the third-lowest (4's) bit in x, and the fourth-lowest (8's) bit in w: + +inp w +add z w +mod z 2 +div w 2 +add y w +mod y 2 +div w 2 +add x w +mod x 2 +div w 2 +mod w 2 + +Once you have built a replacement ALU, you can install it in the submarine, which will immediately resume what it was doing when the ALU failed: validating the submarine's model number. To do this, the ALU will run the MOdel Number Automatic Detector program (MONAD, your puzzle input). + +Submarine model numbers are always fourteen-digit numbers consisting only of digits 1 through 9. The digit 0 cannot appear in a model number. + +When MONAD checks a hypothetical fourteen-digit model number, it uses fourteen separate inp instructions, each expecting a single digit of the model number in order of most to least significant. (So, to check the model number 13579246899999, you would give 1 to the first inp instruction, 3 to the second inp instruction, 5 to the third inp instruction, and so on.) This means that when operating MONAD, each input instruction should only ever be given an integer value of at least 1 and at most 9. + +Then, after MONAD has finished running all of its instructions, it will indicate that the model number was valid by leaving a 0 in variable z. However, if the model number was invalid, it will leave some other non-zero value in z. + +MONAD imposes additional, mysterious restrictions on model numbers, and legend says the last copy of the MONAD documentation was eaten by a tanuki. You'll need to figure out what MONAD does some other way. + +To enable as many submarine features as possible, find the largest valid fourteen-digit model number that contains no 0 digits. What is the largest model number accepted by MONAD? + +To begin, get your puzzle input. diff --git a/2021/day25/EXAMPLE.txt b/2021/day25/EXAMPLE.txt new file mode 100644 index 0000000..76296ab --- /dev/null +++ b/2021/day25/EXAMPLE.txt @@ -0,0 +1,7 @@ +...>... +....... +......> +v.....> +......> +....... +..vvv.. diff --git a/2021/day25/EXAMPLE2.txt b/2021/day25/EXAMPLE2.txt new file mode 100644 index 0000000..0f3c0cd --- /dev/null +++ b/2021/day25/EXAMPLE2.txt @@ -0,0 +1,9 @@ +v...>>.vv> +.vv>>.vv.. +>>.>v>...v +>>v>>.>.v. +v>v.vv.v.. +>.>>..v... +.vv..>.>v. +v.v..>>v.v +....v..v.> diff --git a/2021/day25/INPUT.txt b/2021/day25/INPUT.txt new file mode 100644 index 0000000..d7fea6d --- /dev/null +++ b/2021/day25/INPUT.txt @@ -0,0 +1,137 @@ +>...>.v>vv>>..>>v...v..>>v.>..>.>>..>>>...>.>>>.>v.>..v>.v>.>v.v.......>..vv.......>v..>.>>...>>>vv....>v.>>.v>vvv..>>.v..v>.v..vv.v..vvvv. +.>....>>......>..v..v...v.v.vvv>>>.v.vv>>v>>.>>>..vv...vv..vvv.v..>...>vv.>v.v>.v>>....vv.v...>v>>>vv.v......>v>..>v.v>....v.v.v>>v...v>..v +vv>.>>>>.v..vv..v>v....>..vv.>...>>v.v.v>>v>.>>.v.v.>v.v.vv>v>>v.....v>v....vv.v>>v.v>>....v.>.....>v...>v.v.>.v..>.v.v.>v..vv.v..v>>v.v>.. +.v>>.>>v.....>>v>>>..>..>.v...>...>v.v..v>>v.>..v.v.>>v.>.>.v.>..>>.>.......vv>>.>v>>v..v..v.>v.vvvv.>.....v>>.>>.v..>>vv>vvv.>.v>v...vv.v. +..>v>.vvv.>.v..v>>..>.v>vv.....>.v..v>v......v>..>v.>....>.>.vv.v...>.>..v.........vv>v...vv>v>v..v.>vvv..vv.>.>.>vvvv.vv..v.....>.>>>...>v +v..>..v>>..>..>.v.>.>......vv.>..>>>v.>.>....vv>vv>...v>v>.>>>>v..>v..>v>>..>.>.>>>...vv>..>..v.>.>>.>>.>>...>>....v.v...>.v..v........>.vv +..>..vv.v..v...>>>vvvvvv.v..vv..>v>>>>v.....v..v....>v.v..v.>...v.v.>..v..>.vvv..>..vv..v.v..v.>>...vv.v....v>...vv...>v.>v..>v..>.v......> +..>>v....>.v..vvv>...>>v.vv......>v.v.vv.v>..>v>.>......v.v>.>>v.vv..v.>....vvv>.v.>v>v.vv.>v.>vvv.v>.......>.v>....>..>v.vvv...v.v>>v...>v +..v>..>v.>v.>>....vvv.>>.>..v>>v>>v>.....v....v.>v..>...v>.....>.vv.>.....>.>.vv..>>v>.>.>>v.vvv....>v....>v.vvvv>.>>.v.v.v...>.>.vv..>.>.. +...>>.v..v>..>vvv..>v>..v.v......v.v.v>v>.v.>vv.v>.>v.>v...v>>>>>.>>v...>..>>v...v..>v>.v..vv>...v>v..>>v>>.v...v.>>.>...v.vv..>>>.>.v>v.v. +vv...>>v.>>..v>v..>...>v...v>>vvvv..>v.v.v.>v...v>v.>v....v.v>v>v>vv.....v>..vv.v>.v...vv>.v>v..>>.vv>>.>.v.>.>vv.v..v>>....>>v.>...vv.v..> +vv.>.>......>v.v.vv...v>v..v.>v.vvvv.>..vv>v.v.v..>>v>>>v....>.>.v.v>>...v.>v..>..>.>>v>>..>.vv.vv.>...v>>..v>..v...v.>.>.>....v>>..>vvv..> +...>>.v>..>..v..v>>..v>>....>>....>..>>..>....>v.>v>vv...v.>...>vvv..v>v..>>...v.......v..>.vv>v>vv....>..v>..v>.>...v.vv>.v.vv..>....>.v.. +.v.v.>..>vvvvv..v>>..v.vv...>v....>.v.>.v..>...>..>>...v.>>>v.>>v.v....vv>.v>.>.vv.v....v>vvv.v>>...>v>.v.>vvvv.v.vv..>.>>.vvvvvv..vv>.v>>> +v.v>.vv.>..v>vv>v>vv.>v.....v..>.......vv.....v>.v..v>.v....>....>>>..>...v>..>>..vv.v>.>....>.v.>...>..vvv>.>.v.v.>vv...>>>>.vvv.v.v...>>. +.vvv...>....v.>.>v..>.vv.v.vv>v...v...........>.v>>.........>v....v..>v.>>..>.v>>.v>v....>>>v.v...v>>v..v.v>>>v....>.>.v....v>>.v..v..vv..> +.v>>..>.....>.v.>>.v>......>v.>v......v..v>..v...>.....v>v..........>v.v.>.>>>.vvv>.>>.v.>v.v.>>.vvv..v......v>.v.>.v.>>>v.>v....>v>.v>..>. +>>.>>>v.>v..v.>>>.v.v..>>v>...v.>vv>v..>v.>.vv.vv......>.>.>..>...>...>>.>v>...v...>.>vv...>....>.v.>....>.>.>..v.v..v..vvvv.>v.>......v>>. +vv....>.>>.>>vv......v>>..v>>vv.v>v.>.>....v..vv..>..v>.v..v>vvv>.>>v....v..v.v>v.v.v>.v>v.v>....v.....vv...>vv.vvv.v..vv...v.>v.>v..v...>> +...>.>...v....>...>>.>....v>v....>vv..v>...v>.....v>.v>..>>>>.>.v.>...vv..>>>v.>v.>>..>.v...>.>>.v>.v.........v..v.v>v.v.>.v>...>vv..>v>.v> +>..vv..v.....>v.v.....vv.....>..>.>..>.v...>..>....>.>>vv......v..v>..v>vvv..>.>..vv..>>v>vv.>...>>..v.>.v.vv>>.>.v>>v..vv.>>....>...v...>> +....>v>>v.>...>vv..v>>.>v.vv...v.>v.>.>>...>>v.v>.vv>v..vvv.v>..vv.v.v>..v>.>>v...>......>vv...vvv.v>v.>....vvv.vv.vv.>..>>v.>>>>.>.>v>.v.. +...v...>>.>.>.....v.v.>.....v..>.v>>.>..>vvvv..>..>v>.>.v..>>.v......>..vvv.v.v...v...>.>.v.....>v>...>.>....>.v.v>>.vv.....v..>>>vvv.>>..v +..v.>v>.v.v.>>v>v>v...>..>..v.v>.>..v..>..>>..>>v.>.>...vvv..>v..v..>>v>...>v..v>......>.>vv.>.....>..>>>>>>v.v>..v..>v..>>>..>vvv>.v..v.>. +v.>.>.v.>v...>.v.......>>....>...v.v>..>v>.v..v>..vv..v>...v.>..>>...v>..>.>.>v..>v>vv.v...v...>..v..>vv...>v>....>>v>.>.......v>>.....>v>v +>.>>..v...>v...vvv.>vv......>>.v>.v...>>.v........>.>.v......vv.>>v>.>v.vvv>.v>.v..>.....v.v>v.v...v>>....>>..v....vv>>>v.>.v..v.>.v.v..vvv +>.>.>....v...>>>...>v..>.v...>.vvv..v.....>>...>.>.v>..v..vv>>v>>.v>...v..>v>.vv.v.>.>..>.>v>>....>.>vv>..>>.>v...vv......vv>>>>>.>..>.>.v> +>...>>....>...vv.v.>.v>..>.vv.vv....v.v.>.v>>....>>vvv>...>>>.v.>>..v.vv..>v>v>.v>>..........vvvv...>>vv..vv..>>v...vv>>...v>...v>.v...>>.v +.v.>..v...vv..v>...v....>vv>v..>v..>..v>>v....>.v>.v.>.vv...v..v>>>>.v>>.vvv...>.v.>.>>>....>....v.v..>>>.v.>..v.>.....v..>>>>.v>..vv.v>>>> +vv.v...v...v>..v>v>>..v.vv>>>>vvv.>v>vv...v>v......v...v>.......v.v..>.>....>>..>v>.v>>v.v.>.>v>>>.vv.v>>>..vv.>v.v>...>.v..v.vv.....>>>.>. +.>.>v>..>.v.>v.vv.vv..v..>v..v>.>vv.>>.>..v...>>>.>.>.>>..>..>v>.v...vv.>.v.v.v.>>.>>>v>..>v..>>....>v.>>.....v.>.>>.............>...>.>>v. +>..v..vvv>v>..>vv>...>.v.v.>v.>..>.>..>..>v.v.vvvv.v.....vv.v..v...vv.vv..>.v.v>>...v>>....v..>.v.v..v>..>>vv....>>>>..>..>>>>v>v...>...vv. +..>.v....>v.v.v.>.>...>....>.>.>v.>>>.v>.vv.v>..vv>.v.>..>.vv>v..vv>>...>v>v..>vvvvv.vv....>>..vv>v>>v>....v>>...>v>vv>..vv>>>vvv..v.v>.>>v +.v.v..v>....>>vv.vv.>.>..>v>..>.v.vv.>>v>.v.v.v...>.>>v.....>.>..>>v>.>..v.vv.>>>.vv>...v..>..v>vvvv>.....vv.v.>>>>..>>vv.>vv>.>>v>..>...>v +.>v>.>>.>>>..v>v>.>>.v..>..>vv.v.>.vv.v.v>.>.vv.>..>>...>vv.>>..v..>..v.v.>>.v..v.vvvv>v>.v.>v..>v..>v.....>.v..v.>v....>.v>>>v.v>.>..>.v.v +>..>v.....vv.v>v>>.v.>.vvvv..>vv.v.v>.vv>...>......v..>>.>..>.v...>.v.vv.....vv..vv....v>v>>vv..v...v..>>.>v>.>v......vvv.vv.v...>>..>.>v.> +.v.v...>>v>v>...>>..v..v...v.v.>>.v>.v>v>.>vv>v...v>>.v>v.>.....v.>.>....v..v>v.>v>...>..>>...vvv>.vvv.>>>vvvvv>..>.v....v.>>>.>.vvv..>v.>v +..vv>v..v>.>>..vvv....v>>>v..v....>.>.>...v.v.v.>>..v....>v>..v>>..v..>....v...vvvv.>v..>...v>.......>..v.vvv..>..>v....v>v>vv>....v.>..v>v +.>>...v>vv.>.>v>>v.>v...>>.>.>..>v>v>>..>>>.>>v...>vv.>vv>v...v>v>...>>..v>..>.v>.>.>vv>.vv...>v.......v>.>v>.>....vv>...v.v.v.v.v>.>.>..v> +>vv.v.vv>...v.>>>>>v.>>..v>..v.vvv...v...>.v...>...>vv..>.v.v....>.>v>.v..>.v...v>.>>...v..v>>..vv...v.>..v...>...v.>v..>v>>v.v>v.v..>>..v> +..v...vv..>v.vvv>.....v..v..>>..vv>....v...>..>.....v.vv>.v>>>...>v.vv.v..>>v>>v..>v.....>..>.>.>.....v.>..v.....>.v.>>>vv.>>.vv>>..>.vvv.v +vv...>..vvvv>>v..>v>.v.>>..>>v..>>.>.v>.>...>>...>.vvv>..vvv..v>....>.v>.>...>.>>>...vv...>.v>>.>.vv...>>>>.....v>>>..v..v...v..v..v...>... +v>..v...>v..v..>....v.>>...>vv..v>..vv.v..v.v.vvvv>.>...v>>.>>>v.vvv..v...vv..v.>v>.v>>v>..vvvvv.>v.>.>...>>.v>.>.v.vvv....>..>...v>>..>v>. +.>>v>vv.v>....>.>.v...vv>v..v>.v.v...>.>>....>.v.>.>v>>>.>.............v.vv.v>.vv.vv>>...v>..>.v..>v....v>v..v...v....>.>.....vv>>.....vvv. +..v>.>>.>v......>.v.v.>vv>....>>...vvv>...v>.>.v..>vv..>>v......>v.>>vv.v....>..>vv.>>.v..>..>...vv>vv>>.vv.>>>>>>.>.vv.>vvv...>v>.>>v>v.>. +v>..v.v.v..vv.>>.v>.v....v..>.>..v.v>v..>vv.v>....vv..v...>.>v.vv>....>.v>...v>..v.>.....>v...>>.v>.>.vv.>>.....>v>.vv.v...v...>v>>>v.>v>.. +>v>..v...>v..v.v..>>.v>>....>v.>v.>v.v.v.v..>>>.vv>>>.>vv..v....v..>..>v..>v..>.....>>v.>...>vv..>..>..vvv..v>..>.v>>>v.v.v>>...v.>v...>... +..v...>...v...v..>>..v...>v..>.vv..v>.....>.v..vv>.>>.>...>>.v.v>>..v>.>...v>...>>v.vv..>>vv>..>v>...>..>v.>vv...>.v..v..v>...vv..>..>>..>. +>...v.>......vv.>>..v.>........>v...v.>>v>>v.vv.>...v>..vv>>..>v..v>v.v>.v..v>.v.....>vv.v>>>..>.vv>vvv..v.>v...v.v.>...>>v.v.>>v>..v.vv.vv +.>..vv>.>.v..>.v.v>..>.v>>>..>v>.v>.v.>>>>....v..>>>v>v.v..v>..vv>vv..vv.>v.v.vvv>.......>>.>>.v.>vvv..>v>....vv.v..>>.....>vv.v..>.vv>v.>. +>>.v>.>.>....>....>v..>vv..>>v..>>>....v.>vvvv>>.>v...>...v>v..>...v.>..>.vv.vv..v>.vv>>.....v>..>v....>.>..v.v..>..>v>...v..>.v.......v.vv +v>>....v.>.vv.vvv>>.v.v>>..>.>.....v...>v.>>..v...>...>v..vvv>.>.>>>v.vv>..>>..v>v.>vv...>..>v.>.>.v.>.>vv..vvv>>.>..>...v>.v>...v>.v>.>..v +..>vvv..v..v>>.vvv>.v....vv.v>>vvv>>v......vv.....v>>>..>.v..>.v>v>v>v>v>.>....v>.vvv...vv>.v.v.>>.vv>...v>....v...>....>>>.>vv.>....>.>>vv +v>vv...>>..>v.>v..v..v>v...vv..v>>.>v>..>...>>>.v.>vv.vv.>.>...v...>.>.v>..v>v..>v>vvv>vvv..v>>v>vv.>v>.>v....>vv...>>.v.>v..>.>>v..>...>.. +.>.vv.....>>v.>..vv...vv.v.>.>......vv..v>.>...v..v..v>.>.vvv...vv.v.....>.vvv.v..v>...>>v>v..>>v>....>.>..v.>v.>vv.>>..v.v..v.v>.v..>>>... +v.>...v..v..>.v>v.>v.>.>..v>...>...>>v.>.>.>>vv>>>>>v..>.......>>...>.......>vv>>>>>....>.......vv>.>...v>..>v..>vv>>...>...>.v>.>>vv.>>... +v.v..v>vv.v.>..>.v..>>v>....>>.v.>v>>v.>..v>v.v>...>>v>>vvv.>...vvv....v>.>>vv.v.....>>..v>.>.>>v......v>>..v>....v..>vv>.>vv>.>..v.>>.v.vv +>..v....v.>>v>>vv.>.>.vv.>>..>v..>.v..>......>>.......vvv>.>>>>>>v.>>>>v.>v.>vv...v>vv..v>>..>..>.>>..vv.>>v>...v...>.>..>.>v..>..v.vv>>..v +vvv.v..>.>vvv.>>...>>.....v.v>v>.>>>...v>v>v.vv>>>>vv...v>.....>v>v..v>>v...>.v..>>v>.v...>..vv....v.v.v.v.v...>.>.>.vv.>v.>>>>v>v>.>...v.. +v.v..>....v...v>.vv.v>.>>.>v..v>......>..v.>>vv>>.v...>......>>.>vvv.>>>v>.v..v...v...vvvvv>v..v..v>..>...v.....v>.>v..>v..v.>>v.>>.>v...v. +v>>..>vv>>>........v.>>>.>>>>>>..>..>...>>.vv>vv.>..>..v.vvvv...>.>.>.v....>.>>v>v.>>.vv>.>..v..>...v.v...v>.>.v.>v>.v..>....vv.>>.vv.>>>.. +.v>.>....vv..>....v>.>>...>v>.v>.v......vv.>...>.......>.>v>vv.....>..>v>v.>....v.>>v.>>v>v.....>...v...vv..v>v>v>v..>>.vv>....v.v>...>..>. +.>..vvvv.>...v......>>.v..>....>v>.v>.>...>.v.v..v......>.v>vv>v..>>..v>.>.....>.v...>..v.v..vv.vv>v..>>..>>..>vv>>>...v.v.>>>..>>v.>v>>..> +>...>v>v.>.....v..>....v.>..>.>vv>>....v>....>v.>...v.>v.v....>...>v>v.>.v.....v.>>.>>v.>v..>v.vv.>v...>.v>.v....>>>..v>.>v.>>>>vv...v.>.>> +v.....v>v>v>>v.>>>.>.>...>v..v......v.v>..vv>>.>v>v..v.>v>.>.>vv..>...v..>...>v.>>.....>>...>.>v.>v.v...>.>v.v>.v>.>..>>>.....>>v.>..v....v +v...v..v>>.v.....>v>..>v.v.v...v...vv.>.>..vv>.>>...v.v>vv.v.>>...vv.v...v.>....v.>...>>..vvvv..v>>>vv.>>....v.v...v.>>vvv>..>v.vv>.>>.>.v. +.vvv.vv..>vvv>.>..>..>>>v.vv>..v>.v..>.v.>v>vv..v.>.vvv..v>.v...>.v>>.>>.vv...>>.vv...v..vv..>v>vv>v.v...>v>>vvv.v>.vvv>.>.>.v....>..>>v.v. +>>v>......v>v>...v.>v>v>>.vv.>..vv..>>..>v.>...>....v>..v.>.....v.>>.v.>...>>.>>.v>..>v..v..>...>v.>v.v...v>v..>>..v.v.>v..v..>>...>.vv.v.. +v.>.v.>.vv.vvv.vv.>v>....v......vv..vvv>...>>.>....v>.>.v....v....>>.....>.vv>.vv>v.>v.....>..>>.>v.vv..>v.>..v>v.v.>vvv>vv>.......v.v.vv>. +v....>.>..v.>.>v>.v>vv..>>.v..v..v..>>.v>>...>v>...>v..v....>....v..>>..>>.v...>>....v..v.>v..>v>....>.v>>.v>v..>v>...v..v.>....v.....>..v> +..>>...>v....>v>v>>>....v>v.....>>.v....>>>v.>...>..>.>>v.v.>v>>..v.>>.>vvv>>>.vvv.>..v.....>.vv..v.......v..>...>...>....>vvv..>>v.>..vv>> +.v..v>....vv.>>v...>v..v.>....v>v.>..>>vv.>..>..v>.>...>v>v>v.v>.>.v..>>v>..vv..vv..>.v..vv>>>......vv.>v>>...>v.v.>>.>..vv.vv.>.>>>v>vv... +>v>vv.......>v>.v...>v.vvv>...v.>.>v.v..v.v>v>v.v..v.v.>.v>>.>>..>..>.>>.>v>v..>.>...>vvv.v>v>.....v.vv>>.>.vv...>.>...v...v.>vv.v..>.vvv.. +>>.>>>......vvv>v..vv.v..v>>..v....>>.v..>vvvv>v>>...v>>>..>>vv...>>vv.>.vv>>>..vv>.v>..v.>..v.vv...v.>.vv>>vv>>>..>.v....v>>vv.>>.vv...>.. +v....>>>..v..>v..>.v>v...v>v..vv......>vv.v.>....>..v.vv..>vv>v.v..vvv.v.>v.>.v...>....v..>.>v.v>>.>.>v>>..>.vvv>vv.v.v.>vvvv>..>.........v +......v>..>...v..vvv.v>...v.v>>vvv.v.>....v.v.v.>...v..v>>>>..vv.>v.>..>.v>>..>>.>vv.v>..v.>v>>..>v..>vv..>.vvv>..vv.vv...>.>>.vv..>...v>v> +..v>>.>v.>.>v>..vv..>>..>>.>..v>...v..>>>..v..>.v.>v>..>>...vv.>v.>v...v>v..v>..>>vvv......vv.>...v..v>>>vv.v...v.v.v.>>>..vv>v>v...v>..... +..v>>>..v..v.>>.>>.v..v......>>.vv>.v.v>>.>...>.v>>.>>..v.v>.v.>>....v.>.....>.>>v.v.....v>vv.>.>>>..v..>v....v>.vv>...v.v>v..v...>...>.>v. +.>.v.....>v.vv..>.>v>v.>>v.v.>>..vv>>v...vvv..vv.v.>v....vv>....vvv.v..>>.v..>>>....v..>..>>>>>>.>.>.>.v..>.>...>>>.v>vvvvv.>..v.>>..vv.>>. +>.>...>v..>>..v..v.v..v>....>.v.v>..v...v..vv.>v>vv.>....>>v.v>vv...>..v>..v..v>.v>..........vv>v.v.>....>.>.vv>>....>.v..v.v.>v>>>>..v.v.. +v.v>.v>>.>>.v.>>....v...>...v...v.v..>..>...>vvv>......vv...>>..vv.v>>>>..vvv....v.>v...vv.v.>v>..v.........>v>>.>..>.v..v..v.v.v.>.v>...v> +vv.>.v..v...v.v.>>>vv..>...>.vvv>v.v>>>>>>....>>>...>v>>..v.>.vv>>v..v.>vv>.vvvv...>vv..v...>.>...vv>..v>.v.>v>.v>.v....v.v.>v..>........>. +v>v>>..>.v.v..>v....>.>>..v>...v....>v.>.>..v.vvv..>.>vvv.>v..vv>...v.>.>v.>.v>.>...v.v>.>>>>>.>.....v.>..>v>.v..>>.>.>>...vv..vvv....v>.>. +>..v.v.v...vv>..>>vv>v....vv>vv.v>v>>v>>....>.>.v>.>...v.>...>v..>v>vv..vv....>..vv..v>..>vv.v>>..>....>v.>>.v...>.>..v>>vv...vvvv.....>v>. +v.v........>......v.v..v...>>>.v>v.>....vv>v>.v.v>..>>.v.>..>..vvvv>>.v.>v..vvv.v..>.vvvvv.>>>...v>.>v...v>>..>v.>>.v>>..v>.vv.vv.v>.v>v.v. +v....>.v..v...vv.>.....v..v...>.....v.v.>...v..v.v>>>...>.v..vv.v.>>>v...>v.v...v.>>v..>..>.>.>>>..>v.>vv>vvvvvvv..>>...>v.>.v.v>>vv.>.v>>> +>>.vv...v....>.v.v...>>.>>v.>..>>v.>>.....>>>vv........>>..v...v>v...v.vv..v.v>vvv.>.>v.....v..>>..>vv.v>..vvv>.....vv>....v...>.vv.v.>.>v> +v.>.>.v>>...v.>>.>vv....v..v..>.>.>>vvvv.>>>.vvv.v.....>>>.>..v..>.vvvv>.v...v.v>..v.vvv..vv.>..v.>vv.>.vvv...v.vv..>v>v>>v>>..>v>>.>>.>... +...>.>>>...v.>>.......>.>..v.v..>vvv...vv..v...>v>>.....>.vv.>v>.v.>vv>v>.......v>vvv..v>.......>..>v..>.>>...v..>..>...>>v..>.v.>v.v.v>... +v...>.v>v>..>v.v......>.v....>v.>vv........vv.>>v.>.>......v.>v.>>>v..>.>>>..vv.v...v>>.v>...v>v..vv.>.>>..>.v..v.v.v.>...>v>>..>>>>>..v... +v>.....>.>>vv>>v....>v.v..>v..>v..>v.v>v.>v..v.>v...>...v>..v..>.......v..>>v.vv......>>v>>v.vvv>..>>>v..v.>v..v>vv..v.>v.v.vvv>..v..>..... +..vv.>vv.>vv..>..>>v.v.>>v.v>.>v>..>vv.>....>vv.v.>.........v...v.>>v>v>>>>.>..v...vvvv.>.v.........v..vv..v.>>.>.>v.>.vv.>....>vvvv.v..>.> +..>..v>....>.vv.v..>...v>.....>>...v.v......v>>.vvvv..>....>..>.v...vv...>>vv>vv>....>v.v.>v>....vv.......>.>v.v>>v.v..>>....v.v.>>>v>.v..> +..v>>vv>v.v.vv>>v.>v.v.v..>.v.>v..>v....>v.....v>vv....vv.v.....>.......v.>vvv..v.v.>..>.vv.>>v>..v.>..v.>>>..vv......>.>..........>v.v..v> +.>>vvv.......v>...>>.>v>....v>v....vvv.v>......v...v..>v>>>>>.>.>v.>>>.>>>.>>>.vv.vv.....>...v.v>>.v.v..>>...>.v>v>vv.>vv.v..v>vvv.>v.>.... +..v.vv.v..v>v>......v.>..v..v>v..v...>..v.>....v>...vv>..>..vv.>..v.......v.v.>.>.vv...vvv>v>..v.>v>...v>.>vv.>v.>.>vvv.>..v.v.>.>.>v..v>>v +vv>...vv>.vv..>.vv.v>.>......>.>.>>>>>.>....v...>.v.>..>v>..>>.v>v.>..>.v.....v.v>....v.v>.v.v>v.v>>>..v...>v>.v....vv..>.>..v..v.>>v.v...v +vvv>.vv..v.>vv>..v...>>..v.......vv...v..v>...>>.>>>v>.v....>>.v....>>.>>.>vvv..>>>v.v.v...>.......>v>.>vv.vvvv.v..v.v...>..v.>.v..>v>vv>v. +>.....v>>v....vv..v>...v>...>.>.v>>........v.>.......v.vv.v.v..vv..>..>>v.>.>>.v.>..>>>v..v.v.v....v.v..>>vv.v...v.v....v.>>v..v....v.v.... +.v.>....v.>.>>>v...v>v.>>.>.>.>>.>>>.>.vv...>.>>.>>...v....vv..>...>..v.>...vv...>v.>v>.v..>.>..v>>>v.vv..v..vv>>..v..v.v>.>>....>vvv.v>v.. +.>.>vvv...v.v..>..v...>.....>>>v.v>.>>v.v.v>.>vv......>..vv.v>.>.vv>v......v>....vv>.vv>....v..>>..v.>v.>.v.>>>>v>......>..>..v>...>.>vv>>. +>v>v...>...v.vv>>.>.>v.>>.v..v..v..v>...vv>.....v...>...v.......>.v.....>>>.v...>..>v>.>>...v.>>.>..vv>.>v>..>.>...v.......v..vv.vv>.v.v>.v +v.vv..v.v..v>.vv....>.>....>...v>>.>.>>v.vv>.>>...>>.>..>>>vv>.>.vvv...v..v..v.......v........v>v..v>..v.>vv>.>>..>....>..v.v>.vvv>.>.v..>. +>.....>>..v>..v..>>.>v..v.v...v..v>.v.v>.v.v...v.>..vv.vv.>>...v...vv.>>.>.v>..v.....v.....>v.....>v>>v.>vv>..vv.vv>v>..v>..>.>v>v..>.>.... +>..v>..>..>...>.vv...v>..vv..>>.>>.>.vv.v......>>.>...........v.v>..v..........v.>>.>>>.v.vvv>vv.>.vvv>...>...v..>v..>>.>...v.>>>.>>>v>v>.v +vvv......v..>>vv>.v>.vv>.>v...vvv>.>v.v>v..>>...v>..>..v>>>>>>..>>..vvv>.>>....>.v>..>...v..>>..vv>.>.v.v.v>.>>>.vvv>.v.>v>v>v.v.v..vv>v>>. +.v..v.>>v..>.>.v>..>.>.......>.>v...vv.>>>.vv..v..>v.>vv.v......>v.>>.>v>v.>.v>..............>>.>>>v>>>v>.>vv>>.v.......v.v...v>vvv.v>>v>.. +...v>v.vvv...>.>.>>v>>>..v..>.....>....v..vv>v>>v.v.>>.v>>v..>.......vv...>......v.>.v..v.>>.>v..>>..>v>v.vvv>vvv...>..>v.v..v...v...v>.... +v..>.v.>>v..>v....vv.>...>v>..vvv..vv>>.>>.>>v>>>..>>..vv.>v......v.v>v.>.v>v.>.v..>..v...v>>....>v....v.>v.v.>...v..v..>v.>.>.v>v..>vv.>.v +.>....vv>..vv>.>..vv.>v..v.v>>.v..>.......>vvv..v>vv.v>.v.vv.>......v.>.vv..v>...vvv>..v.>....vvv..>..vv.>>..>>....>.....v>>>.>.v..v.v..>.. +vv..v>v>...>..vv.>.>.....v..v..>vv>>...vv>>..>v.>v.>vvv>vv>>.v.>.vvvv.>...v>>.>..v.v>>v.vv...>..>..vv>.v.vvv>v.>>..>>......vv>>vvv...>..v>. +>>>>...v.v.>vvv..>.v..>>>.>>..v...v>>.>v>>v....v>>v..v.....v..vv.v>..v>v>.....v.>...>>>vv.v.v.v...vv.v.....vv....v>.v.>.vv.>.v...vvv..vv.>> +v.vvv>...v>vv.....v.vv.>.>v....v.>vv.v>>.v>..vv...>.v....>...>..>.v.>.v.vv.>.>>.>>v.>.v..>v..vv...v.>..v.>>.v>..>...v>.>>.>...>>....v....>. +>.>.vv>>>.......>v....>>>...v.vv>>..>.v.v..v>.v.v.....>..>v>>.>..>.vv...>..>.>>vv....>..v...v....v>>vv.>v....v.v>>....vv>.vv.>v>>.v.>.>.>v. +..v.>vv..v>.v..>.v......v...>.......v>v...vv>.v>....v.>....>....>v..v.>>>v>.v>..>.>v..>vv>>.>.>>.>..>v..v>>>...>>.v...>.vv>>.v.v>..v>.>.>>. +v>>>.>v.v.>>v>.vvv.>v....>..>.v>..v>..v.v.v..>>.>>..vv>>..>v..>.vv...v...>v...v.v>vv>>.....v>v...v.v.>.>>..>>..>v......>vv.>>>>vvv>..v>vv>. +v.vv..>v.v...>.>.>v.>vvv..>v.>vv.>v..v>.....>.>>.>>..v..v..v...v..v...v>.>v..v.>.>>.vvv>v..>...vvv.v>.>>....>>>..>.v..v.v.>.v....v>.v>...v. +..v.v........v...>>vv>>.vv>>>>v......v>>v..v.v.....>.v.>.v..v.....>v..>>..>>>....v..>.vvv>>.>>vv.v>.v..>v..>....v.vv....v>>>v...>.>>>.v...v +..>v.....v>.....v.>vv...v.v...>vv..v.v...>>.v>.v...>..>v>>v>>v>>>.vv>>>vv...v>..>vv..v>v>.>.v>>vv>...v.v>>.>.>.v..>v.....>>>.v.>v....v>v>v. +.....v..v...>>>vv.>>>>>>>v...>.v>>>>v.vv.>.....v.>.v>...>.>.vvvvvv...>>>.vv>..>>...v.v>..>v.v>>v.vv>...v>...v>...>...vv....>vv....>.v.v.v>v +..>>v>v.>..vv>..>...vv.>...>vv>>.v.....>....>.>.v>.v..>v..v.......v.......>>v>.>>v>>...vv>>>>....>>v>>......v.>..v>.>..>v...>>.>>>>.v.>..v. +v>..v.>vv.>>..vvv>vv>vv>>.v>>.>>.>.>>>.v......v..>.>>v>.....>v>>.>vvvv..v....v..>>vv..>...>>>...v>.v.>..v.....>>.v.v>.>...>.>.v.>.v>...>>vv +.v...vv.v>..v>.v.v>...>v.v>>>>..>.vv.........>v....v.vv.v>>v...>vv>>v..vv.v>.>.>>.v>..vv.v.>......v.>.v..>>>>>..v.>vv..v>.>.v..>..>..v..>v. +>..>v.>.>..v.>......v>..>.>..v>.vv.>.>>>.vv>>v..>..>.>.>.v>>v.>>...>..>>......>..>>v.v>..>..v.....>.>.>>v.>..>.v...>.>...v.>>>v...>.v>v.... +>.v>>.vv...v>vv.>>.>vvv>>>>..v.v>vv..v..>vv.........v>...v..vvv.>.vv>>v>>>...>>v>vv...>..v.>.v.>>.>..>..>>..>v....>..>vv.....>>...>..v.v.>. +..v>v>..>.v.....>>.v..v.v.v.>>vv..>v.>>..>.v>.v.vvv.....vv>...>.v>v.>v.>.>v.>>.>vv>.>>v..vv>v.v>v..>vv...v>>.>>>...v...>.>.vv.>>v>..v>v..v. +.v>..v>v>>>..v.>..v..>.>>..>.>.>>.....vvv..v...vv.v>>>.>>.vv.v.v.>vv..v.....>.v>......v.>..v..>>..>vv...v>.>..>.>.vv>...v.>v...>.>>>.>..>vv +.>..>v.vv.>vv.>vv..>..v>>.v.>.>v>v>>v...vv.>.>>>..v>.>v.>vv>.>..vv>v>.>v.>>.>.v..v.>.v>.>.>.v.v........>vv.vv.>vv>.>.v..v>.....>v.>vv.>vv.> +..>.>vv.vv..>>.>vv.v.>...>vv.v.......>....>vv>vvvv>..v...>v.....>v>.>>v.>..vv>>v..v....v>vvvvvv.>....>.>>v..>.v...v>.>....vv...>.vvv>>>>.v. +vv.>.v.v..>.>.........>v.v.v..>v....>.v>..>.>v>v..v>v....vv.>.....v.v.v>>>.v..v>.v.v..v..>v>..>......>.vvv..>..v...v........v..>....>..v..> +>vv..>>v..>>vv...>...>>..v.v>....>>v>v>>.v.vv>.v.>>..v>>>>v>>v>>v.v.>>..>>>>>.>...>.>.>v....>..>>.vv....>....>vv>vv>....>....>vv>>>.>>>.... +.>v>....>>>.v>>>v.>v.vv>v>...v>v>..v.v.>>......>.....>.v..>vv>.vv..>.>v>v>.v>.v..>v..vv.v.>......>>>...>..vv.v>vvv>v.....v>>vv>v>.>.>.>.>>> +....>v>..v>>v.v.>v.vv.>v...vv.v..>>v>>.>v.v>.....>v>.v>..>v..>.>vv>v.v>v.v.>vvv..v>..v.v.vv>....vvv...vv.vv>>.>vvv..>v>v..v..v.v>>>..>.>... +>v>v.v...v.vv...>>vv>.....v....>...v..>.>......>v>>.>..v..>.>..>>.>....v..>>v.>v..>.>.vv>v..v...v>.>v.>>..>vv.>...v..>.>v....>..v>v....v.v. +.>>.....>.vvv.v>.>v>>.....vv>....>..vvv>v.v..>v>>....>vv...v.v.>.vv.>>>.v>.>v.>>v.vv>..>>v>.vvv.v.v.v>>..v....>>.vv>v.>.>v.....v.>.....>... +v...v..>v.>.>.v..>...>v.>..v..vv.v..>.>.v...v...>v>.vv..>.>v.>>.>v>..v.v.v.>v...>.>v>..v>.....v..v>>..>..vv>..>...v>>>..>>...v.>.v.v..>.>>> +.>>>.>v.>>.>..>>...>v..v..>.>..v>v.>.>vv.v.v....vv..>.v>v...v.....v>...>>v.>.>.vv..>vv..>v>..>vv.>v..>>.v.>v.>>.>.v>..>>v>v.v>v..vv.>vv.>.> diff --git a/2021/day25/Makefile b/2021/day25/Makefile new file mode 100644 index 0000000..07fc3b7 --- /dev/null +++ b/2021/day25/Makefile @@ -0,0 +1,77 @@ +# AOC daily Makefile - GNU make only. +# +# Copyright (C) 2021 Bruno Raoult ("br") +# Licensed under the GNU General Public License v3.0 or later. +# Some rights reserved. See COPYING. +# +# You should have received a copy of the GNU General Public License along with this +# program. If not, see . +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +INPUT := INPUT.txt +SHELL := /bin/bash + +CC := gcc + +LIB := aoc_$(shell uname -m) +INCDIR := ../include +LIBDIR := ../lib +LDFLAGS := -L$(LIBDIR) +#LDLIB := -l$(LIB) -lm +LDLIB := -l$(LIB) + +export LD_LIBRARY_PATH = $(LIBDIR) + +CFLAGS += -std=gnu99 +CFLAGS += -O2 +CFLAGS += -g +# for gprof +#CFLAGS += -pg +CFLAGS += -Wall +CFLAGS += -Wextra +CFLAGS += -march=native +# Next one may be useful for valgrind (some invalid instructions) +# CFLAGS += -mno-tbm +CFLAGS += -Wmissing-declarations +CFLAGS += -Wno-unused-result + +CFLAGS += -DDEBUG_DEBUG # activate general debug (debug.c) +CFLAGS += -DDEBUG_POOL # memory pools management + +TIME := \time -f "\ttime: %E real, %U user, %S sys\n\tcontext-switch:\t%c+%w, page-faults: %F+%R\n" +export PATH := .:$(PATH) + +.PHONY: clean all compile assembly memcheck memcheck1 memcheck2 ex1 ex2 + +all: ex1 ex2 + +memcheck: memcheck1 memcheck2 + +memcheck1: + @valgrind -q -s --track-origins=yes aoc-c -p 1 < $(INPUT) + +memcheck2: + @valgrind -q -s --track-origins=yes aoc-c -p 2 < $(INPUT) + +compile: aoc-c + +assembly: aoc-c.s + +ex1: aoc-c + @$(TIME) aoc-c -p 1 < $(INPUT) + +ex2: aoc-c + @$(TIME) aoc-c -p 2 < $(INPUT) + +clean: + @rm -f aoc-c core* vgcore* gmon.out aoc-c.s + +.c: + @echo compiling $< + @$(CC) $(CFLAGS) $(LDFLAGS) -I $(INCDIR) $< $(LDLIB) -o $@ + +.c.s: + @echo generating $@ + @$(CC) -S -fverbose-asm $(CFLAGS) -I $(INCDIR) $< -o $@ diff --git a/2021/day25/README.txt b/2021/day25/README.txt new file mode 100644 index 0000000..6035832 --- /dev/null +++ b/2021/day25/README.txt @@ -0,0 +1,285 @@ +--- Day 25: Sea Cucumber --- + +This is it: the bottom of the ocean trench, the last place the sleigh keys could be. Your submarine's experimental antenna still isn't boosted enough to detect the keys, but they must be here. All you need to do is reach the seafloor and find them. + +At least, you'd touch down on the seafloor if you could; unfortunately, it's completely covered by two large herds of sea cucumbers, and there isn't an open space large enough for your submarine. + +You suspect that the Elves must have done this before, because just then you discover the phone number of a deep-sea marine biologist on a handwritten note taped to the wall of the submarine's cockpit. + +"Sea cucumbers? Yeah, they're probably hunting for food. But don't worry, they're predictable critters: they move in perfectly straight lines, only moving forward when there's space to do so. They're actually quite polite!" + +You explain that you'd like to predict when you could land your submarine. + +"Oh that's easy, they'll eventually pile up and leave enough space for-- wait, did you say submarine? And the only place with that many sea cucumbers would be at the very bottom of the Mariana--" You hang up the phone. + +There are two herds of sea cucumbers sharing the same region; one always moves east (>), while the other always moves south (v). Each location can contain at most one sea cucumber; the remaining locations are empty (.). The submarine helpfully generates a map of the situation (your puzzle input). For example: + +v...>>.vv> +.vv>>.vv.. +>>.>v>...v +>>v>>.>.v. +v>v.vv.v.. +>.>>..v... +.vv..>.>v. +v.v..>>v.v +....v..v.> + +Every step, the sea cucumbers in the east-facing herd attempt to move forward one location, then the sea cucumbers in the south-facing herd attempt to move forward one location. When a herd moves forward, every sea cucumber in the herd first simultaneously considers whether there is a sea cucumber in the adjacent location it's facing (even another sea cucumber facing the same direction), and then every sea cucumber facing an empty location simultaneously moves into that location. + +So, in a situation like this: + +...>>>>>... + +After one step, only the rightmost sea cucumber would have moved: + +...>>>>.>.. + +After the next step, two sea cucumbers move: + +...>>>.>.>. + +During a single step, the east-facing herd moves first, then the south-facing herd moves. So, given this situation: + +.......... +.>v....v.. +.......>.. +.......... + +After a single step, of the sea cucumbers on the left, only the south-facing sea cucumber has moved (as it wasn't out of the way in time for the east-facing cucumber on the left to move), but both sea cucumbers on the right have moved (as the east-facing sea cucumber moved out of the way of the south-facing sea cucumber): + +.......... +.>........ +..v....v>. +.......... + +Due to strong water currents in the area, sea cucumbers that move off the right edge of the map appear on the left edge, and sea cucumbers that move off the bottom edge of the map appear on the top edge. Sea cucumbers always check whether their destination location is empty before moving, even if that destination is on the opposite side of the map: + +Initial state: +...>... +....... +......> +v.....> +......> +....... +..vvv.. + +After 1 step: +..vv>.. +....... +>...... +v.....> +>...... +....... +....v.. + +After 2 steps: +....v>. +..vv... +.>..... +......> +v>..... +....... +....... + +After 3 steps: +......> +..v.v.. +..>v... +>...... +..>.... +v...... +....... + +After 4 steps: +>...... +..v.... +..>.v.. +.>.v... +...>... +....... +v...... + +To find a safe place to land your submarine, the sea cucumbers need to stop moving. Again consider the first example: + +Initial state: +v...>>.vv> +.vv>>.vv.. +>>.>v>...v +>>v>>.>.v. +v>v.vv.v.. +>.>>..v... +.vv..>.>v. +v.v..>>v.v +....v..v.> + +After 1 step: +....>.>v.> +v.v>.>v.v. +>v>>..>v.. +>>v>v>.>.v +.>v.v...v. +v>>.>vvv.. +..v...>>.. +vv...>>vv. +>.v.v..v.v + +After 2 steps: +>.v.v>>..v +v.v.>>vv.. +>v>.>.>.v. +>>v>v.>v>. +.>..v....v +.>v>>.v.v. +v....v>v>. +.vv..>>v.. +v>.....vv. + +After 3 steps: +v>v.v>.>v. +v...>>.v.v +>vv>.>v>.. +>>v>v.>.v> +..>....v.. +.>.>v>v..v +..v..v>vv> +v.v..>>v.. +.v>....v.. + +After 4 steps: +v>..v.>>.. +v.v.>.>.v. +>vv.>>.v>v +>>.>..v>.> +..v>v...v. +..>>.>vv.. +>.v.vv>v.v +.....>>vv. +vvv>...v.. + +After 5 steps: +vv>...>v>. +v.v.v>.>v. +>.v.>.>.>v +>v>.>..v>> +..v>v.v... +..>.>>vvv. +.>...v>v.. +..v.v>>v.v +v.v.>...v. + +... + +After 10 steps: +..>..>>vv. +v.....>>.v +..v.v>>>v> +v>.>v.>>>. +..v>v.vv.v +.v.>>>.v.. +v.v..>v>.. +..v...>v.> +.vv..v>vv. + +... + +After 20 steps: +v>.....>>. +>vv>.....v +.>v>v.vv>> +v>>>v.>v.> +....vv>v.. +.v.>>>vvv. +..v..>>vv. +v.v...>>.v +..v.....v> + +... + +After 30 steps: +.vv.v..>>> +v>...v...> +>.v>.>vv.> +>v>.>.>v.> +.>..v.vv.. +..v>..>>v. +....v>..>v +v.v...>vv> +v.v...>vvv + +... + +After 40 steps: +>>v>v..v.. +..>>v..vv. +..>>>v.>.v +..>>>>vvv> +v.....>... +v.v...>v>> +>vv.....v> +.>v...v.>v +vvv.v..v.> + +... + +After 50 steps: +..>>v>vv.v +..v.>>vv.. +v.>>v>>v.. +..>>>>>vv. +vvv....>vv +..v....>>> +v>.......> +.vv>....v> +.>v.vv.v.. + +... + +After 55 steps: +..>>v>vv.. +..v.>>vv.. +..>>v>>vv. +..>>>>>vv. +v......>vv +v>v....>>v +vvv...>..> +>vv.....>. +.>v.vv.v.. + +After 56 steps: +..>>v>vv.. +..v.>>vv.. +..>>v>>vv. +..>>>>>vv. +v......>vv +v>v....>>v +vvv....>.> +>vv......> +.>v.vv.v.. + +After 57 steps: +..>>v>vv.. +..v.>>vv.. +..>>v>>vv. +..>>>>>vv. +v......>vv +v>v....>>v +vvv.....>> +>vv......> +.>v.vv.v.. + +After 58 steps: +..>>v>vv.. +..v.>>vv.. +..>>v>>vv. +..>>>>>vv. +v......>vv +v>v....>>v +vvv.....>> +>vv......> +.>v.vv.v.. + +In this example, the sea cucumbers stop moving after 58 steps. + +Find somewhere safe to land your submarine. What is the first step on which no sea cucumbers move? + +To begin, get your puzzle input.