Compare commits

...

244 Commits

Author SHA1 Message Date
kageru 3f31db2078
wip day 23 2023-12-25 19:01:16 +01:00
kageru b7db7574fa add 2023/20/1 2023-12-20 11:32:44 +01:00
kageru 702a77a31e add 2023/19/2 2023-12-19 16:22:54 +01:00
kageru 71f395b2ad rewrite 2023/19 for part 2 2023-12-19 13:09:00 +01:00
kageru 36ca0e4fe8 add 2023/19/1 2023-12-19 12:41:01 +01:00
kageru 28fe5655b2 clippy 2023-12-18 17:08:53 +01:00
kageru 2d506e3799 add 2023/16/2 2023-12-18 17:06:42 +01:00
kageru 07972e3029 add 2023/16/1 2023-12-18 16:43:13 +01:00
kageru 5b581eeb73 optimize 2023/10/2 2023-12-18 15:53:14 +01:00
kageru 3d75d43136 cleanup 2023-12-18 15:34:51 +01:00
kageru 2141df8612 add 2023/18/2 2023-12-18 15:09:09 +01:00
kageru 808360a58f optimize 2023/18 2023-12-18 14:57:40 +01:00
kageru 9779f22040 add 2023/18/1 2023-12-18 12:35:28 +01:00
kageru 93d9798a60 add 2023/15/02 2023-12-15 10:22:31 +01:00
kageru 13e499ad58 add 2023/15/1 2023-12-15 09:37:42 +01:00
kageru a81b6e6760 clippy 2023-12-14 10:50:44 +01:00
kageru 50bd733e55 add 2023/14/2 2023-12-14 10:43:20 +01:00
kageru 433b554594 add 2023/14/1 2023-12-14 09:18:51 +01:00
kageru b0ebf8e3d4
make part1 part2 2023-12-13 12:51:08 +01:00
kageru 1338681cf4 make p2 linear time 2023-12-13 12:30:51 +01:00
kageru 8e36759477 make it a bitmask 2023-12-13 12:08:26 +01:00
kageru 22cf7c40b1 add 2023/13/2 2023-12-13 10:35:25 +01:00
kageru f23a95e2e2 add 2023/13/1 2023-12-13 09:30:03 +01:00
kageru ff7cfe5768 cleanup 2023-12-12 16:39:07 +01:00
kageru eb5e58d4a1 add 2023/12/2 2023-12-12 16:21:36 +01:00
kageru bb17e9d9a3 add 2023/12/1 2023-12-12 13:05:11 +01:00
kageru 61edcdb649 optimize day 11 2023-12-11 10:14:25 +01:00
kageru bff0e7601b add 2023/11 2023-12-11 09:46:35 +01:00
kageru 79e6931c13
slighly clean up day 10 2023-12-10 22:38:41 +01:00
kageru b9c3ebc7d7
add 2023/10/2 2023-12-10 21:50:02 +01:00
kageru 8cc873f4fe
add 2023/10/1 2023-12-10 18:37:39 +01:00
kageru 7c980c2648
fix release build for day 9 2023-12-10 17:23:50 +01:00
kageru cae56e170c
add 2023/09 2023-12-09 09:28:50 +01:00
kageru 55e6875732 day 8 benchmark chasing 2023-12-08 11:20:44 +01:00
kageru 68592f33ac more cleanup 2023-12-08 10:06:19 +01:00
kageru d136b4bd66 add bench for lcm 2023-12-08 09:49:45 +01:00
kageru f873147e3a
use fnv 2023-12-08 09:17:58 +01:00
kageru ce111e1a62 make part 2 shorter 2023-12-08 08:54:41 +01:00
kageru bf6619d638
add 2023/08/2 2023-12-08 07:40:21 +01:00
kageru 13daf93f49
add 2023/08/1 2023-12-08 06:30:11 +01:00
kageru b430bfb69a some cleanup 2023-12-07 13:50:06 +01:00
kageru e18f10cb4f add benches for 2023/07 2023-12-07 12:57:07 +01:00
kageru da2401d54a add 2023/07/2 2023-12-07 12:49:37 +01:00
kageru f04588c2f0 add 2023/07/01 2023-12-07 11:19:37 +01:00
kageru 6d929808c8 fix rounding 2023-12-06 12:20:29 +01:00
kageru 1063818bf3 add 2023/06 2023-12-06 11:42:06 +01:00
kageru 9a9545425a optimize 2023/05/2 2023-12-05 12:59:09 +01:00
kageru b27523103a add 2023/05/2 2023-12-05 12:26:05 +01:00
kageru 2e5602388d add 2023/05/01 2023-12-05 10:52:38 +01:00
kageru 857a7cd8fe remove unnecessary bounds check 2023-12-04 17:58:03 +01:00
kageru 0f19847480 2023/04 compute more during parsing 2023-12-04 11:42:26 +01:00
kageru 3ec8057f64 add tuple_map 2023-12-04 10:30:01 +01:00
kageru 44fa3dc40f add 2023/04 2023-12-04 10:20:57 +01:00
kageru 932d92ddba
get rid of ranges 2023-12-03 20:40:33 +01:00
kageru db09b873ed
make position generic over number types 2023-12-03 20:11:55 +01:00
kageru 072c178cb8 optimize 2023/03/2 2023-12-03 15:18:21 +01:00
kageru 77ff6daad8 add 2023/03/2 2023-12-03 10:25:35 +01:00
kageru be085ab131 add 2023/03/1 2023-12-03 09:31:34 +01:00
kageru db91d6dcc3
add 2023/02 2023-12-02 10:14:10 +01:00
kageru 55636a082e 2023/01 less duplicate code 2023-12-01 14:01:38 +01:00
kageru eefb16d5be
add 2023/01 2023-12-01 07:05:01 +01:00
kageru 7f8d03a5a0
add 2023 setup and grid code 2023-11-30 23:58:02 +01:00
kageru 568a43b115 import 2017 solutions I found in my github gists 2023-10-16 12:10:46 +02:00
kageru fc0f216511
Make 2022/22/1 work 2022-12-22 21:03:12 +01:00
kageru 538309d690
don’t reverse grid when printing 2022-12-22 20:38:34 +01:00
kageru 1b75458f75
2022/22/1, except it doesn’t work 2022-12-22 20:22:42 +01:00
kageru 5a8c34ccf8 input parsing 2022/22 2022-12-22 15:10:00 +01:00
kageru 1f10471413 bit of cleanup 2022-12-21 13:39:42 +01:00
kageru 791afead09 Add 2022/21/1 2022-12-21 13:32:51 +01:00
kageru c67282906c
day 20 cleanup 2022-12-20 22:52:25 +01:00
kageru 0091045fb2
add 2022/20/2 2022-12-20 22:39:21 +01:00
kageru 38b9ad928e
Add 2022/20/1 2022-12-20 22:14:25 +01:00
kageru 15b46e1975
make more stupid assumptions 2022-12-20 01:15:02 +01:00
kageru ea4c15668f Add 2022/19 2022-12-19 12:29:55 +01:00
kageru d303f55a4e
clippy 2022-12-15 20:50:38 +01:00
kageru 606f433196
fix tests on day 7 2022-12-15 20:48:04 +01:00
kageru 5c09e523e6 optimize parsing 2022-12-15 14:10:50 +01:00
kageru f2a9208212 optimize part 1 2022-12-15 14:02:46 +01:00
kageru d2e5c13586 clean up day 15 2022-12-15 13:39:21 +01:00
kageru 460d7c10a7 finish 2022/15 2022-12-15 13:08:15 +01:00
kageru 202b15dcb9 2022/15 wip 2022-12-15 12:19:28 +01:00
kageru 3926f7fcd7 allow passing an argument to part/bench functions 2022-12-15 10:53:56 +01:00
kageru a4ad70ddd3
optimize parsing 2022-12-14 23:46:52 +01:00
kageru 2dd0df251f
shorten p2 2022-12-14 23:40:29 +01:00
kageru 6a40d11153
shorten p1 2022-12-14 23:33:30 +01:00
kageru 60a1379090
get rid of custom type 2022-12-14 23:24:16 +01:00
kageru b4735efed2
Add 2022/14 2022-12-14 22:42:56 +01:00
kageru 515b47714d optimize p2 2022-12-12 17:19:53 +01:00
kageru 2de9cca374 stupid copy paste for p2 2022-12-12 17:06:46 +01:00
kageru 48c5e58750 implement the slowest day 12/1 2022-12-12 15:56:43 +01:00
kageru 00f656fa07 parse 2022/12 2022-12-12 12:08:49 +01:00
kageru 77f1559f9f changes to grid module 2022-12-12 11:56:38 +01:00
kageru 93e753d902 add grid from previous years 2022-12-12 11:40:49 +01:00
kageru 8c7b1dfb78 Add 2022/10 2022-12-12 11:09:57 +01:00
kageru 09f5b95c78
remove unneeded parsing 2022-12-11 22:51:58 +01:00
kageru bd3d070049
remove lcm 2022-12-11 21:40:07 +01:00
kageru 1cfc30921f
Add 2022/11 2022-12-11 21:32:32 +01:00
kageru 3055794744 make tuples immutable 2022-12-09 13:05:41 +01:00
kageru 98ebcaecb4 escape newlines in test inputs 2022-12-09 12:50:12 +01:00
kageru dd34e0a854 optimize day 9 2022-12-09 12:36:25 +01:00
kageru 5180a1e9e1 Add 2022/09/2 2022-12-09 12:12:03 +01:00
kageru f7c0779706 Add 2022/09/1 2022-12-09 11:41:51 +01:00
kageru 7a085154e7
rayon go brrrr 2022-12-08 17:43:05 +01:00
kageru 9a26ae4a4d optimize transpose 2022-12-08 14:53:11 +01:00
kageru 9e3e03bcd3 less code duplication 2022-12-08 13:34:57 +01:00
kageru f71090babf Add 2022/08/2 2022-12-08 12:16:39 +01:00
kageru 156512658f Add 2022/08/1 2022-12-08 11:36:21 +01:00
kageru 2d601b9bfb more parsing optimizations 2022-12-07 15:59:15 +01:00
kageru 8050b16034 remove unneeded box 2022-12-07 14:03:06 +01:00
kageru d2c569209e clean up 2022/07 2022-12-07 11:51:08 +01:00
kageru 5c8e79c543 Add 2022/07/02 2022-12-07 11:20:02 +01:00
kageru a52030278e Add 2022/07/01 2022-12-07 11:07:13 +01:00
kageru b519084a16 optimize 2022/06 2022-12-06 13:50:19 +01:00
kageru c51d56617c Add 2022/06 2022-12-06 10:34:25 +01:00
kageru 647e1c815e Remove temporary storage for 2022/05 2022-12-05 12:04:32 +01:00
kageru ef93b302ce Optimize parsing 2022/05 2022-12-05 11:47:37 +01:00
kageru 5a86a400ef Add 2022/05 2022-12-05 11:15:40 +01:00
kageru 4e7420463d add 2022/04 2022-12-05 10:26:36 +01:00
kageru 56fa30a5a4 skeleton for 4 + 5 2022-12-05 10:02:52 +01:00
kageru 67f7c4c47f Add 2022/03 2022-12-03 13:13:30 +01:00
kageru 6ced50128c optimize more 2022-12-02 15:07:19 +01:00
kageru d865c06f8b be less stupid 2022-12-02 14:05:04 +01:00
kageru 515bc5f96f naive solution for 2022/02 2022-12-02 11:18:36 +01:00
kageru 8e47158ba1
document the dc solution 2022-12-01 18:19:42 +01:00
kageru ddc84b662a Do 2022/1/1 in dc 2022-12-01 16:46:40 +01:00
kageru 43b47bc622 directly parse into BinaryHeap 2022-12-01 14:25:17 +01:00
kageru 2109680030 use binary heap for 2022/1/2 2022-12-01 12:07:38 +01:00
kageru 7a86dc1a88 add faster number parsing for benchmarks 2022-12-01 10:21:16 +01:00
kageru e33d2aa86f
Add 2022/01 2022-12-01 06:12:16 +01:00
kageru e11d9e24cd
Remove test files for the 2022 setup 2022-12-01 00:06:19 +01:00
kageru 22afa80e1b rename parse param to bench_parse 2022-11-29 12:56:07 +01:00
kageru a6dfde6fc5 extract day and typealias from macro 2022-11-29 12:45:03 +01:00
kageru 927d1ccce3 Add boilerplate macro for 2022 2022-11-29 12:29:49 +01:00
kageru cc29762a6a futile attempts at 22 2021-12-22 16:16:54 +01:00
kageru b733d05353
21/2 optimizations 2021-12-22 00:41:17 +01:00
kageru b262f734b5
Day 21 refactoring 2021-12-22 00:29:21 +01:00
kageru c47f381a3b
clippy 2021-12-21 23:39:43 +01:00
kageru 4dee357ea1
Add 21/2 2021-12-21 23:33:19 +01:00
kageru c19088f3cb
Optimize 21/1 2021-12-21 21:57:53 +01:00
kageru 7cdb90bf8e Clean up 21/1 a little 2021-12-21 16:05:15 +01:00
kageru 8f83f5489a Add day 21 part 1 2021-12-21 15:45:38 +01:00
kageru aa2e083c2d Skeleton for day 21 2021-12-21 09:38:17 +01:00
kageru 64e851cd77
Add test for day 20 2021-12-21 00:20:34 +01:00
kageru 43d232d924
Day 19 parsing 2021-12-20 19:24:36 +01:00
kageru 165da4c28c Add day 20 2021-12-20 16:05:38 +01:00
kageru 549ee502b1 wip day 20
test passes, but real input is wrong
2021-12-20 15:31:46 +01:00
kageru a2c61d1bf4
Use box patterns 2021-12-18 23:15:37 +01:00
kageru 29e0ca1ac9
optimize day 18 2021-12-18 22:50:28 +01:00
kageru 74372c1e33
day 18: disable box syntax 2021-12-18 18:28:08 +01:00
kageru e0461fb56a
Remove unused #[feature] 2021-12-18 17:58:57 +01:00
kageru 1159d3b6e4
Make reduce return new Node
This is a little slower, but I much prefer how it looks
2021-12-18 17:49:55 +01:00
kageru 8333c88189
Add day 18 part 2 2021-12-18 17:46:46 +01:00
kageru 7cbbd03e0f
finish day 18 part 1 2021-12-18 17:37:31 +01:00
kageru 68cade10ac
Day 18: add split and tests 2021-12-18 17:06:34 +01:00
kageru 35e85c9737
Add day 18 parsing + exploding 2021-12-18 16:18:25 +01:00
kageru 79ab35a23e
Use Vec::retain for day 3
The performance issues I reported have since been fixed. Rejoice.
2021-12-17 22:08:31 +01:00
kageru 95e4a6f8cc
Day 17: no longer hardcode upper search bounds 2021-12-17 21:52:42 +01:00
kageru 66bc3c6d42
More day 17 optimizations 2021-12-17 17:32:35 +01:00
kageru 36ffc1cf00 Remove useless destructuring 2021-12-17 14:06:31 +01:00
kageru 10454bd621 Day 17 early exit earlier 2021-12-17 13:26:10 +01:00
kageru 4796950fdf better bounds 2021-12-17 12:55:18 +01:00
kageru 14d3e22da6 Day 17 more FP 2021-12-17 12:55:18 +01:00
kageru 5d2035e161 Add day 17
brute force is best force
2021-12-17 12:55:18 +01:00
kageru b13bb26752
Remove unneeded bitshift 2021-12-16 23:12:44 +01:00
kageru 07539273dc Add day 15 part 1 2021-12-15 18:07:19 +01:00
kageru b38c53b886 Add day 14 2021-12-14 12:10:45 +01:00
kageru 74925b973d Slightly optimize string generation 2021-12-13 11:43:08 +01:00
kageru 310730482a Properly rotate day 13 part 2 2021-12-13 11:25:31 +01:00
kageru 4904505f69 Add day 13 2021-12-13 11:12:02 +01:00
kageru 4da3dc4a8b
Day 12: clone a little less 2021-12-12 13:19:21 +01:00
kageru 1e03a430b9
Add day 12 part 2 2021-12-12 13:05:38 +01:00
kageru 06c8b775fa
Add day 12 part 1 2021-12-12 12:41:37 +01:00
kageru 8ccab04d6f
Extract some grid functionality into trait 2021-12-11 22:54:57 +01:00
kageru e668c96185
Day 11 cleanup 2021-12-11 13:36:15 +01:00
kageru c6b1ec262f
Add day 11
and the entire grid library from last year
2021-12-11 13:11:34 +01:00
kageru a06c73a488
Add grid module from 2020 2021-12-11 12:03:13 +01:00
kageru aa33a74bc7
Simplify match 2021-12-10 22:51:24 +01:00
kageru 6d9fbe0edf Refactor day 10 2021-12-10 15:09:09 +01:00
kageru 2103005872 Add day 10
Ugly for now
2021-12-10 14:10:23 +01:00
kageru ed3b0b579c
Try 9/2 2021-12-09 21:14:08 +01:00
kageru 96877c6359 Day 9 simplify neighbors 2021-12-09 11:10:21 +01:00
kageru 2a1c7ee382 Add day 9 part 1 2021-12-09 10:46:49 +01:00
kageru 48a392325f
Day 8: more optimizations
This is getting ridiculous, but I couldn’t sleep
2021-12-09 00:47:30 +01:00
kageru 30c8e0e1ff
Add unchecked string parsing
Saves ~5-10% in parsing benchmarks
2021-12-09 00:26:00 +01:00
kageru 9db1906760
Day 8: No longer brute force anything 2021-12-08 20:49:05 +01:00
kageru 188dd576a9
Bitmagic 2021-12-08 20:10:16 +01:00
kageru a1f6eb888c Day 8 Refactoring III
Completely remove SevenSegmentDisplay type
2021-12-08 16:54:07 +01:00
kageru 83419cbdf3 Day 8 Refactoring II
Unbloating the parsed type
2021-12-08 14:07:44 +01:00
kageru 0b77540d9d Day 8 Refactoring I
Parsing and variable names
2021-12-08 14:07:14 +01:00
kageru 2ba51b2208 Add day 8 2021-12-08 13:42:35 +01:00
kageru cfb1e87465
Make 7/1 faster 2021-12-07 19:43:24 +01:00
kageru 744aa2fc72 Simplify day 7 2021-12-07 14:06:09 +01:00
kageru 413339cdb8 Add day 7 2021-12-07 11:57:45 +01:00
kageru 728b95b9e1 Death to imperative programming! 2021-12-06 14:10:46 +01:00
kageru fcab7acc74 Slightly optimize input parsing 2021-12-06 13:46:34 +01:00
kageru c073e2f906 Make day 6 better 2021-12-06 13:05:57 +01:00
kageru fc60409b42 Add day 6 part 2 2021-12-06 12:26:12 +01:00
kageru 0256625608 Add day 6 part 1 2021-12-06 11:01:23 +01:00
kageru 78de4f1d46
Add macro for static day 5 parsing 2021-12-05 23:38:23 +01:00
kageru d0a72cb04e
Remove fnv dependency 2021-12-05 22:56:22 +01:00
kageru 6ae2840f80
Replace HashMap with Vec
again much faster
2021-12-05 22:10:29 +01:00
kageru fcfb68ea33
Preallocate day 5 hashmaps 2021-12-05 22:00:14 +01:00
kageru 45600f5dd1
Optimize day 5 2021-12-05 21:27:52 +01:00
kageru bcddb22135
Add day 5 2021-12-05 20:48:20 +01:00
kageru df68a385d8
Const-ify winning indices 2021-12-04 16:00:05 +01:00
kageru ea1339f018
Replace HashSet with Vec for more brrrrr 2021-12-04 13:38:17 +01:00
kageru f7efb54d21
Remove useless type alias 2021-12-04 13:31:26 +01:00
kageru 5b71f0740c
Enable benchmarks 2021-12-04 13:09:10 +01:00
kageru 6b868de832
Add day 4 2021-12-04 12:49:48 +01:00
kageru 964a84df45
Enable lto in benchmarks 2021-12-03 20:28:39 +01:00
kageru 70450dbcdc
Vec::retain does not go brrrr 2021-12-03 18:02:18 +01:00
kageru 9a03a4f499 Generalize input bench macro 2021-12-03 17:05:53 +01:00
kageru 5d90f44f2b Don’t use log2 to get around bit count 2021-12-03 15:24:26 +01:00
kageru 312f526345 Make day 3 not awful 2021-12-03 12:00:58 +01:00
kageru 8a60ce83f9
Add missing semicolon in day template 2021-12-03 07:02:58 +01:00
kageru 61ec05955a
Add day 3 (bad) 2021-12-03 07:01:36 +01:00
kageru e9a3ead7c2 Add DAY constant to each file for input reading 2021-12-02 10:31:23 +01:00
kageru 329be3f1c1
Add day 2 2021-12-02 06:13:01 +01:00
kageru b734f0c5af
Get alternative input file via env variable instead 2021-12-01 23:12:39 +01:00
kageru 731d7f5e33 Move imports into macros 2021-12-01 14:16:29 +01:00
kageru 250bad526c Revert "Remove env stuff from input reading"
I remember now. This was so I can `cargo run bigboy_input` without code changes
2021-12-01 14:12:36 +01:00
kageru 63c695608e Remove env stuff from input reading
No idea what last year me was thinking
2021-12-01 13:30:10 +01:00
kageru 85370a3b3b Use aocd to get daily input
see https://pypi.org/project/advent-of-code-data/
2021-12-01 09:54:28 +01:00
kageru a044e4cf1b
Refactor day 1
tuple_windows is terribly slow, wtf
2021-12-01 06:26:45 +01:00
kageru 94bf221efd
Add day 1
Part 2 is ugly. Better solution later when it’s not 6AM anymore
2021-12-01 06:19:33 +01:00
kageru 1c3ae8ec96 Minor rustfmt changes 2021-11-22 16:34:19 +01:00
kageru 111a56880f Make 2020 compile again 2021-11-22 14:34:40 +01:00
kageru a65c137864 Set up everything for 2021 2021-11-22 14:30:40 +01:00
kageru adb0e84858
caching meme for D17 to save time 2021-07-09 00:21:34 +02:00
kageru a570cf6fda
Remove hardcoded neighbors implementation
Not that this one is much better, but after hours of trying,
it’s all I got to compile. :(
2021-07-08 22:23:48 +02:00
kageru 4b4f4fbf80
Add tests and clean up add/sub/mul for positions 2021-07-08 19:58:30 +02:00
kageru 123d9bd1fb
Get rid of Position2D, 3D, 4D 2021-07-08 19:35:31 +02:00
kageru c726998c0c
Migrate day 12 to PositionND 2021-07-08 19:27:56 +02:00
kageru 98b8a9c81c
Migrate day 11 to PositionND 2021-07-08 19:21:07 +02:00
kageru eee3183dc0
Merge branch 'd17-constgenerics' 2021-07-08 19:09:45 +02:00
kageru e838f132c2
Make day 17 work with const generics 2021-07-08 19:05:31 +02:00
kageru 3d80b9f073
clippy lints and stabilizations
A few things have changed in the past few months
2021-04-29 19:14:28 +02:00
kageru 506eff857e
Generify day 19 over all pattern vectors 2020-12-19 14:00:03 +01:00
kageru ca14b85812
2020/19/2 2020-12-19 13:02:01 +01:00
kageru cd6b531a5e
slightly reduce recursion depth 2020-12-19 12:50:48 +01:00
kageru a1bf3c288b
2020/19/1 2020-12-19 12:32:28 +01:00
kageru 022b2a447b
Optimize 2020/18 2020-12-18 19:04:50 +01:00
kageru 5c87450e11 2020/18/2 2020-12-18 11:44:45 +01:00
kageru d313bd6e25 2020/18/1 2020-12-18 11:19:00 +01:00
168 changed files with 43641 additions and 311 deletions

4
2017/README.md Normal file
View File

@ -0,0 +1,4 @@
# 2017
While going through my Github gists, I found a few AoC days from 2017, so I decided to include them here for later reference.
Apparently, I got a total of 15 stars that year, but I have no idea where my code for most of the solutions is.

69
2017/day08.nim Normal file
View File

@ -0,0 +1,69 @@
import tables
import nre
import strutils
let pattern = re"(?<target>\w+)\s(?<opcode>(inc|dec))\s(?<value>-?\d+)\sif\s(?<comptarget>\w+)\s(?<compop>(<|>|==|!=|<=|>=))\s(?<comp2>-?\d+)"
var registers = initTable[string, int]();
proc parseLine(li: string): RegexMatch =
let found = nre.find(li, pattern)
if found.isNone:
echo("mismatch")
return
return found.get()
proc compare(target: string, val2: int, op: string): bool =
# text parsing done right ヽ( ゚ヮ・)ノ
let val1 = registers[target]
case op
of "<":
return val1 < val2;
of ">":
return val1 > val2;
of "==":
return val1 == val2;
of "!=":
return val1 != val2;
of "<=":
return val1 <= val2;
of ">=":
return val1 >= val2;
else: discard
proc changeRegister(r: string, op: string, val: int): void =
# only ‘inc’ and ‘dec’ are possible
if op == "inc":
registers[r] += val
else:
registers[r] -= val
proc executeLine(ins: Table): void =
# set registers to 0 if they haven’t been initialized
if not registers.hasKey(ins["comptarget"]):
registers[ins["comptarget"]] = 0
if not registers.hasKey(ins["target"]):
registers[ins["target"]] = 0
# do math... or don’t
if compare(ins["comptarget"], parseInt(ins["comp2"]), ins["compop"]):
changeRegister(ins["target"], ins["opcode"], parseInt(ins["value"]))
for line in lines "day8.txt":
let parsed = parseLine(line)
executeLine(parsed.captures.toTable())
# returning a list like with python’s dict.values doesn’t seem to work.
# is there a way to convert iterables to arrays?
var maximum = 0
for v in values(registers):
if v > maximum:
maximum = v
echo(maximum)

83
2017/day19.nim Normal file
View File

@ -0,0 +1,83 @@
import sequtils
import future
import nre except toSeq
type
Direction = enum
up = 0, left = 1, down = 2, right = 3
Grid = seq[seq[char]]
const directions = [up, left, down, right]
proc indexOf(hay: seq[char], needle: char): int =
# It almost seems weird that this doesn’t already exist...
# It probably does, and I just missed it. Whatever, no error handling because :lul:
var i = 0
while hay[i] != needle:
i += 1
return i
proc gridGet(g: Grid, p: array[2, int]): char =
return g[p[0]][p[1]]
proc changePosition(current: array[2, int], dir: Direction): array[2, int] =
if dir == up:
return [current[0]-1, current[1]]
if dir == left:
return [current[0], current[1]-1]
if dir == down:
return [current[0]+1, current[1]]
if dir == right:
return [current[0], current[1]+1]
proc oppositeDirection(d: Direction): Direction =
# the better solution would be something like
# mod(getEnumOrdinal(direction, $direction) + 2, 4)
# but that doesn’t quite work because I’m bad at this whole thing
case d
of up: return down
of left: return right
of down: return up
of right: return left
else: discard
proc changeDirection(g: Grid, pos: array[2, int], direction: Direction): Direction =
for d in directions:
if d != oppositeDirection(direction) and gridGet(g, changePosition(pos, d)) != ' ':
return d
let grid = lc[toSeq(line.items()) | (line <- lines("input.txt")), seq[char]]
var position = [0, indexOf(grid[0], '|')]
var direction = down
var done = false
var visited = ""
var newchar: char
var steps = 1
while not done:
#echo position[0], ", ", position[1]
#echo direction
var newpos = changePosition(position, direction)
newchar = gridGet(grid, newpos)
#echo(newchar)
if newchar in ['|', '-']:
inc steps
elif newchar == '+':
inc steps
direction = changeDirection(grid, newpos, direction)
elif nre.contains($newchar, re"[A-Z]"):
inc steps
visited &= newchar
elif newchar == ' ':
done = true
position = newpos
echo(visited)
echo(steps)

108
2017/day20.nim Normal file
View File

@ -0,0 +1,108 @@
import strutils
import future
import nre
# 3-dimensional vector type with attributes for x, y, and z
# Mainly used for readability
type Vector = object
x, y, z: int
# Are there proper constructors in nim?
# I guess this is... something.
proc newVector(x: int, y: int, z: int): Vector =
var v: Vector
v.x = x
v.y = y
v.z = z
return v
# Manhattan Distance. Should be self-explanatory
method manhattan(this: Vector): int {.base.} =
return abs(this.x) + abs(this.y) + abs(this.z)
proc countZeros(v: Vector): int =
var z = 0
for c in [v.x, v.y, v.z]:
if c == 0:
inc z
return z
proc `$`(v: Vector): string =
return $v.x & ", " & $v.y & ", " & $v.z
proc `<`(a: Vector, b:Vector): bool =
if manhattan(a) == manhattan(b):
return countZeros(a) < countZeros(b)
return manhattan(a) < manhattan(b)
proc `>`(a: Vector, b:Vector): bool =
if a == b:
return countZeros(a) > countZeros(b)
return manhattan(a) > manhattan(b)
proc `==`(a: Vector, b:Vector): bool =
return a.x == b.x and a.y == b.y and a.z == b.z
proc `!=`(a: Vector, b:Vector): bool =
return not (a == b)
type Particle = object
number: int
velocity: Vector
acceleration: Vector
position: Vector
proc newParticle(n: int, vel: Vector, acc: Vector, pos: Vector): Particle =
var p: Particle
p.number = n
p.velocity = vel
p.acceleration = acc
p.position = pos
return p
proc `>`(a: Particle, b: Particle): bool =
if a.acceleration == b.acceleration:
if a.velocity == b.velocity:
return a.position > b.position
return a.velocity > b.velocity
return a.acceleration > b.acceleration
proc `<`(a: Particle, b: Particle): bool =
if a.acceleration == b.acceleration:
if a.velocity == b.velocity:
return a.position < b.position
return a.velocity < b.velocity
return a.acceleration < b.acceleration
proc min(arr: seq[Particle]): Particle =
var m = arr[0]
for p in arr:
if p < m:
m = p
return m
let input = lc[line | (line <- lines("input.txt")), string]
var particles: seq[Particle] = @[]
# p=<-1027,-979,-188>, v=<7,60,66>, a=<9,1,-7>
for i in 0..(len(input)-1):
let line = input[i]
let parsed = nre.match(line, re"p=.(?<px>-?\d+),(?<py>-?\d+),(?<pz>-?\d+).,\sv=.(?<vx>-?\d+),(?<vy>-?\d+),(?<vz>-?\d+).,\sa=.(?<ax>-?\d+),(?<ay>-?\d+),(?<az>-?\d+)")
if parsed.isNone():
echo("Could not parse ", line)
continue
let matched = parsed.get().captures
# echo(i, ": ", line)
particles.add(
newParticle(i,
newVector(parseInt(matched["vx"]), parseInt(matched["vy"]), parseInt(matched["vz"])),
newVector(parseInt(matched["ax"]), parseInt(matched["ay"]), parseInt(matched["az"])),
newVector(parseInt(matched["px"]), parseInt(matched["py"]), parseInt(matched["pz"]))
)
)
echo(min(particles).number)

375
2020/inputs/day18 Normal file
View File

@ -0,0 +1,375 @@
9 * 7 + ((6 + 9 * 2 + 6 + 7 + 5) * (5 + 9 + 7) * 6) * (4 + 8) + 5 * 8
3 * (4 * 9 + 8 + 4 * 4 + 7) + 7 * (8 * 9)
4 * ((6 * 5 * 9) + 2) + 9 * 4
((4 * 6 * 2 * 9) + 7 * 4) + 4 * 6 + 5 * 6 + 6
9 * 8 * ((5 + 7 * 8 * 2) * 6) + 3
6 + (3 * 7) * 3 + (9 * (6 * 6 + 5 + 9 + 9) * 7 * 9 + (4 * 8) + 8)
6 * 4 + 2 + 8 + 7
(5 * (9 * 8) * 6) + 2 + 8 * 5 * 4 * 3
(3 + 2 * 2 * 8 * 5) + (7 + 6 * 4 * 8) * (6 * 9 * 5 * 9)
(4 * 2 + (9 + 2 * 4) * 5 + 9) + (9 * 3)
7 * 6 + 6
4 + (8 + (5 * 9) + 9 * 8)
9 + 8 + 5 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0,0 +1,626 @@
25: 53 116
122: 116 92 | 53 53
100: 53 73 | 116 125
111: 67 116 | 91 53
71: 116 58 | 53 78
55: 116 54 | 53 21
123: 53 97 | 116 108
104: 56 116 | 125 53
19: 125 53
56: 116 116 | 116 53
60: 116 121 | 53 59
75: 53 20 | 116 124
6: 53 131 | 116 33
62: 53 53 | 116 116
101: 116 127 | 53 26
128: 116 125 | 53 93
34: 53 28 | 116 125
65: 63 116 | 135 53
50: 32 53 | 76 116
2: 53 10 | 116 132
133: 28 53 | 131 116
85: 53 131
125: 116 53
118: 87 116 | 3 53
135: 73 53 | 125 116
28: 53 53
110: 116 122 | 53 56
91: 5 53 | 74 116
73: 92 116 | 53 53
80: 15 116 | 109 53
124: 128 116 | 17 53
87: 92 53 | 53 116
43: 116 27 | 53 37
66: 46 53 | 93 116
106: 116 77 | 53 83
137: 72 116 | 104 53
93: 116 116 | 53 116
129: 92 103
12: 116 56 | 53 131
45: 53 132 | 116 12
102: 65 116 | 2 53
24: 116 101 | 53 95
14: 116 84 | 53 29
57: 93 116 | 56 53
70: 108 116 | 100 53
51: 116 1 | 53 68
26: 73 53
15: 116 93 | 53 125
42: 53 134 | 116 106
79: 116 33 | 53 122
5: 116 125 | 53 3
74: 53 122 | 116 73
18: 93 53 | 87 116
20: 47 53 | 17 116
114: 116 85 | 53 118
37: 53 73 | 116 87
47: 116 73 | 53 125
107: 116 3 | 53 46
69: 53 25 | 116 125
32: 53 28 | 116 93
76: 3 53 | 125 116
38: 92 33
119: 116 39 | 53 80
8: 42
21: 125 53 | 125 116
58: 75 116 | 119 53
64: 116 44 | 53 113
68: 90 53 | 45 116
1: 23 116 | 60 53
53: "a"
81: 73 53 | 33 116
86: 116 129 | 53 35
90: 110 116 | 13 53
82: 53 93 | 116 25
95: 99 116 | 66 53
27: 116 56 | 53 3
120: 116 51 | 53 40
126: 116 96 | 53 52
116: "b"
84: 116 123 | 53 49
134: 116 61 | 53 14
78: 116 102 | 53 86
96: 130 53 | 98 116
10: 87 116 | 33 53
88: 53 116 | 116 92
40: 126 53 | 24 116
127: 56 116
59: 87 53 | 3 116
11: 42 31
41: 116 137 | 53 16
44: 116 22 | 53 79
109: 88 53 | 87 116
49: 136 116 | 94 53
113: 107 116 | 81 53
77: 116 64 | 53 36
3: 53 116 | 53 53
9: 133 53 | 112 116
98: 92 93
117: 3 92
39: 53 19 | 116 21
16: 6 116 | 117 53
132: 131 116 | 125 53
63: 116 122 | 53 33
22: 131 116 | 56 53
89: 116 125 | 53 131
115: 55 53 | 50 116
99: 116 33 | 53 93
92: 116 | 53
121: 53 73 | 116 56
13: 73 92
103: 53 3 | 116 62
83: 111 116 | 41 53
61: 105 116 | 115 53
130: 56 92
136: 33 116 | 125 53
30: 53 76 | 116 7
94: 92 87
52: 97 116 | 18 53
7: 116 28 | 53 46
97: 25 53 | 33 116
35: 89 116 | 82 53
72: 53 131 | 116 87
48: 34 116 | 38 53
54: 116 46 | 53 131
131: 116 116
23: 116 4 | 53 57
31: 116 71 | 53 120
29: 116 30 | 53 114
108: 116 25 | 53 46
33: 92 92
4: 131 116 | 3 53
36: 70 116 | 9 53
67: 69 116 | 117 53
0: 8 11
105: 48 116 | 43 53
46: 116 53 | 53 116
17: 93 116 | 122 53
112: 122 53 | 3 116
babbbbabaabaaabbbbbaaabbbbababba
ababaaaaabbbabbbbbabbbba
aabbaabaabbababaababbaba
bbbbabaaabaaabbbbbbbbaab
babbbabababaabbaaaabbbba
bbaabbababbaaabaaaababbbabaaaaaaaaaaababbaabbbbaaaaaaabaabababbbbabbbaababbbaabbbbababab
babbabbabbaababbbbbbbaab
baababababbaababaaabaaab
aababaababbaaaabbbababbbbbbbbbaabbbbabbbbbabbababbababaabaabaaaabbabaaaaabbaaaaa
baabbbbaaabbabbbababbbba
baabbabaaaaababbaababbbbaababaaabbbbbaaabababaab
babbabbabaabbabbaabbabaa
baaabbbbabbaaabbaaaaaabbbbabaaba
abababbaaabaabbbabbbaaaa
ababababbbbaaaababaabaaa
baaababbbbbabababbbaaabaaaabaababaaabbbbaaabbbbaabbaabbbabbbaaab
babaaabaabbabaababbabaaaabbbaaaa
ababaaabaabaabaabbbbababbbaabababaababaaabaabbbb
abbaaaabaabababaabaabbaa
baaaaaabaaaaababbababaaa
aabaaabbababaabbbaaabbbbaabbbaaa
baaabbbaaaaaaaaaaabbbbba
abbbbbabbbbabaabaabbbbabbbaabaabaabbbbbb
baabbbababababbabbaaaaaaabbbaabbbababbbaababaaaaaabbbbaa
bbbbbbbbabababaabaaabbbabbaaabbbaaaaaabaabbaabbabbabbbba
abaabbabaabaaaaabaabaaaa
aabababbababaaaaabbbbbaa
bbbabbaaabaaaababababbbabbbaabab
aabababbaabbbababaabaaab
aabaaababaabbabaaabaaaab
abbbabaabbaabbabaaabbbba
baaabbbbaababbabbbbabbaabaabbbbbabbbbabbbabbaaba
bbaaababaabaaabbabbbbbabbabaaabbbbaabbbbaabbbaaabbabbabb
baabaabaaababbbbbbaabbaa
bbaaabbbbababbabaaaababa
bbabbbbabaaaaabbbaaaaababbbbbaaabaababbbbabbabaabaabbabaabbababbaaaaaaabbbabaaabbbbbbabb
abaabbbababaaaabaabbbbbbbbabbbab
ababaaaaabababbabbbaababbaaabbaaabbaaaba
bbabbaabababbabbbaaaaaabaaabaabb
baabaaaaababbbbabbabbabbbababbaa
aaaaaaaabaaabaabababaaba
baabbababaaabaaaaabaabaaaababbbbaaabbbbb
abaaaabaabbababaababbbab
bbaaabababbababbababbbbb
baababbaaaabababbaaaaaabbaaaabbb
bbbbbbbaabababbabbabbbba
bbaaaaaaaabaabbbabaabbaa
abbabababbaaaaababbbabbbbbaaaaaaababaaaababaaaba
abaababbaabaaaaaaabaaaab
abababaabbaaabbaabababbaaabbabaa
babbabbbbbbbbbbabbaabbaa
bbabbbaaaabaaababbaaababbaaabaabaabbbaababbaabaaaabbbaaaabbaabbbaabbbbba
abbbaabbababaaabbababbbaabbbbababababaaa
bbaaabbabbbaabaaabbbabaaaaababbbbaababbb
baabaaaabbaaabbaaabbaababbbbbbababbbabbbbbbabbba
abaabbbaabaababaaaabbabb
bbbbabaaaabaabbbbbbbbaab
bbaaaaabababbabbaababbab
babbaabaabbbbaaaaabbbbbb
baaabaabbbbbaaaaabbbaaab
aaabbaabbabbabbbbabbbbba
aabbababaabababaaabbabbbbbbbbbbaaaabbaaaababbabbabaaabaabbababaabbbbbabbbabbbbabaabaabaabaababba
ababaabbaabbbabababbabab
bbbabbbabaaabbbaaaabbbab
aabababbaabaabaaabaaabbbaabbbaaa
aaaaaabaabbabbaabbbbaaaaaabbaabbaaabaaaaabbbbaabaaaabbbaababbbbbababbaaa
ababaabbabababbabababbbaaabababaaabbbbaaaabbbabb
babbabbaabbabbbaababaaba
abbbbaaabbbbbbbabbababbbbaabbaab
babbaabaabbbbabbaaaaaaabaabbabba
bbaaababbaabbabbbbbbabbbbabbabaabbabaaaa
aaabaabaaabbababbababaab
bbaaabbbababaabbaabaaababaabbbbbbbabbaaa
abbabbbabaaabbbbbabbbabaaabbaabababbbbbaabbbaabababaabba
aaaaaaaaabbabbaabbabbbaaaabababbbaaabaababaabbaabbababab
aabbbabababbabaaaaabababbabbbbba
abbababbbbbbabbaaabbbbbb
bbbbbbbaabaaaaababbaabbb
aabababbabaaabbaababbaaabbbbababbbabbabbbaaababbabbbbbabaaabaabaabbabaabaaabbaaa
abbbbbabbbbbabaaabaabaab
abbabbbabbbbabababbbbbba
abababbabaaaaaabbbabaaaa
aaaaababbbbbaabbaaabaabaabaaabababbabbabbbbaabbb
baabbbbabbbaaaaababaaabb
bbaaaababbaaaabaababaaaaaabbbaabbbbabaaa
babbbbbbbabbbaaabababaabbabbbaabbbaaabaa
aabaaabbaabbaabbbababaab
baaaabbbbbabbbababbaababbabaaabaabababbaabaabbabbaaaaabaabbaaabb
abababbabaabbbbaaaaababa
aabbbbabbbbbaabaaaabbaabbbabaabababbbbaabbaabbabbaabbaaa
aaabaabaaabbababbabbbababaabbabb
bbbaaababbbbbbbbbbbababbabbbaaab
bababbaaaaaabbbbbabaaaab
bbaaaabaaaaaaabababbbabaaaaabaaa
aabbabbbbbaaababbbababaa
abbaaaababbbbbabaaaaabbb
bbaaaaaabbbaabababaabaab
ababaabbabaababbbbabbaabbbbbbbbbaaabbababbabbabbabbaabaa
bbaabbbaabababbaaaababbb
bbbbabbaaabaabaababaaaaa
bbaabbababbbbaabbababbbabbbbababbbbaaabbbaaaababaababbbababbaabb
bbaaaababababbabbabbbbaaabbbaaab
babaababaaabbaabbbababaa
ababababababbaabbabababa
abbabbbbaaaaaabbabbbabaababaabbaabbbababbbbaabaaaaaaaaabbbaabbba
bbbaaabaaaaaaaaaababbabbbbaabaab
abbbaabbabbbbaaaaaaabaab
abbbbbbbaaabbbbaaaababbaaaaabbabbababaabbbaabbabaabababa
aababbaaabaababbababaabb
babbaaabaabbabbbbbabbaaaaaaabaab
aabababaabbbbabbaaaaabaaaabaabababbaaaba
baabbabbbbaaabababaabbbb
abbaaabbbbbabaabbbbbaabbabbbbaabbaabaaabaabaaaab
bbaabbbabbbbbabbbababbbb
babaababbbbababaabaaaabbbabbabaabaabababaabababb
bbababbabbaabbbbbbbbabbbabbaabaaabbbaaaabbaabaababaaaaaa
babbbbabbbbbbbaaababbbba
abbbbababbbaaaaaaaabbbab
baaaaaabaabbbaabbabbbabbabbaaabaababbaaaabbaaababbaaaaaabaaaaaabbaababababaaabbbabaabaaa
aabaabbbabbbbaaaaababbaaababaabbabbbabbababaabba
aabababbbbbbabbaabbbbbbb
baabababbbaaaaababbbbaabbabbabbbaaababbaaaabaaab
baaabbbababbaabaabbabaaa
abaababbabbbbaabaababbbbbbbaaaab
aababaababbbabbbababbaaa
baaabbbbbbbbabbabbbbbaab
bbabbaabaaabbbaaaabbbaaa
bbabaabaababbaababbbabbbabaabbabbaabbaab
bbbbbbbaaabbaabaababaaba
aababababaaabbbaababbbaa
babbbbbabbbababbaaababaaaababbaaaaabbbabaaababaaabbbbbbbbbbaaaabbaaabbaabaaaababbbaaaaab
aababbaaabaaaababbbbabaaabbbbabaabbbbabbbabbbabb
bbbaabaaaabbbbabaababbaabbabaababbaabaaaababbbba
abaabbbaabbbaaabbabaaaab
bbbbbbbbaaabbabababaaabbbbaaaabbbabaaabb
baaaaabbbaaaaabbabbaaaaa
ababaaaaaabbbaababbaabba
bbaaaaaaaaabbababaaaaaaaaabaaaab
bbbabababbbbabbaabaaaaaa
bbaaaababaaabbbabbbabaabaabaabab
bbbabbbaaabbbbaaabbaabbaabaabbbaaabbbbba
babbabbabbbbbbbaaababababaaabaabbaaaaaabaaaaabaaabbbbbbaaabbbbbabbaabbaa
ababbabbaabbaabbbaaaaabbaababaaaabbabbab
abbabbbbbaabbbbbbabaabbb
abbbaabbaaaaababbbaabbabaababaabaababaababbbbbbbbbaabaab
baaaaaaabbbabbbaaaabbbba
bbaaabbbababbbabbaaaabaabaabbabbbbbbbbbbabbabbabbababababbaababbbbabbaba
bbbbababbaabbababbabbbab
baaabaabaababbbbbbabbbbb
abbbbababbbababbbbabbababbabaabbbbaaaabb
bbaaaaaaabbbabbbabbbbbaa
bbabaabaabbabbaaababbbaa
aabbbaababaabbabbabaabba
baaabbbaaaabaababbaaaabb
babbbbaabbbbaabaabbbaaaa
abbaabbbaababbabbaaabbababbbabab
aaabaaaaaabbabababbbbabbbbabbbbbaaabaaab
babbbaababbaaaaaaabaaababbaaabbb
bbbbaababbaaaaaabbbbbaab
bbaaaaaaabbbbababaabaaab
babaababbabbabbbaabababaabaabaab
abbbabbbabbabbaaaababaababbabaab
bbbbaaaaaabbaababbabaaabbbabaaaabbabbabb
aaabbaabbaaabbbbbbbbbaaa
abbbbaabaabbbabaabaaabababaabbba
babbabbabaaababbbbaaabbababaabaabaabbaababaabaaa
babbabbaaabaabbaaaaaabaaabbbaabaabbaaaaabbbaaabaaababbaabbbbaabaabbbbaba
aabaaabbabbaaabbbabbbabb
bbaaaaaabaabbbbaabbbaaab
bbbbaaaabbbaaabaabbbbabbbababaaa
abbbabaabbabbaabbabbbbba
aaaaaaabaababbbbababbbab
abbbababbbabbbbabbbbbabbbabaaababbababaabbbaaaab
babaaabaaabbbaaaaabbbbbbabbaaaaabaabaabbabbbababaababaaaaaabbaaababbbabbbaaababb
abbababbbaaaaaabbabaaabb
bbabbababbabbaabbababbbb
babbbbaaaabbaaababbbbaaaaabbababaaabbaabbbbbaaab
aabbaabbabaaaabbaabababaabaaaabaaaabaaaaaaabaabababababa
abababbaaaabaabaaaababbb
bababbabaaabbbaaababbbbb
baaaababbabbbabababaabba
abbbbabaaaaababbbbbaabbabaaaabbaaaababba
aabbababbbaababbabaababa
babbaaabbbaabaabbbaaabbabaaaaabaabbabbaabaabbaabbbbbababbbbabbbb
aaabbbaaabbabbabaabaaaaaaabaaaaa
aababbaaaababbbbabbbaaaa
baaabbbabababbbaaabaabba
bbabbaabbbbabaaabaaabbbbbbbaabababbaabbbbabbabbaaabaaabb
baabaabaababababaaabaabb
abbababbbbbbababbbaabaab
abababbabababbabbaaaaaab
bababbbaaabaaabababababb
aabbabbbbaaababbbbabbaaa
abbaaaababbabababbaabbbabbaabaab
bbbabbbaababaaaabbbaaabababbaaaaababbabaaabbabaaaaaaabba
baabaabaababaaabbbbbababbabbabbabababbbb
bbbbbaaabbaababaabbbbbaaababaaba
bbaaaabaabbaaaabbbababbbbbbababaabbabaababbbaaaaabaabaaa
bbabaaaaababbbbbbababbbbbbbababbbabbbbab
ababababbaaabaabbbbaababaababababaabbbaaaaababbbbabaaabb
babbbabaaabbabbbaababbba
aaaaaaaababbbababbaababbabbbaabb
aababababbaaaaaabaaaaaba
aaaaaaabbaaaabaaaababaabbbabbabb
bbabbabbbbbbabbaabbbaabaababbbaabaaabababaabbbbbbabbbbbb
bbbaabbaabaaaabaabaaabaa
babaabbabbabbaaabaabaaaaabaabaaa
aababababbbbaabaabbbbbaa
baabababbaabaabbaaaaaabbaaaaabababbabbaaabbabbaaaaaaabbb
bbabaabaababbabbbabbaabb
abaaaababbbbbbbabbabaaaa
bababbabbbbbabaababbbbbb
aabbabbbbbbbabababbabaab
abbababababbabaaaabbbaaa
aabababbabbaabbbbbbaaaabbbbbaaaa
abbbabbbaaaaaaabbaabbbbb
bbbbbbbaaabaaababbbbababbabaaabaabababbb
aaaababbaaaaaabaaabaabba
abaaaabbbbbbababbbababbbabaabaaababaabaa
bbabbbaaababbabbbbbaaaab
aababaaabaabbbbbbbbabbbb
aabbbaababbbbbabbababaaa
aabbaaababbaababbbbbababbbbbababbbbbaabbbaabbbbbabaabbaabbbabbbb
baaabbbbbbbaaabaabaabaab
baaabbaaaababaabbabaaaaa
aaabababaababbabaababababbbbbbaabbabbbaabaabaabbaaabaabaababbbbb
aabaaabbbaaabaaabbbabaab
bbbaabbaababbabababbbbbababbbabbbbaabbbbbbabaaaaaaaabbab
aabbaaabbbaabbabaaababbb
bbbbabaabbbabbbaaabaaaab
aabbaabbbabaababbaababaa
aaaaaaaababbbbababaaaabaaabababbabaaababababababaaabbabbababbbbbaaaabbab
babbbbabbababbbabaabbaaa
aabbaaabbbaababbbbbbabaaababaabbbabaaabaaabbbabbababbaba
bbbaaaaabbaaabababbabbbb
bbbbabbababbaaaabbbabbbaabbaabbbbbaabaaa
aaaababbabbaababbabababb
bababbabaaabaaabbaabbbaabaaababa
babaababbaaaaaabababbaabbababbaaaaababbb
aabbabababaaabbababaaaba
bbbaaabbabaababbbababbaa
abbabbbaabbaababbabaabba
baaababbaaaaaabaaabbbaaa
baaaaaabaabababbaaabbaabababbaababbaaabbaababbba
abbbbabbbbabbabaaaaaaabbbabbaabb
abbbbaabaaabaababbbababaaabbbaabbabbabbabbabaaababbabbbbbaababaa
bbbabababaabbaaabbaaababbabaaaaabbaaaaaa
abbbbaababbbabbbaabaaaab
bbababaaaaaabababaaabbbbbbabbaaababbabbabaaaababaaaabababbabaabaabaabaab
bbbabbaabbbbabababaaabaa
abaaabbabaaaabaaaaabbabaababbaba
babbaabaabbabbaabaaaaaba
aababababbabbbaaabbaabba
bbbabaabbaaabbbabbabbaaa
bbbababaaabbabababababbb
aabbbbababaaaabbbaabbabbbaabbaab
bbaaaababababaababbbaaab
abbbaabbaaaaabbaaabaaaabbabaaabaaaaabbabbaababaa
babbabaabababbabbbbbabbbaabbbaba
bbbbbbbaabbbaabbbbbabbab
abaabbabbaabaababaabababbbbaaababababbaaaabbbabbabbaabbb
abababbabbaaaaabaabbabba
abbabaaababbababaabaababbabaaaaabbaaabaabbabbaaa
babbabaabbababbbbbabbaaa
aabaaabaababaaaaaaaabbba
bbaabbbabbbbaaaabaabababaabaaabaaabbabba
abaaaabaaabaaabbabbabbbb
abaaaaabaaaaaaaabaaaaaba
aaabbabababbbbaaaaaabbbb
bbbbaabbabaaabababaaabbababbbabaababbaabbabaabba
bbbabbbaaabbbababbaaabbbbbbabbabbbbbbabbabbbbbbb
abaaaababaaabaabababaaba
baaabaaabbabbbaaaabbaababaaaabba
bbbbabbbbbaabbbabaabbbbb
ababbaababbbbabaababaaaaaabbaaabaaaaabbb
baaaababaaaaababbababbaa
aabaababbabbaabbbaabbababaabbaabaaabaaabbabaabbababaaabbabbbaaab
abbabbaaaaaaabbabaaaabbaababbaaa
bbbbaabaabbbbabbaabbabbbaababbbbbabaaaba
bbbaaabbbaaabbbaaaababbb
baaabbbabbbaaaaabbbaaabaaabababbabaaabbababbabab
aabaaabbabaaaaababbbaaab
bbaaaaabaabbabababbbbaaababbababaabaabba
bbaaababbbbbaaaabababbbaaaabbabb
bbababbbbbabbababbbbabaabbbbaaaaaabbbaabbabbabbbbbbabbbb
bababbbaaaabbaabaaaabbba
ababbaababaabbabaaaaabba
aaaaaabaaaabbbaaababbaba
babbbbaaabbbabbbbbbabbab
bbbbbbbabbbbabbbabbaaaba
baaabaaaaabbaabbabaaababaaababbb
baabaabababbabbbaabbbabb
bbaaaaaaabbbbabbabaabbabbabbaaabaaaababaaaaaabba
baaaaaaaaaaaaaaaaaaababa
abbaababaabbbbabaaababba
bbbbababaabbbaabaababbaaaaabaaab
aababaabaabaababbbbbaaaaababaaaaabaababbbabbbbaaabaaaaabababbbab
babaababbbaabbabbbaabbaa
baabbababaaaabaabababbaa
bbaaabbabbaaabbbbbabbabb
baabbbbabbaaaabaaaabbbba
bbababbbbaabbbbaaaaabaab
aaabababaaaaaabbabaaaabababbbbbb
bbbbbbababaaabbbbaaaaaaabbaabbaabbbbbaabaabaaabbaaabbbbabbaabaabbbbaaabbabbbaabb
aabbbaaababbabbbbaabbbbababaaaaababaaaaaaaababbbaabababb
bbabbaabbabbaaaaaaaaabba
abbabbaabbaabbabaaabaabaabbaaaaaaabaaaabbbaabaabaabbabaa
abaababbaabbaaabaaabaaaabbaaaabaabaaababaababaaabbbabbababaaabaaabbaabbabbaaabaa
bbaaaaabbbbbabaaaababbaababbabbbaaabbabababbababbabbbbba
babbbbaaaababbaaaabaabbbbaabbbaababbbbbb
aaaababbbbbbbbaabbbabbbb
bbaaababbbaaabbaaabbbabb
abbaaabbbabbaabababaabbb
aabababbabbbbbababbbaabbaaabaaaaabbabbaababaabaabaaaaabaaababbbaababbbab
babbaaaaaabbbbabbbbbbbaabaabbbabbbbbaaab
babbabaaabbaaabbbabaaaaa
aaaaaaabababababbaababbb
ababaabbbabbaaaaabbbbbbb
aabbaaabaabbbabaaaababba
baabbabaaabaabaaabbaaaaa
abaaaabaaabbbaabbabaabaa
bbaaabbbbaaabbbaababbbbb
baaababbbbbaababbbabbaaa
ababbbbbabbababbaaabaabbaabbbaaaaabbaaabbbbbababbaaaaabaaabbbbaaaabbabaaaababbbbabaabaaa
bbbbabbbababababbaabbaab
ababbaabbabbbbaababbabbabaaabbaabaaabaaabaaaabbbababaababaababbb
baaaababbabbbbabbaabbaab
bbaabbbaabaaabbbbababbaa
bbabbbbaabbaaabaabbaabbaabaabbbb
bbbaaaaabbaababbbbaabbababaababbabbaaaba
aabababbaaabbbaaababaabbabbbbbba
abaaaabaaaabaaaabaaaababaabbbaababaabbabaaaaabbaaababbbabaabbaaababaaaab
baaabbbbbababababaaaababbbbaabaaaabaaabbbabbaabbabbbabaabbaaaaba
abbbbabbbbbbabbbbabbbbbb
bbbbabbbabbaaabbbbabaabaababaababbaaaabb
ababaaaaaababaabbaabbabaabbbabaaababbaaaabbbaaaa
bbbbbbbbbbbbaabbaaaabaab
aababaabbabbabaaaaaabaab
ababaaababbabbbabbaabaaa
bbbababbabbbbbabaaaaabaa
abbbaabbbabbbbabaaabbaaa
abbaaaabbbaaaaabaabaabba
aaabbabaaabaabbbaaabbabb
ababaaababbbbaaababaababbbbaabbbbaabaaaa
baabababbaababbabaabbaab
bbaaabbbaaabaabaababbaba
baaaaabbbbbaabaabaaabaaabaabbbbb
aabbbababaaaaaabababbaaa
baaaababbaaababbaaaaabaa
aabababaabaabbababababbb
bbaaaaaabaababbabbbbabaabbbbbbaaaabbaaabbababaab
bbbbababaabababaaabbbaaa
baaabaababbabbbaaababbaa
babaaaaaabbaababaaabbbbaabababbababaaaababaabaabbbbaabbbaaaaababaabaabbabbbbbbbbabababbaabaaaaab
bbbaababbaabbbbabaaaabaaabbbbbba
aababaabaababaaabbbaaababbbabaabbbaabaab
bbbbababaaabaaaabbbaaaab
bbbbbbbbabbbabbbaababaabbbabbabbbbaabaab
baaabaaabaaabbbbaabaaabbaaabaabaaabbbbaa
bbbabaabbaaaababaaabaaab
ababababbbbbabbbaaabababbaabbaab
abbababbaababaaaaababbaa
ababababaabbaabbbababaaa
ababbabbaaaaaabbababbbab
aaabbabbbaabababaabbaabbaaabaabbbabbaabb
bbbbababaabaaaaaabaaaaaa
bbaababaababbaabaaaabaaaaabbabaabaaaaaaaaabbaaba
bbababbbbaaaaabbaaababba
bbbbbbaaabbaababbaaabbaaabbbbabababbbbba
aabbbaabbbbababbbaaababa
aabaabaabaaabaababbabbbb
bbbbabaabaabbbbababaabab
abbbaaaaaabbbbbababbababbaaaabba
aaaaaaabaaabaababbbaaaaaaabbbbbbbbaabaaaabbaaaba
baaabbabbaaabaababbaabababbabbbabaabababaaababbbbbabbaabaabbbabb
aaaaababbaaabbaabbaaaabb
bbbabbbabaabbabaabbbabbaababaaaabbbbabbabbaabbaaaabaaabbabbbbaab
baabaabaabbbbbababaaaabbbbbabaabbbbaaaabbbbbbaabbaabbbbb
bbaaaaaabbabbaabbaabaaba
abbababbbabbbbabbaaaaaabaaaaaabaaaaaabbb
abaababbaabbbaabbabaabbb
baabababbaabababbbbaaaaabbababbbbaaaabbb
baabaabaabaabbbbbaabababbabababbbbabbbaabaaaaabaaaaabaaababbbbababbbaaabbbabaaba
abbbbaaaaaabbbaabaaaabaaaaaabbaa
baababababbaaabbbabbaabb
aaaaaabaabababbabbabbbbb
aaabbabaaabbaabbbbabaaab
abbbaabbbbbbabaaaaaabaaa
aabbabbbabaaaabbaabbbaaa
aabbababbaaabbbbabbbbbabaabaabab
bbbaababaabbbbbabbabaaaabaaaabba
bbbbababaabababaaabbabaa
ababaabbbbbbbbbaaaaabbbb
aaabababbabbaaaaababbbbb
bbbbabbabbbbbbaaaabaabbbbabbbbba
bbbababbaaababababbaababbbabbaabbabaaabaabbabaab
baaabbbaabababbaababbbaa
aaaaaababbbabbaaaabaaaaaabababababbaabaababaaaba
bbabbaabbbbbbbaabbbaaaab
babbaabaabbaaabbbbaabbbaabababbaaaabbbaabaababbbabbbaaaa
baabaabbbaaababababaaabbabbbbaaaaabaaaaababbabaaabbbbbbabaabaababbbbbaaabaaaaaaa
abbaababbbbabaabababbaba
bbaababbababababbbbbbaab
bbbbaababbaaaababaaabbaaabaabbbbbbbbbaaa
babbbaaabaababaababbbabbabbaabbabbaaaabaaababaababaabaaaabbaaaba
bbababbbabaaaaabbbbbbabb
babbabbbababaaaababbbabaaaabbababbabbbbbabababbb
abbbaabbbbaaabbbaaabbabaaaaaaababaabaabbaabbbaabababbbabbbbbbbabababbbbbaaababaa
aaaaabbabbbaaaabbaaababbbaaaababaaabbabbbabbabbaabbabaabaabbaaaaabbaabaababaabaababbabaa
baaababaababbbabbaaaabbaababbaaababababababbaabbbbbabbbababbababaaabbbbaababbaba
babbabbaabbbabaaabbaaaaa
bbbaaabaaaabababbaaabbbabababbbb
bababbbaababaaaabaabaabaaabbabbbbbabababbabbbaab
aababaaaabaabbabbabaabaa
aababbaaaaabbaabaaaababa
babbbbaababbbbaaaaabbbaabbaababbbbabaaabbaaabbabababbbaa
abaaaababababbabbababbbabbabbaabbbaaabaa
aabbababaabbaababaaaaabbbabbaaaabababbabbbbabbaaaaabbbbb
aabaaababbaaaabbaabbabaaaaababbabababbbb
abbbbbaabbbabaaaaaaaabbaaabbbaaa
bbbbabaaaabbbababbbabbbb
bbbababaababaaabaabbabaa
abaababbbaaababbbabbbbaaabaabaab
aaabbaababbbbaaaaabbbbba
aabaaaabababbaaaaaabaabbaaaabbaa
baaabbabbbabaaabaaaabaabababbbbb
abaaaaabbbaaaaaabaababaa
bababbabbbbabbaaaaabbbab
abaaababbaabbabaaabaaabbabbbbabaaaaababaaabaaaabbbbabbbbbaabbaaa
aabababbaaabaaaaabbaabba
ababaaabbabbabaabbbaaaaaaaaaaabbaaabaaab
aabaaababbbababaaabaabaabbbbaaaaaabbaaaa
bababaaabbababbabbbabaaa
abaaabbabaaabaabbababbaa
abbbabaabbaabbbababbbbbb
aabbbbabbaaabaaabbaaabaa
bbbbabbaabbbbbbaaaababaa
abbbbabaaabababbaaabbbbb
abaaabbaabaaabbbbbaabbbb
aabaaabaaaaaaabaaaaabbba
abbabbbaababbabbaaaabbbb
babbaabaaaaaaaabbaabbbbabaaaababaabbaaaa
ababbabbabaaaabbbbbababbaabbababbbbababb
abbbabbbbabbbbabbbaabaab
baaababbbbaaabbabbbaaaab
abbbbaabbbbbaabbabaaababbaabaaab
bbbbababbbaaabaaabbababbbabbbbababaababaaaabaaaabaaaabaaabbbaabababbbabbbaaaaaababbaabbb
bbbbabaabbabaabbabbbbbabbabaaabbaabbaaab
baabbabaaabbaababbbbbaab
bbabaaabaabaaaababbbbbaabaaabbaabababbaaaabbaaabaaaababbaaaababaaaaaaaaaababbbbb
abaaaabaabbbabbbaaaaababbaaaaaab
abbbabbbaababbbbabaaaababbaaabbaabbbaabbbbabaaaa
bbaaabbabbaababbbbbabbaabaabbbbabbbaababababbbaa
bbaaaaaababbbbbbbaababaaababbaaabaabaaabbbababbabbabbbbababbaaab
bbaababbbbaaabbbababbaba
bbbaaabbbbbbabaabbabbaaa
bbbababaaababbbbbaababaa
baaaababaababaaaabbbbbbb
aabbbbabaaaababbbabaabba
baaabaabbbbabbbabbaaabbaabbbaabbbbaabaab
aabbbaabbaaaaaaabaaaaabbbbbaabab
baaaabaaaabbaabaabaaababaaaabaab
aaaaaabaaababbaabaaaaaba
aaabaaaaaabbbbabbaabbaaa
abaababbbbbabbbaaaaaaaaaaabaaabbbaabbbabaaabaabb
bbbaabbaabbababaabbabaaa
bbbababbabbabbbabbaaabbabababbaaababbbbb
abaabbbaababbbaaabbabaab
aababaabaaabbababababbbaaaabbabababbbbaaaaaabbbababbabab
bbabbbaaaaaaababbbaaaabababbabaaabbabbbbaaabbbbb
aaaaaabbbbbaaabbbbaabaaaaabbabaa
bbbaabbababbaabaaabbbbbb
abbbabaaaaaaababaababbab
bbabaabaaabbaabbaabbabba
baaaabaaaababaabbbabbbab
bbaabbbaaaabbaaaaaaaabaaaaaabbaa
aabaabaaaababaabbbbaabaabbbaaabbbbabbabb
aaabaabaabbbabbbaabbbbbb
babbaaaaabaaabbbbbaaababaaaaaabaababbbababbabbbbaaabbbba
abbababbbaabbabbabaabbabaaaaabbb
ababaaabbaaaaabbabbbabaabbaabbbaabaaaaabbaabaabbabbbaaaa
babbaaaabaabababbaaaabbb
aaabbbaaaabbbabababaabaa
bbbaaabaababbaabababaaba
aaababbaaabbaababbbbabbabbbabbab
abababbaaababaababbaabba
bbaaabbabbbbababaaaabaab

View File

@ -1,5 +1,5 @@
#![feature(iter_map_while)]
#![feature(test)]
#![allow(clippy::ptr_arg)]
extern crate test;
use aoc2020::common::*;
use itertools::Itertools;

View File

@ -1,4 +1,5 @@
#![feature(test, str_split_once)]
#![feature(test)]
#![allow(clippy::ptr_arg, clippy::upper_case_acronyms)]
extern crate test;
use aoc2020::common::*;

View File

@ -40,7 +40,7 @@ fn sum_up_to(input: &[usize], n: usize) -> Option<usize> {
return None;
}
}
return None;
None
}
fn main() {

View File

@ -1,4 +1,5 @@
#![feature(test)]
#![allow(clippy::ptr_arg)]
extern crate test;
use aoc2020::common::*;

View File

@ -40,7 +40,7 @@ impl Default for Tile {
}
}
type Parsed = HashMap<Position2D, Tile>;
type Parsed = HashMap<PositionND<2>, Tile>;
fn read_input() -> String {
read_file(11)
@ -50,28 +50,32 @@ fn parse_input(raw: &str) -> Parsed {
raw.lines()
.enumerate()
.flat_map(move |(y, l)| {
l.chars()
.enumerate()
.map(move |(x, c)| (Position2D { x: x as i64, y: y as i64 }, Tile::from(c)))
l.chars().enumerate().map(move |(x, c)| {
(
PositionND {
points: [x as i64, y as i64],
},
Tile::from(c),
)
})
})
.collect()
}
#[inline]
fn occupied_neighbors(pos: &Position2D, grid: &Parsed) -> usize {
fn occupied_neighbors(pos: &PositionND<2>, grid: &Parsed) -> usize {
pos.neighbors()
.iter()
.filter(|p| grid.get(&p).unwrap_or(&Tile::Floor) == &Tile::Occupied)
.filter(|p| grid.get(p).unwrap_or(&Tile::Floor) == &Tile::Occupied)
.count()
}
const DIRECTIONS: [(i64, i64); 8] = [(0, 1), (1, 0), (1, 1), (0, -1), (-1, 0), (-1, -1), (-1, 1), (1, -1)];
#[inline]
fn neighbors_in_vision(pos: &Position2D, grid: &Parsed) -> usize {
DIRECTIONS
.iter()
.map(|t| Position2D::from(*t))
fn neighbors_in_vision(pos: &PositionND<2>, grid: &Parsed) -> usize {
IntoIterator::into_iter(DIRECTIONS)
.map(|(x, y)| PositionND { points: [x, y] })
.map(|p| {
(1..)
.find_map(|n| match grid.get(&(*pos + (p * n))) {
@ -85,20 +89,20 @@ fn neighbors_in_vision(pos: &Position2D, grid: &Parsed) -> usize {
.count()
}
fn make_step<F: Fn(&Position2D, &Parsed) -> usize>(previous: &mut Parsed, count_neighbors: F, limit: usize) -> bool {
fn make_step<F: Fn(&PositionND<2>, &Parsed) -> usize>(previous: &mut Parsed, count_neighbors: F, limit: usize) -> bool {
let readonly = previous.to_owned();
let mut changed = false;
for (pos, tile) in previous.iter_mut() {
match tile {
Tile::Floor => (),
Tile::Empty => {
if count_neighbors(&pos, &readonly) == 0 {
if count_neighbors(pos, &readonly) == 0 {
*tile = Tile::Occupied;
changed = true;
}
}
Tile::Occupied => {
if count_neighbors(&pos, &readonly) >= limit {
if count_neighbors(pos, &readonly) >= limit {
*tile = Tile::Empty;
changed = true;
}
@ -108,7 +112,7 @@ fn make_step<F: Fn(&Position2D, &Parsed) -> usize>(previous: &mut Parsed, count_
changed
}
fn move_until_equilibrium<F: Fn(&Position2D, &Parsed) -> usize>(mut parsed: Parsed, count_neighbors: F, limit: usize) -> usize {
fn move_until_equilibrium<F: Fn(&PositionND<2>, &Parsed) -> usize>(mut parsed: Parsed, count_neighbors: F, limit: usize) -> usize {
while make_step(&mut parsed, &count_neighbors, limit) {}
parsed.iter().filter(|(_, t)| t == &&Tile::Occupied).count()
}
@ -219,7 +223,7 @@ LLL####LL#
assert_eq!(draw_ascii(&grid), draw_ascii(&after_1));
assert_eq!(&grid, &after_1);
assert!( make_step(&mut grid, neighbors_in_vision, 5));
assert!(make_step(&mut grid, neighbors_in_vision, 5));
let after_2 = parse_input(P2_AFTER_2);
assert_eq!(draw_ascii(&grid), draw_ascii(&after_2));
assert_eq!(&grid, &after_2);

View File

@ -1,4 +1,5 @@
#![feature(test)]
#![allow(clippy::ptr_arg)]
extern crate test;
use aoc2020::{common::*, grid::*};
@ -17,23 +18,23 @@ fn parse_input(raw: &str) -> Parsed {
fn part1(parsed: &Parsed) -> i64 {
let end_pos = parsed
.iter()
.fold((Direction::Right, Position2D { x: 0, y: 0 }), |(dir, pos), (cmd, dist)| match cmd {
'N' => (dir, pos + Position2D::from((0, *dist))),
'S' => (dir, pos - Position2D::from((0, *dist))),
'E' => (dir, pos + Position2D::from((*dist, 0))),
'W' => (dir, pos - Position2D::from((*dist, 0))),
.fold((Direction::Right, PositionND::from([0, 0])), |(dir, pos), (cmd, dist)| match cmd {
'N' => (dir, pos + PositionND::from([0, *dist])),
'S' => (dir, pos - PositionND::from([0, *dist])),
'E' => (dir, pos + PositionND::from([*dist, 0])),
'W' => (dir, pos - PositionND::from([*dist, 0])),
'R' => (dir + (dist / 90) as i8, pos),
'L' => (dir + -(dist / 90) as i8, pos),
'F' => (dir, pos + Position2D::from(dir) * *dist),
'F' => (dir, pos + PositionND::from(dir) * *dist),
_ => unreachable!(),
})
.1;
end_pos.x.abs() + end_pos.y.abs()
end_pos.points[0].abs() + end_pos.points[1].abs()
}
fn rotate_waypoint(mut wp: Position2D, deg: i64) -> Position2D {
fn rotate_waypoint(mut wp: PositionND<2>, deg: i64) -> PositionND<2> {
for _ in 0..((deg / 90 + 4) & 3) {
wp = Position2D { x: wp.y, y: -wp.x };
wp = PositionND::from([wp.points[1], -wp.points[0]]);
}
wp
}
@ -42,12 +43,12 @@ fn part2(parsed: &Parsed) -> i64 {
let end_pos = parsed
.iter()
.fold(
(Position2D { x: 10, y: 1 }, Position2D { x: 0, y: 0 }),
(PositionND::from([10, 1]), PositionND::from([0, 0])),
|(wp, pos), (cmd, dist)| match cmd {
'N' => (wp + Position2D::from((0, *dist)), pos),
'S' => (wp - Position2D::from((0, *dist)), pos),
'E' => (wp + Position2D::from((*dist, 0)), pos),
'W' => (wp - Position2D::from((*dist, 0)), pos),
'N' => (wp + PositionND::from([0, *dist]), pos),
'S' => (wp - PositionND::from([0, *dist]), pos),
'E' => (wp + PositionND::from([*dist, 0]), pos),
'W' => (wp - PositionND::from([*dist, 0]), pos),
'R' => (rotate_waypoint(wp, *dist), pos),
'L' => (rotate_waypoint(wp, -dist), pos),
'F' => (wp, pos + wp * *dist),
@ -55,7 +56,7 @@ fn part2(parsed: &Parsed) -> i64 {
},
)
.1;
end_pos.x.abs() + end_pos.y.abs()
end_pos.points[0].abs() + end_pos.points[1].abs()
}
fn main() {

View File

@ -18,7 +18,7 @@ fn chinese_remainder(divs: Vec<i64>, rems: Vec<i64>) -> i64 {
if x1 < 0 {
x1 += b0;
}
return x1;
x1
}
let mut sum = 0;
let prod: i64 = divs.iter().product();
@ -26,7 +26,7 @@ fn chinese_remainder(divs: Vec<i64>, rems: Vec<i64>) -> i64 {
let p = prod / div;
sum += rem * mul_inv(p, *div) * p;
}
return sum % prod;
sum % prod
}
type Parsed = (i64, Vec<Option<i64>>);

View File

@ -1,4 +1,5 @@
#![feature(test, str_split_once, destructuring_assignment, bool_to_option)]
#![feature(test, destructuring_assignment, bool_to_option)]
#![allow(clippy::ptr_arg)]
extern crate test;
use std::collections::HashMap;
@ -22,7 +23,7 @@ fn read_input() -> String {
read_file(14)
}
fn parse_input<'a>(raw: &'a str) -> Parsed<'a> {
fn parse_input(raw: &'_ str) -> Parsed<'_> {
raw.lines()
.map(|l| {
if let Some(l) = l.strip_prefix("mask = ") {
@ -58,7 +59,7 @@ fn calc_bitmasks_p1(b: &str) -> (usize, usize) {
(calc_bitmask(b, |(_, b)| *b == b'1'), calc_bitmask(b, |(_, b)| *b != b'0'))
}
fn part1<'a>(parsed: &Parsed<'a>) -> usize {
fn part1(parsed: &Parsed<'_>) -> usize {
let (mut ones, mut zeros) = (0, 0);
let mut mem = HashMap::new();
for command in parsed {
@ -72,7 +73,7 @@ fn part1<'a>(parsed: &Parsed<'a>) -> usize {
mem.values().sum()
}
fn states_to_number(bits: &Vec<BitState>) -> usize {
fn states_to_number(bits: &[BitState]) -> usize {
bits.iter()
.rev()
.enumerate()
@ -95,7 +96,7 @@ fn get_variations(input: Vec<BitState>) -> Vec<usize> {
}
}
fn part2<'a>(parsed: &Parsed<'a>) -> usize {
fn part2(parsed: &Parsed<'_>) -> usize {
let mut mask = vec![];
parsed
.iter()

View File

@ -1,4 +1,5 @@
#![feature(test)]
#![allow(clippy::ptr_arg)]
extern crate test;
use std::collections::HashMap;
use aoc2020::common::*;

View File

@ -1,4 +1,4 @@
#![feature(test, str_split_once)]
#![feature(test)]
extern crate test;
use aoc2020::common::*;
use itertools::Itertools;
@ -79,7 +79,7 @@ fn part2(parsed: &Parsed, key: &str) -> usize {
let mut rules = vec![None; len];
for i in (0..len).cycle() {
let at_index = only_valid.iter().map(|v| v[i]).collect_vec();
if let Some(_) = rules[i] {
if rules[i].is_some() {
continue;
}
if let Some(rule) = remaining_rules

View File

@ -1,8 +1,8 @@
#![allow(incomplete_features)]
#![feature(test, const_generics, const_evaluatable_checked)]
#![feature(test, generic_const_exprs)]
extern crate test;
use aoc2020::{
common::*, grid::{cell::Cell, *}
common::*, grid::{self, cell::Cell, *}
};
use itertools::Itertools;
@ -10,7 +10,7 @@ fn read_input() -> String {
read_file(17)
}
fn parse_input<const DIMS: usize, F: FnMut((usize, usize)) -> PositionND<DIMS> + Copy>(raw: &str, mut pos_gen: F) -> Grid<DIMS, Cell> {
fn parse_input<const DIMS: usize>(raw: &str) -> Grid<DIMS, Cell> {
raw.lines()
.enumerate()
.flat_map(move |(y, l)| {
@ -22,31 +22,38 @@ fn parse_input<const DIMS: usize, F: FnMut((usize, usize)) -> PositionND<DIMS> +
.collect()
}
fn count_live_neighbors<const D: usize>(p: PositionND<D>, grid: &Grid<D, Cell>) -> usize {
p.neighbors().iter().filter(|&n| grid.get(n) == Cell::Alive).count()
fn count_live_neighbors<const D: usize>(p: &PositionND<D>, grid: &Grid<D, Cell>) -> usize
where [(); grid::num_neighbors(D) + 1]: Sized {
IntoIterator::into_iter(p.neighbors())
.filter(|n| grid.get(n) == Cell::Alive)
.count()
}
fn make_step<const D: usize>(input: Grid<D, Cell>) -> Grid<D, Cell> {
fn make_step<const D: usize>(input: Grid<D, Cell>) -> Grid<D, Cell>
where [(); grid::num_neighbors(D) + 1]: Sized {
let readonly = input.clone();
input
.fields
.keys()
.flat_map(|p| p.neighbors().iter())
.flat_map(|p| p.neighbors())
.unique()
.map(|pos| {
let cell = readonly.get(&pos);
let new = match (&cell, count_live_neighbors::<D>(&pos, &readonly)) {
(Cell::Alive, 2..=3) => Cell::Alive,
(Cell::Dead, 3) => Cell::Alive,
_ => Cell::Dead,
};
(pos, new)
})
.map(|pos| (pos, next_state(&pos, &readonly)))
.filter(|(_, c)| c == &Cell::Alive)
.collect()
}
fn solve<const D: usize>(parsed: &Grid<D, Cell>, steps: usize) -> usize {
fn next_state<const D: usize>(pos: &PositionND<D>, grid: &Grid<D, Cell>) -> Cell
where [(); grid::num_neighbors(D) + 1]: Sized {
let cell = grid.get(pos);
match (&cell, count_live_neighbors::<D>(pos, grid)) {
(Cell::Alive, 2..=3) => Cell::Alive,
(Cell::Dead, 3) => Cell::Alive,
_ => Cell::Dead,
}
}
fn solve<const D: usize>(parsed: &Grid<D, Cell>, steps: usize) -> usize
where [(); grid::num_neighbors(D) + 1]: Sized {
let mut clone = parsed.clone();
for _ in 0..steps {
clone = make_step(clone);
@ -56,9 +63,9 @@ fn solve<const D: usize>(parsed: &Grid<D, Cell>, steps: usize) -> usize {
fn main() {
let raw = read_input();
let input = parse_input(&raw, |(x, y)| Position3D::from((x, y, 0)));
let input = parse_input::<3>(&raw);
println!("Part 1: {}", solve(&input, 6));
let input = parse_input(&raw, |(x, y)| Position4D::from((x, y, 0, 0)));
let input = parse_input::<4>(&raw);
println!("Part 2: {}", solve(&input, 6));
}
@ -72,40 +79,82 @@ mod tests {
..#
###";
#[test]
fn test_make_step() {
let input = parse_input::<3>(TEST_INPUT);
let changed = make_step(input.clone());
let expected = Grid {
fields: IntoIterator::into_iter([
(PositionND { points: [1, 3, 0] }, Cell::Alive),
(PositionND { points: [0, 1, 0] }, Cell::Alive),
(PositionND { points: [2, 2, 0] }, Cell::Alive),
(PositionND { points: [2, 2, 1] }, Cell::Alive),
(PositionND { points: [0, 1, 1] }, Cell::Alive),
(PositionND { points: [2, 1, 0] }, Cell::Alive),
(PositionND { points: [1, 3, -1] }, Cell::Alive),
(PositionND { points: [0, 1, -1] }, Cell::Alive),
(PositionND { points: [1, 2, 0] }, Cell::Alive),
(PositionND { points: [1, 3, 1] }, Cell::Alive),
(PositionND { points: [2, 2, -1] }, Cell::Alive),
])
.collect(),
};
assert_eq!(changed, expected);
}
#[test]
fn test_count_live_neighbors() {
let input = parse_input::<2>(TEST_INPUT);
let one_one = PositionND { points: [1, 1] };
let live = count_live_neighbors(&one_one, &input);
assert_eq!(live, 5);
}
#[test]
fn test_next_state() {
let input = parse_input::<2>(TEST_INPUT);
let one_one = PositionND { points: [1, 1] };
assert_eq!(next_state(&one_one, &input), Cell::Dead);
let one_three = PositionND { points: [1, 3] };
assert_eq!(next_state(&one_three, &input), Cell::Alive);
}
#[test]
fn test_3d() {
let input = parse_input(TEST_INPUT, |(x, y)| Position3D::from((x, y, 0)));
let input = parse_input::<3>(TEST_INPUT);
assert_eq!(solve(&input, 1), 11);
assert_eq!(solve(&input, 2), 21);
assert_eq!(solve(&input, 6), 112);
}
#[test]
fn test_4d() {
let input = parse_input(TEST_INPUT, |(x, y)| Position4D::from((x, y, 0, 0)));
let input = parse_input::<4>(TEST_INPUT);
assert_eq!(solve(&input, 6), 848);
}
#[bench]
fn bench_3d_parse(b: &mut test::Bencher) {
let raw = read_input();
b.iter(|| assert_eq!(parse_input(black_box(&raw), |(x, y)| Position3D::from((x, y, 0))).fields.len(), 43));
b.iter(|| assert_eq!(parse_input::<3>(black_box(&raw)).fields.len(), 43));
}
#[bench]
#[rustfmt::skip]
fn bench_4d_parse(b: &mut test::Bencher) {
let raw = read_input();
b.iter(|| assert_eq!(parse_input(black_box(&raw), |(x, y)| Position4D::from((x, y, 0, 0))).fields.len(), 43));
b.iter(|| assert_eq!(parse_input::<4>(black_box(&raw)).fields.len(), 43));
}
#[bench]
fn bench_3d(b: &mut test::Bencher) {
let input = parse_input(&read_input(), |(x, y)| Position3D::from((x, y, 0)));
let input = parse_input::<3>(&read_input());
b.iter(|| assert_eq!(solve(&input, 6), 348));
}
#[bench]
fn bench_4d(b: &mut test::Bencher) {
let input = parse_input(&read_input(), |(x, y)| Position4D::from((x, y, 0, 0)));
let input = parse_input::<4>(&read_input());
b.iter(|| assert_eq!(solve(&input, 6), 2236));
}
}

128
2020/src/bin/day18.rs Normal file
View File

@ -0,0 +1,128 @@
#![feature(test)]
#![allow(clippy::ptr_arg)]
extern crate test;
use aoc2020::common::*;
use itertools::Itertools;
use std::collections::VecDeque;
type Parsed = Vec<Vec<Operation>>;
#[derive(Debug, Copy, Clone, PartialEq)]
enum Operation {
Number(usize),
Multiply,
Add,
OpenParen,
CloseParen,
}
fn read_input() -> String {
read_file(18)
}
fn parse_input(raw: &str) -> Parsed {
raw.lines()
.map(|l| {
l.bytes()
.filter(|&b| b != b' ')
.map(|op| match op {
b'+' => Operation::Add,
b'*' => Operation::Multiply,
b'(' => Operation::OpenParen,
b')' => Operation::CloseParen,
n => Operation::Number((n - b'0') as usize),
})
.collect()
})
.collect()
}
fn part1(parsed: &Parsed) -> usize {
parsed.iter().map(|l| build_stack(l, execute_stack_p1)).sum()
}
fn execute_stack_p1(mut stack: VecDeque<Operation>) -> usize {
while stack.len() > 2 {
let res = match stack.drain(..3).next_tuple() {
Some((Operation::Number(x), Operation::Add, Operation::Number(y))) => Operation::Number(x + y),
Some((Operation::Number(x), Operation::Multiply, Operation::Number(y))) => Operation::Number(x * y),
x => unreachable!("Invalid stack: {:?}", x),
};
stack.push_front(res);
}
if let Operation::Number(n) = stack[0] {
n
} else {
unreachable!()
}
}
fn execute_stack_p2(mut stack: VecDeque<Operation>) -> usize {
while let Some(i) = stack.iter().position(|o| o == &Operation::Add) {
let res = match stack.drain(i - 1..=i + 1).next_tuple() {
Some((Operation::Number(x), Operation::Add, Operation::Number(y))) => Operation::Number(x + y),
x => unreachable!("Invalid stack: {:?}", x),
};
stack.insert(i - 1, res);
}
while stack.len() > 2 {
let res = match stack.drain(..3).next_tuple() {
Some((Operation::Number(x), Operation::Multiply, Operation::Number(y))) => Operation::Number(x * y),
x => unreachable!("Invalid stack: {:?}", x),
};
stack.push_front(res);
}
if let Operation::Number(n) = stack[0] {
n
} else {
unreachable!()
}
}
fn build_stack<F: FnOnce(VecDeque<Operation>) -> usize + Copy>(ops: &[Operation], execute_stack: F) -> usize {
let mut stack = VecDeque::new();
let mut parens = 0;
for i in 0..ops.len() {
match ops[i] {
Operation::OpenParen if parens > 0 => parens += 1,
#[rustfmt::skip]
Operation::CloseParen => if parens > 0 { parens -= 1 } else { break },
// skip the entries that one of the recursive children is already processing
_ if parens > 0 => continue,
Operation::Add => stack.push_back(ops[i]),
Operation::Multiply => stack.push_back(ops[i]),
Operation::Number(n) => stack.push_back(Operation::Number(n)),
Operation::OpenParen => {
stack.push_back(Operation::Number(build_stack(&ops[i + 1..], execute_stack)));
parens += 1;
}
}
}
execute_stack(stack)
}
fn part2(parsed: &Parsed) -> usize {
parsed.iter().map(|l| build_stack(l, execute_stack_p2)).sum()
}
fn main() {
let input = parse_input(&read_input());
println!("Part 1: {}", part1(&input));
println!("Part 2: {}", part2(&input));
}
#[cfg(test)]
mod tests {
use super::*;
use aoc2020::*;
use paste::paste;
use test::black_box;
const TEST_INPUT: &str = "((2 + 4 * 9) * (6 + 9 * 8 + 6) + 6) + 2 + 4 * 2";
test!(part1() == 13632);
test!(part2() == 23340);
bench!(part1() == 510009915468);
bench!(part2() == 321176691637769);
bench_input!(len == 375);
}

187
2020/src/bin/day19.rs Normal file
View File

@ -0,0 +1,187 @@
#![feature(test, bool_to_option)]
extern crate test;
use aoc2020::common::*;
use itertools::Itertools;
#[derive(Debug, PartialEq, Clone)]
enum Rule {
Char(u8),
And(Vec<usize>),
AndOr(Vec<usize>, Vec<usize>),
Any(Vec<usize>),
Useless(usize), // just delegates to another rule and makes parsing annoying
Either(Vec<usize>, Vec<usize>),
}
type Parsed<'a> = (RuleSet, &'a str);
#[derive(Debug, Clone)]
struct RuleSet(Vec<Rule>);
impl RuleSet {
fn and_combinations(&self, s: &str, rules: &[usize], start: usize) -> Vec<usize> {
if let Some(&rule) = rules.first() {
if s.len() <= start {
return vec![];
}
self.matches(&s[start..], self.0[rule].clone())
.into_iter()
.flat_map(|i| self.and_combinations(s, &rules[1..], start + i).into_iter())
.collect()
} else {
vec![start]
}
}
fn matches(&self, s: &str, rule: Rule) -> Vec<usize> {
if s.is_empty() {
return vec![];
}
match rule {
Rule::Char(c) => (s.as_bytes().first() == Some(&c)).then(|| vec![1]).unwrap_or_else(Vec::new),
Rule::And(v) => self.and_combinations(s, v.as_slice(), 0),
Rule::AndOr(v1, v2) => self
.matches(s, Rule::And(v1))
.into_iter()
.chain(self.matches(s, Rule::And(v2)))
.collect(),
Rule::Any(v) => v.into_iter().flat_map(|r| self.matches(s, self.0[r].clone())).collect(),
Rule::Useless(r) => self.matches(s, self.0[r].clone()),
Rule::Either(first, second) => self
.matches(s, Rule::And(first))
.into_iter()
.chain(self.matches(s, Rule::And(second)))
.collect(),
}
}
}
fn read_input() -> String {
read_file(19)
}
fn parse_input(raw: &'_ str) -> Parsed<'_> {
let (rules, inputs) = raw.split_once("\n\n").unwrap();
let rules = RuleSet(
rules
.lines()
.filter_map(|l| l.split_once(": "))
// why isn’t this already sorted like it was in the example?
.sorted_by_key(|t| t.0.parse::<i32>().unwrap())
.map(|(_, r)| match r {
or if or.contains('|') => {
let mut split = or.split(' ').filter(|s| s != &"|").map(|s| s.parse().unwrap());
split
.clone()
.next_tuple()
.map(|(a, b, c, d)| Rule::AndOr(vec![a, b], vec![c, d]))
.or_else(|| split.next_tuple().map(|(a, b)| Rule::Any(vec![a, b])))
.unwrap()
}
chr if chr.contains('"') => Rule::Char(chr.bytes().skip_while(|&b| b != b'"').nth(1).unwrap()),
and if and.contains(' ') => Rule::And(and.split(' ').map(|s| s.parse().unwrap()).collect()),
useless => Rule::Useless(useless.parse().unwrap()),
})
.collect(),
);
(rules, inputs)
}
fn part1((rules, input): &Parsed) -> usize {
input
.lines()
.filter(|l| rules.matches(l, rules.0[0].clone()).contains(&l.len()))
.count()
}
fn part2(parsed: &Parsed) -> usize {
let mut rules = parsed.0.clone();
rules.0[8] = Rule::Either(vec![42], vec![42, 8]);
rules.0[11] = Rule::Either(vec![42, 31], vec![42, 11, 31]);
parsed
.1
.lines()
.filter(|l| rules.matches(l, rules.0[0].clone()).contains(&l.len()))
.count()
}
fn main() {
let raw = read_input();
let input = parse_input(&raw);
println!("Part 1: {}", part1(&input));
println!("Part 2: {}", part2(&input));
}
#[cfg(test)]
mod tests {
use super::*;
use aoc2020::*;
use paste::paste;
use test::black_box;
const TEST_INPUT: &str = r#"0: 8 11
1: "a"
2: 1 24 | 14 4
3: 5 14 | 16 1
4: 1 1
5: 1 14 | 15 1
6: 14 14 | 1 14
7: 14 5 | 1 21
8: 42
9: 14 27 | 1 26
10: 23 14 | 28 1
11: 42 31
12: 24 14 | 19 1
13: 14 3 | 1 12
14: "b"
15: 1 | 14
16: 15 1 | 14 14
17: 14 2 | 1 7
18: 15 15
19: 14 1 | 14 14
20: 14 14 | 1 15
21: 14 1 | 1 14
22: 14 14
23: 25 1 | 22 14
24: 14 1
25: 1 1 | 1 14
26: 14 22 | 1 20
27: 1 6 | 14 18
28: 16 1
29: 29
30: 30
31: 14 17 | 1 13
32: 32
33: 33
34: 34
35: 35
36: 36
37: 37
38: 38
39: 39
40: 40
41: 41
42: 9 14 | 10 1
abbbbbabbbaaaababbaabbbbabababbbabbbbbbabaaaa
bbabbbbaabaabba
babbbbaabbbbbabbbbbbaabaaabaaa
aaabbbbbbaaaabaababaabababbabaaabbababababaaa
bbbbbbbaaaabbbbaaabbabaaa
bbbababbbbaaaaaaaabbababaaababaabab
ababaaaaaabaaab
ababaaaaabbbaba
baabbaaaabbaaaababbaababb
abbbbabbbbaaaababbbbbbaaaababb
aaaaabbaabaaaaababaa
aaaabbaaaabbaaa
aaaabbaabbaaaaaaabbbabbbaaabbaabaaa
babaaabbbaaabaababbaabababaaab
aabbbbbaabbbaaaaaabbbbbababaaaaabbaaabba"#;
test!(part1() == 3);
test!(part2() == 12);
bench!(part1() == 235);
bench!(part2() == 379);
// bench_input!(0.len == 0);
}

View File

@ -7,18 +7,14 @@ pub use position::*;
use itertools::join;
use std::{collections::HashMap, fmt::Display, hash::BuildHasher};
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq)]
pub struct Grid<const D: usize, T: Display + Default> {
pub fields: HashMap<PositionND<D>, T>,
}
impl<const D: usize, T: Display + Default + Copy> Grid<D, T> {
//pub fn get_convert<Pos: Into<P>>(&self, pos: Pos) -> T {
//self.fields.get(&pos.into()).copied().unwrap_or_else(|| T::default())
//}
pub fn get(&self, pos: &PositionND<D>) -> T {
self.fields.get(pos).copied().unwrap_or_else(|| T::default())
self.fields.get(pos).copied().unwrap_or_else(T::default)
}
pub fn insert<Pos: Into<PositionND<D>>>(&mut self, pos: Pos, t: T) {
@ -34,12 +30,6 @@ impl<const D: usize, T: Display + Default> std::iter::FromIterator<(PositionND<D
}
}
// impl<T: Display + Default + Copy> Grid<Position2D, T> {
// fn draw_ascii(&self) -> String {
// draw_ascii(&self.fields)
// }
// }
struct Boundaries {
x_min: i64,
x_max: i64,
@ -48,20 +38,20 @@ struct Boundaries {
}
#[rustfmt::skip]
fn get_boundaries(input: &[&Position2D]) -> Boundaries {
let x_min = input.iter().min_by_key(|k| k.x).map(|p| p.x).unwrap_or(0);
let x_max = input.iter().max_by_key(|k| k.x).map(|p| p.x).unwrap_or(0);
let y_min = input.iter().min_by_key(|k| k.y).map(|p| p.y).unwrap_or(0);
let y_max = input.iter().max_by_key(|k| k.y).map(|p| p.y).unwrap_or(0);
fn get_boundaries(input: &[&PositionND<2>]) -> Boundaries {
let x_min = input.iter().min_by_key(|k| k.points[0]).map(|p| p.points[0]).unwrap_or(0);
let x_max = input.iter().max_by_key(|k| k.points[0]).map(|p| p.points[0]).unwrap_or(0);
let y_min = input.iter().min_by_key(|k| k.points[1]).map(|p| p.points[1]).unwrap_or(0);
let y_max = input.iter().max_by_key(|k| k.points[1]).map(|p| p.points[1]).unwrap_or(0);
Boundaries { x_min, x_max, y_min, y_max }
}
pub fn draw_ascii<T: Display + Default, S: BuildHasher>(coordinates: &HashMap<Position2D, T, S>) -> String {
pub fn draw_ascii<T: Display + Default, S: BuildHasher>(coordinates: &HashMap<PositionND<2>, T, S>) -> String {
let b = get_boundaries(&coordinates.keys().collect::<Vec<_>>());
join(
(b.y_min..=b.y_max).rev().map(|y| {
(b.x_min..=b.x_max)
.map(|x| coordinates.get(&(x, y).into()).unwrap_or(&T::default()).to_string())
.map(|x| coordinates.get(&PositionND { points: [x, y] }).unwrap_or(&T::default()).to_string())
.collect::<String>()
}),
"\n",
@ -71,9 +61,22 @@ pub fn draw_ascii<T: Display + Default, S: BuildHasher>(coordinates: &HashMap<Po
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_add() {
assert_eq!(Position2D { x: 0, y: 2 } + Position2D { x: -1, y: 0 }, (-1, 2).into());
assert_eq!(Position2D { x: 0, y: -1 } + Direction::Up, (0, 0).into());
assert_eq!(PositionND::from([0, 2]) + PositionND::from([-1, 0]), [-1, 2].into());
assert_eq!(PositionND::from([0, -1]) + PositionND::from(Direction::Up), [0, 0].into());
}
#[test]
fn test_sub() {
assert_eq!(PositionND::from([0, 2]) - PositionND::from([-1, 0]), [1, 2].into());
assert_eq!(PositionND::from([0, -1]) - PositionND::from([0, -1]), [0, 0].into());
}
#[test]
fn test_mul() {
assert_eq!(PositionND::from([0, 2]) * 5, [0, 10].into());
assert_eq!(PositionND::from([0, -1]) * -2, [0, 2].into());
}
}

View File

@ -1,8 +1,8 @@
extern crate test;
use super::direction::*;
use impl_ops::*;
use itertools::iproduct;
use lazy_static::lazy_static;
use std::{
convert::TryInto, hash::Hash, ops, ops::{Add, AddAssign}
convert::TryInto, hash::Hash, ops::{Add, Mul, Sub}
};
pub trait Position
@ -11,30 +11,9 @@ where Self: Sized + Hash + PartialEq + Eq + Clone + Copy
fn neighbors(&self) -> Vec<Self>;
}
#[derive(Hash, PartialEq, Eq, Debug, Clone, Copy)]
pub struct Position2D {
pub x: i64,
pub y: i64,
}
#[derive(Hash, PartialEq, Eq, Debug, Clone, Copy)]
pub struct Position3D {
pub x: i64,
pub y: i64,
pub z: i64,
}
#[derive(Hash, PartialEq, Eq, Debug, Clone, Copy)]
pub struct Position4D {
pub x: i64,
pub y: i64,
pub z: i64,
pub w: i64,
}
#[derive(Hash, PartialEq, Eq, Debug, Clone, Copy)]
pub struct PositionND<const DIMS: usize> {
points: [i64; DIMS],
pub points: [i64; DIMS],
}
impl<const D: usize, I> From<[I; D]> for PositionND<D>
@ -49,7 +28,16 @@ where I: TryInto<i64> + Copy
}
}
const fn num_neighbors(d: usize) -> usize {
// because calling .unwrap() on a TryInto result isn’t possible without trait bounds on the
// associated Error type.
fn unwrap_number_result<I: TryInto<i64>>(i: I) -> i64 {
match i.try_into() {
Ok(i) => i,
_ => panic!("Bad coordinate"),
}
}
pub const fn num_neighbors(d: usize) -> usize {
3usize.pow(d as u32) - 1
}
@ -66,233 +54,251 @@ impl<const DIMS: usize> PositionND<DIMS> {
PositionND { points }
}
// until I can figure out how to properly do that, here’s a “good enough” solution :^)
pub fn neighbors(&self) -> [PositionND<DIMS>; num_neighbors(DIMS)]
where
[PositionND<DIMS>; num_neighbors(DIMS)]: Sized,
{
let mut out = [PositionND::zero(); num_neighbors(DIMS)];
match DIMS {
2 => {
for (i, n) in iproduct!((-1..=1), (-1..=1))
.filter(|t| t != &(0, 0))
.map(|(x, y)| PositionND::<DIMS>::from_padded(&[x, y]))
.enumerate()
{
out[i] = n;
where [PositionND<DIMS>; num_neighbors(DIMS) + 1]: Sized {
// Day 17 gets 25% faster if we cheat by using these cached vectors
if DIMS < 5 {
return match DIMS {
1 => {
let mut out = [*self; num_neighbors(DIMS)];
for (out, dir) in out.iter_mut().zip(NEIGHBOR_VECTORS_1D.iter()) {
*out = *out + PositionND::from_padded(dir);
}
out
}
}
3 => {
for (i, n) in iproduct!((-1..=1), (-1..=1), (-1..=1))
.filter(|t| t != &(0, 0, 0))
.map(|(x, y, z)| PositionND::<DIMS>::from_padded(&[x, y, z]))
.enumerate()
{
out[i] = n;
2 => {
let mut out = [*self; num_neighbors(DIMS)];
for (out, dir) in out.iter_mut().zip(NEIGHBOR_VECTORS_2D.iter()) {
*out = *out + PositionND::from_padded(dir);
}
out
}
}
4 => {
for (i, n) in iproduct!((-1..=1), (-1..=1), (-1..=1), (-1..=1))
.filter(|t| t != &(0, 0, 0, 0))
.map(|(x, y, z, w)| PositionND::<DIMS>::from_padded(&[x, y, z, w]))
.enumerate()
{
out[i] = n;
3 => {
let mut out = [*self; num_neighbors(DIMS)];
for (out, dir) in out.iter_mut().zip(NEIGHBOR_VECTORS_3D.iter()) {
*out = *out + PositionND::from_padded(dir);
}
out
}
}
_ => unimplemented!(),
4 => {
let mut out = [*self; num_neighbors(DIMS)];
for (out, dir) in out.iter_mut().zip(NEIGHBOR_VECTORS_4D.iter()) {
*out = *out + PositionND::from_padded(dir);
}
out
}
_ => unreachable!(),
};
}
let ns = neighbor_vectors::<DIMS>();
let mut out = [*self; num_neighbors(DIMS)];
for (out, dir) in out.iter_mut().zip(IntoIterator::into_iter(ns).filter(|n| n != &[0; DIMS])) {
*out = *out + PositionND::from(dir);
}
out
}
}
// Maybe one day :(
/*
fn neighbors_inner<const D: usize>(existing: [i64; DIMS]) -> [[i64; DIMS]; (DIMS - D).pow(3)] {
let out = [[0; DIMS]; (DIMS - D).pow(3)];
let mut index = 0;
for i in -1..=1 {
existing[D] = i;
// I guess that means no recursion with const generics?
for xs in neighbors_inner(existing.clone()) {
out[index] = xs;
index += 1;
fn build_neighbor_cache<const D: usize>() -> Vec<[i64; D]>
where [(); num_neighbors(D) + 1]: {
IntoIterator::into_iter(neighbor_vectors::<D>()).filter(|n| n != &[0; D]).collect()
}
lazy_static! {
static ref NEIGHBOR_VECTORS_1D: Vec<[i64; 1]> = build_neighbor_cache::<1>();
static ref NEIGHBOR_VECTORS_2D: Vec<[i64; 2]> = build_neighbor_cache::<2>();
static ref NEIGHBOR_VECTORS_3D: Vec<[i64; 3]> = build_neighbor_cache::<3>();
static ref NEIGHBOR_VECTORS_4D: Vec<[i64; 4]> = build_neighbor_cache::<4>();
}
#[macro_export]
macro_rules! dim {
($d: expr) => {{
let mut out = [[0; D]; num_neighbors(D) + 1];
let mut i = 0;
for offset in -1..=1 {
for inner in neighbor_vectors::<$d>() {
out[i][0] = offset;
let mut j = 1;
for e in inner {
out[i][j] = e;
j += 1;
}
i += 1;
}
}
out
}};
}
fn neighbor_vectors<const D: usize>() -> [[i64; D]; num_neighbors(D) + 1]
where
{
// I would love to just call neighbor_vectors::<D-1>(), but it seems to be impossible to get the
// correct constraints for that.
match D {
0 => unreachable!(),
1 => {
let mut out = [[0; D]; num_neighbors(D) + 1];
out[0] = [-1; D];
out[1] = [0; D];
out[2] = [1; D];
out
}
2 => dim!(1),
3 => dim!(2),
4 => dim!(3),
5 => dim!(4),
6 => dim!(5),
7 => dim!(6),
// Adding more causes a stackoverflow. How curious.
_ => unimplemented!(),
}
}
impl<const D: usize> Mul<i64> for PositionND<D> {
type Output = PositionND<D>;
fn mul(mut self, rhs: i64) -> Self::Output {
for p in self.points.iter_mut() {
*p *= rhs;
}
self
}
*/
}
impl<const D: usize> Add<PositionND<D>> for PositionND<D> {
type Output = PositionND<D>;
fn add(self, rhs: PositionND<D>) -> Self::Output {
let mut points = [0; D];
for i in 0..D {
points[i] = self.points[i] + rhs.points[i];
fn add(mut self, rhs: PositionND<D>) -> Self::Output {
for (x, y) in self.points.iter_mut().zip(rhs.points) {
*x += y;
}
PositionND { points }
self
}
}
mod p2d {
use super::*;
impl<const D: usize> Sub<PositionND<D>> for PositionND<D> {
type Output = PositionND<D>;
impl From<Direction> for Position2D {
fn from(d: Direction) -> Self {
match d {
Direction::Up => Position2D::from((0, 1)),
Direction::Right => Position2D::from((1, 0)),
Direction::Left => Position2D::from((-1, 0)),
Direction::Down => Position2D::from((0, -1)),
}
fn sub(mut self, rhs: PositionND<D>) -> Self::Output {
for (x, y) in self.points.iter_mut().zip(rhs.points) {
*x -= y;
}
self
}
}
impl From<Direction> for PositionND<2> {
fn from(d: Direction) -> Self {
match d {
Direction::Up => PositionND::from([0, 1]),
Direction::Right => PositionND::from([1, 0]),
Direction::Left => PositionND::from([-1, 0]),
Direction::Down => PositionND::from([0, -1]),
}
}
}
impl Position for Position2D {
fn neighbors(&self) -> Vec<Position2D> {
vec![
*self + Direction::Up + Direction::Left,
*self + Direction::Up,
*self + Direction::Up + Direction::Right,
*self + Direction::Left,
*self + Direction::Right,
*self + Direction::Down + Direction::Left,
*self + Direction::Down,
*self + Direction::Down + Direction::Right,
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_neighbors_2d() {
let p = PositionND { points: [0, 0] };
let n = p.neighbors();
assert_eq!(
n,
[
PositionND { points: [-1, -1] },
PositionND { points: [-1, 0] },
PositionND { points: [-1, 1] },
PositionND { points: [0, -1] },
PositionND { points: [0, 1] },
PositionND { points: [1, -1] },
PositionND { points: [1, 0] },
PositionND { points: [1, 1] },
]
}
);
let p = PositionND { points: [1, 1] };
let n = p.neighbors();
assert_eq!(
n,
[
PositionND { points: [0, 0] },
PositionND { points: [0, 1] },
PositionND { points: [0, 2] },
PositionND { points: [1, 0] },
PositionND { points: [1, 2] },
PositionND { points: [2, 0] },
PositionND { points: [2, 1] },
PositionND { points: [2, 2] },
]
)
}
impl<I: Into<i64>> From<(I, I)> for Position2D {
fn from((x, y): (I, I)) -> Position2D {
Position2D { x: x.into(), y: y.into() }
}
#[test]
fn test_neighbors_3d() {
let p = PositionND { points: [0, 0, 0] };
let n = p.neighbors();
assert_eq!(
n,
[
PositionND { points: [-1, -1, -1] },
PositionND { points: [-1, -1, 0] },
PositionND { points: [-1, -1, 1] },
PositionND { points: [-1, 0, -1] },
PositionND { points: [-1, 0, 0] },
PositionND { points: [-1, 0, 1] },
PositionND { points: [-1, 1, -1] },
PositionND { points: [-1, 1, 0] },
PositionND { points: [-1, 1, 1] },
PositionND { points: [0, -1, -1] },
PositionND { points: [0, -1, 0] },
PositionND { points: [0, -1, 1] },
PositionND { points: [0, 0, -1] },
PositionND { points: [0, 0, 1] },
PositionND { points: [0, 1, -1] },
PositionND { points: [0, 1, 0] },
PositionND { points: [0, 1, 1] },
PositionND { points: [1, -1, -1] },
PositionND { points: [1, -1, 0] },
PositionND { points: [1, -1, 1] },
PositionND { points: [1, 0, -1] },
PositionND { points: [1, 0, 0] },
PositionND { points: [1, 0, 1] },
PositionND { points: [1, 1, -1] },
PositionND { points: [1, 1, 0] },
PositionND { points: [1, 1, 1] },
]
);
}
impl_op!(+|a: Position2D, b: Direction| -> Position2D { a + Position2D::from(b) });
impl_op!(-|a: Position2D, b: Direction| -> Position2D { a - Position2D::from(b) });
impl_op!(*|a: Position2D, b: i64| -> Position2D { Position2D { x: a.x * b, y: a.y * b } });
impl_op!(+|a: Position2D, b: Position2D| -> Position2D {
Position2D {
x: a.x + b.x,
y: a.y + b.y
}
});
impl_op!(-|a: Position2D, b: Position2D| -> Position2D {
Position2D {
x: a.x - b.x,
y: a.y - b.y,
}
});
impl AddAssign<Direction> for Position2D {
fn add_assign(&mut self, rhs: Direction) {
*self = *self + rhs;
}
#[test]
fn test_neighbor_vectors() {
let n = neighbor_vectors::<2>();
assert_eq!(n, [[-1, -1], [-1, 0], [-1, 1], [0, -1], [0, 0], [0, 1], [1, -1], [1, 0], [1, 1],]);
}
impl AddAssign for Position2D {
fn add_assign(&mut self, rhs: Position2D) {
*self = *self + rhs;
}
}
}
mod p3d {
use super::*;
impl Position for Position3D {
fn neighbors(&self) -> Vec<Position3D> {
iproduct!((-1..=1), (-1..=1), (-1..=1))
.filter(|t| t != &(0, 0, 0))
.map(|(x, y, z)| *self + Position3D::from((x, y, z)))
.collect()
}
}
impl<I> From<(I, I, I)> for Position3D
where I: TryInto<i64>
{
fn from((x, y, z): (I, I, I)) -> Position3D {
Position3D {
x: unwrap_number_result(x),
y: unwrap_number_result(y),
z: unwrap_number_result(z),
}
}
}
impl_op!(-|a: Position3D, b: Position3D| -> Position3D {
Position3D {
x: a.x - b.x,
y: a.y - b.y,
z: a.z - b.z,
}
});
impl_op!(+|a: Position3D, b: Position3D| -> Position3D {
Position3D {
x: a.x + b.x,
y: a.y + b.y,
z: a.z + b.z,
}
});
}
mod p4d {
use super::*;
impl Position for Position4D {
fn neighbors(&self) -> Vec<Position4D> {
iproduct!((-1..=1), (-1..=1), (-1..=1), (-1..=1))
.filter(|t| t != &(0, 0, 0, 0))
.map(|(x, y, z, w)| *self + Position4D::from((x, y, z, w)))
.collect()
}
}
impl<I> From<(I, I, I, I)> for Position4D
where I: TryInto<i64>
{
fn from((x, y, z, w): (I, I, I, I)) -> Position4D {
Position4D {
x: unwrap_number_result(x),
y: unwrap_number_result(y),
z: unwrap_number_result(z),
w: unwrap_number_result(w),
}
}
}
impl_op!(-|a: Position4D, b: Position4D| -> Position4D {
Position4D {
x: a.x - b.x,
y: a.y - b.y,
z: a.z - b.z,
w: a.w - b.w,
}
});
impl_op!(+|a: Position4D, b: Position4D| -> Position4D {
Position4D {
x: a.x + b.x,
y: a.y + b.y,
z: a.z + b.z,
w: a.w + b.w,
}
});
}
// because calling .unwrap() on a TryInto result isn’t possible without trait bounds on the
// associated Error type.
fn unwrap_number_result<I: TryInto<i64>>(i: I) -> i64 {
match i.try_into() {
Ok(i) => return i,
_ => panic!("Bad coordinate"),
#[bench]
fn bench_neighbor_vectors_2d(b: &mut test::Bencher) {
b.iter(|| test::black_box(neighbor_vectors::<2>()))
}
#[bench]
fn bench_neighbor_vectors_3d(b: &mut test::Bencher) {
b.iter(|| test::black_box(neighbor_vectors::<3>()))
}
#[bench]
fn bench_neighbor_vectors_4d(b: &mut test::Bencher) {
b.iter(|| test::black_box(neighbor_vectors::<4>()))
}
#[bench]
fn bench_neighbor_vectors_5d(b: &mut test::Bencher) {
b.iter(|| test::black_box(neighbor_vectors::<5>()))
}
}

View File

@ -1,5 +1,5 @@
#![allow(incomplete_features)]
#![feature(const_generics, const_evaluatable_checked)]
#![feature(generic_const_exprs, test)]
pub mod common;
pub mod grid;
pub mod teststuff;

14
2021/Cargo.toml Normal file
View File

@ -0,0 +1,14 @@
[package]
name = "aoc2021"
version = "0.1.0"
edition = "2021"
[dependencies]
fnv = "1.0.7"
impl_ops = "0.1.1"
itertools = "0.10"
paste = "1.0"
test-case = "1.2.1"
[profile.bench]
lto = true

2000
2021/inputs/day01 Normal file

File diff suppressed because it is too large Load Diff

1000
2021/inputs/day02 Normal file

File diff suppressed because it is too large Load Diff

1000
2021/inputs/day03 Normal file

File diff suppressed because it is too large Load Diff

601
2021/inputs/day04 Normal file
View File

@ -0,0 +1,601 @@
46,12,57,37,14,78,31,71,87,52,64,97,10,35,54,36,27,84,80,94,99,22,0,11,30,44,86,59,66,7,90,21,51,53,92,8,76,41,39,77,42,88,29,24,60,17,68,13,79,67,50,82,25,61,20,16,6,3,81,19,85,9,28,56,75,96,2,26,1,62,33,63,32,73,18,48,43,65,98,5,91,69,47,4,38,23,49,34,55,83,93,45,72,95,40,15,58,74,70,89
37 72 60 35 89
32 49 4 77 82
30 26 27 63 88
29 43 16 34 58
48 33 96 79 94
41 94 77 43 87
2 17 82 96 25
95 49 32 12 9
59 33 67 71 64
88 54 93 85 30
78 84 73 64 81
6 66 54 21 15
72 88 69 5 93
11 96 38 95 44
13 41 94 55 48
5 14 2 82 33
56 26 0 84 92
8 95 24 54 25
68 67 15 85 47
20 91 36 13 88
39 26 33 65 32
78 72 80 51 0
35 64 60 18 31
93 59 83 54 74
86 5 9 98 69
0 8 20 18 70
5 29 65 21 57
68 61 83 63 51
91 73 77 75 80
35 62 16 32 10
51 78 58 67 93
50 14 99 5 31
6 21 48 30 83
22 33 23 1 34
2 72 57 54 42
15 68 4 24 49
12 9 74 88 51
91 19 50 76 75
80 84 23 17 53
67 42 22 85 36
41 78 11 69 9
90 25 98 65 77
97 53 37 84 89
58 63 5 55 1
24 10 74 20 82
42 19 95 89 49
61 31 50 76 3
34 47 32 69 86
78 68 99 11 91
55 12 73 45 23
24 53 95 64 14
40 29 71 57 97
62 70 25 22 2
88 68 33 82 59
72 38 76 78 43
73 36 84 90 40
16 4 57 9 29
38 97 46 51 83
86 88 99 44 32
54 49 37 43 62
18 66 17 49 27
24 93 91 87 72
54 37 77 43 10
88 80 60 15 79
47 68 12 2 69
9 23 13 57 68
38 97 63 88 98
96 62 65 82 58
61 83 29 47 40
21 86 20 16 56
27 90 37 97 52
14 96 76 21 79
0 43 63 81 56
42 62 23 55 74
45 72 77 44 47
8 78 63 24 87
9 23 12 17 68
36 83 45 61 50
84 77 18 86 37
31 26 19 49 94
72 84 59 48 40
92 98 35 1 80
83 15 85 63 39
2 64 58 13 20
29 88 60 12 74
21 94 52 6 4
89 70 39 23 64
96 87 31 54 14
88 35 83 13 56
84 10 98 48 68
70 33 48 21 37
91 95 65 38 77
92 14 26 96 60
12 6 73 13 81
54 55 2 45 80
60 11 67 95 28
5 32 0 71 12
47 78 13 54 43
49 89 82 66 77
26 53 19 79 3
81 9 53 72 29
56 35 60 44 45
42 94 96 88 64
15 92 4 6 14
97 11 17 61 63
24 43 33 9 34
36 28 69 35 7
47 4 14 82 38
11 1 52 0 49
93 87 98 41 5
37 79 99 34 77
38 26 25 95 70
28 78 40 33 86
41 57 96 10 24
9 74 72 50 81
18 96 52 29 61
38 90 1 48 51
78 11 27 55 97
33 21 87 93 67
79 46 94 45 2
27 63 6 90 10
3 60 24 5 89
78 72 76 54 8
33 22 87 51 58
4 37 64 91 43
63 73 87 80 89
29 14 95 48 3
71 55 69 9 67
30 99 19 2 86
26 72 88 85 37
12 57 81 78 40
35 4 55 15 39
33 45 25 60 70
86 79 88 52 3
90 20 28 59 85
92 51 98 47 99
41 78 65 4 46
19 87 39 89 17
12 23 36 29 44
6 82 71 16 37
8 34 81 67 80
83 92 13 11 41
39 89 93 49 43
20 69 3 74 76
44 72 68 70 45
66 39 94 98 28
72 4 25 77 76
56 41 84 59 40
36 87 18 44 73
29 45 79 55 95
45 91 2 92 16
21 47 86 81 56
31 11 62 5 95
39 1 30 65 33
42 60 17 18 83
86 11 77 30 43
51 88 73 98 94
72 63 38 56 10
57 92 49 7 41
79 75 34 23 54
56 95 3 43 65
39 62 93 19 27
61 41 99 96 52
4 92 77 98 70
16 54 11 17 57
6 63 10 71 58
64 70 50 92 0
7 14 99 45 26
78 17 44 46 73
77 38 62 53 37
31 82 67 55 27
57 58 84 6 15
14 41 49 8 85
12 32 91 42 19
23 1 87 54 29
54 60 43 26 4
78 17 28 67 5
87 93 90 71 22
13 30 16 21 85
55 74 52 1 29
50 16 70 32 33
6 94 52 66 22
97 64 98 72 39
27 69 99 34 26
36 91 37 21 14
7 97 64 28 18
85 80 14 37 34
72 1 22 58 73
53 3 68 17 0
29 44 56 95 32
30 66 93 24 92
48 80 79 86 27
89 13 62 94 81
70 65 61 8 54
96 97 20 90 34
87 76 4 7 43
92 55 80 25 62
79 6 88 35 30
10 32 5 45 17
36 27 33 68 63
72 69 27 88 41
34 53 42 84 3
58 18 22 66 65
9 47 85 12 62
73 90 91 57 33
67 16 50 58 52
68 70 84 98 69
4 72 9 64 0
93 97 39 26 5
3 37 79 7 82
61 57 88 54 70
77 8 94 81 63
39 48 18 13 10
55 23 27 4 73
3 5 64 0 96
62 27 0 52 19
28 57 83 25 41
5 59 24 33 80
37 85 2 86 43
22 94 50 8 20
54 32 34 47 87
71 22 43 85 24
11 68 58 36 46
35 56 61 67 18
70 23 72 5 59
3 96 41 45 32
68 2 56 28 24
87 38 40 75 26
53 64 73 80 81
54 88 20 6 18
64 55 51 96 47
59 35 49 67 71
36 91 61 76 68
6 94 20 8 27
60 88 45 7 82
87 94 51 91 1
96 60 28 97 37
26 27 74 53 35
88 89 11 77 8
73 47 18 59 6
46 50 19 36 83
69 28 4 44 70
45 20 63 27 1
53 38 9 47 67
91 31 79 73 86
45 3 98 91 60
40 7 78 34 83
52 73 59 13 4
38 15 82 86 79
42 11 17 20 62
65 86 38 20 72
78 45 73 74 25
62 42 24 75 3
81 8 35 50 51
44 11 94 85 57
13 86 55 65 96
53 18 43 76 20
41 14 32 52 38
90 59 80 68 7
2 23 92 39 50
96 62 85 24 14
37 5 11 91 45
61 28 23 34 77
43 48 20 0 21
10 35 2 26 97
89 5 40 34 84
90 6 72 68 10
13 64 71 31 76
53 60 9 92 62
69 98 8 50 3
17 86 10 75 79
67 94 78 40 56
11 85 82 50 46
53 39 22 9 61
59 73 72 33 45
65 22 18 96 95
55 86 67 52 69
10 2 60 83 98
43 61 87 88 66
41 24 8 84 33
31 53 98 70 91
33 34 48 83 9
40 39 29 71 65
69 10 62 30 4
52 21 11 93 75
8 94 53 85 89
13 84 58 59 29
97 7 21 25 96
45 54 34 22 63
37 17 49 68 67
86 87 84 24 10
82 32 36 59 50
8 62 79 71 43
49 23 85 69 58
21 66 42 25 56
65 88 43 25 19
26 36 63 5 6
37 54 75 1 38
95 46 83 66 28
4 90 80 99 85
78 83 7 77 34
27 92 93 96 82
40 95 52 32 43
17 28 69 41 85
21 65 39 58 19
11 84 28 90 36
74 4 62 5 46
22 8 45 40 98
12 6 30 9 82
37 2 53 29 41
17 65 31 86 57
73 16 24 67 53
60 93 88 45 26
14 80 94 7 44
55 78 49 8 82
95 38 81 25 76
29 13 83 47 12
17 69 4 43 28
63 84 39 52 34
1 97 41 88 8
70 40 16 83 3
15 49 20 74 48
71 30 21 28 84
29 10 97 1 18
57 50 63 35 69
40 13 67 9 41
71 76 8 54 24
15 97 92 49 96
61 34 23 81 31
11 38 48 37 86
77 36 32 75 7
38 18 84 26 2
19 13 99 83 20
35 51 74 6 27
71 48 15 66 69
91 57 41 3 99
74 55 81 77 43
36 52 47 49 45
85 65 5 38 50
90 68 70 16 0
1 90 28 86 27
73 36 67 11 14
71 31 10 65 55
78 21 16 69 12
87 24 33 83 68
90 17 10 84 45
5 68 69 27 92
6 63 98 3 46
94 48 59 34 43
39 88 12 33 73
12 31 33 98 63
65 51 94 83 92
41 38 84 91 66
47 28 76 54 3
48 36 11 13 27
51 84 96 16 8
64 26 74 30 48
29 41 68 97 87
9 38 1 15 39
98 3 45 53 14
53 70 90 95 86
35 22 85 45 66
93 0 83 30 88
64 57 68 36 3
5 51 19 20 89
9 36 69 46 44
37 7 99 57 45
79 10 86 58 30
49 98 52 90 27
14 51 88 60 81
73 97 91 19 48
76 43 18 83 67
62 9 11 82 55
24 17 33 53 22
75 8 56 1 21
27 97 53 0 89
30 70 3 80 54
56 93 40 64 35
46 82 1 44 65
6 59 45 32 34
87 58 73 45 69
24 49 89 71 83
94 6 53 68 50
28 25 88 47 0
36 13 31 18 55
52 63 37 66 9
34 77 57 6 55
85 80 97 78 74
95 75 67 96 29
22 73 92 69 47
79 97 80 36 73
38 77 35 32 53
2 37 29 6 89
78 91 15 47 34
11 52 64 84 0
69 30 21 99 46
72 4 15 25 42
67 98 81 91 63
70 20 57 65 14
0 78 19 8 87
20 4 98 33 85
76 17 94 65 35
95 69 72 52 71
23 25 50 38 27
43 49 96 53 99
16 27 34 65 36
10 40 84 60 82
80 2 54 67 70
52 94 79 17 56
5 14 77 91 88
32 90 50 66 39
30 16 14 20 10
4 42 88 59 12
75 84 54 51 48
33 24 13 89 43
78 42 34 65 51
75 72 3 99 61
15 50 59 8 89
71 18 9 54 53
43 39 97 56 19
50 43 83 4 30
89 97 58 35 39
11 24 61 41 25
87 99 93 15 34
31 57 3 45 44
70 21 63 24 38
34 23 88 7 51
43 18 76 46 49
60 78 47 8 12
11 66 98 25 74
30 17 23 10 92
12 85 69 81 91
47 80 28 29 58
73 44 77 50 32
76 54 78 75 60
71 53 86 48 98
90 37 79 8 56
99 42 97 36 15
31 85 34 10 40
43 89 57 72 51
48 0 65 55 90
45 76 69 97 4
42 52 46 77 56
64 62 68 35 72
71 10 27 30 16
41 69 63 88 57
25 56 23 78 80
8 92 59 66 97
48 61 77 15 14
87 47 91 12 71
51 46 15 2 49
48 33 23 16 4
80 41 43 59 83
62 13 20 63 85
99 30 7 87 8
69 80 96 43 47
61 75 45 62 15
32 22 91 83 58
82 13 50 52 8
89 20 63 73 14
40 2 96 52 73
25 27 26 43 34
60 38 80 78 5
83 63 48 10 66
97 46 53 74 86
46 7 0 69 15
79 19 85 27 73
63 45 5 49 54
93 29 84 28 66
72 23 99 8 33
20 72 85 99 49
69 0 10 52 23
88 56 28 67 21
16 91 83 54 81
14 73 32 30 59
31 52 63 12 3
96 20 82 6 89
55 38 8 95 40
5 60 84 81 75
51 14 65 27 61
46 93 1 47 76
8 98 7 16 63
44 78 17 14 92
42 62 20 12 68
56 3 74 6 21
8 94 11 40 44
43 92 78 91 18
75 80 12 54 26
67 9 45 22 21
86 1 90 36 30
21 19 83 90 8
50 28 45 65 75
59 88 25 29 70
58 23 0 95 49
36 68 76 78 66
77 28 43 56 97
73 71 8 72 46
23 25 70 69 41
90 17 34 67 48
32 75 81 63 21

500
2021/inputs/day05 Normal file
View File

@ -0,0 +1,500 @@
456,846 -> 221,846
980,926 -> 73,19
682,930 -> 562,930
766,592 -> 274,100
247,685 -> 247,21
106,800 -> 635,800
953,340 -> 135,340
293,223 -> 293,12
454,196 -> 454,463
886,766 -> 164,766
592,590 -> 192,590
436,982 -> 436,545
731,571 -> 420,260
741,11 -> 466,11
727,541 -> 579,541
341,553 -> 25,553
942,470 -> 942,196
203,600 -> 203,647
965,595 -> 949,611
554,306 -> 554,401
902,438 -> 902,728
864,609 -> 525,270
187,790 -> 187,323
956,950 -> 427,950
847,554 -> 422,554
935,900 -> 701,900
192,854 -> 866,180
512,946 -> 543,915
978,979 -> 491,979
708,61 -> 708,878
738,508 -> 282,52
23,25 -> 841,843
204,750 -> 204,797
703,500 -> 703,419
14,311 -> 694,311
646,301 -> 785,301
397,168 -> 439,168
680,931 -> 561,812
540,448 -> 90,448
706,668 -> 91,53
848,319 -> 318,319
198,948 -> 198,307
686,58 -> 686,541
867,234 -> 867,498
134,125 -> 134,688
824,566 -> 53,566
437,167 -> 276,167
94,65 -> 638,609
36,971 -> 971,36
494,330 -> 494,197
920,438 -> 920,364
698,84 -> 49,733
59,842 -> 59,876
328,577 -> 328,677
757,701 -> 134,78
466,274 -> 135,605
81,925 -> 988,18
40,142 -> 882,984
50,96 -> 882,928
782,47 -> 782,427
247,599 -> 24,599
112,812 -> 191,733
487,198 -> 144,198
327,663 -> 327,756
117,76 -> 688,76
530,71 -> 530,958
558,602 -> 671,489
677,830 -> 677,556
529,669 -> 349,669
336,966 -> 341,971
20,31 -> 851,862
423,880 -> 423,573
521,657 -> 552,657
412,822 -> 18,428
423,311 -> 423,105
381,614 -> 705,614
521,248 -> 394,121
286,47 -> 286,403
286,27 -> 711,452
347,61 -> 489,61
760,454 -> 760,954
746,573 -> 911,573
839,933 -> 839,776
124,815 -> 290,649
577,848 -> 419,848
393,206 -> 410,206
364,755 -> 881,755
788,68 -> 788,215
94,798 -> 192,798
292,250 -> 453,250
601,545 -> 293,237
438,923 -> 438,655
70,757 -> 887,757
184,402 -> 818,402
586,49 -> 103,49
202,315 -> 735,315
534,504 -> 534,523
367,236 -> 367,736
24,163 -> 24,240
185,426 -> 634,875
485,189 -> 39,189
556,30 -> 374,30
969,821 -> 676,528
254,435 -> 254,43
290,615 -> 741,164
345,601 -> 120,826
224,641 -> 887,641
190,716 -> 581,325
552,646 -> 552,393
413,177 -> 413,103
397,900 -> 360,900
138,980 -> 138,55
909,891 -> 909,593
926,986 -> 79,139
954,67 -> 53,968
180,30 -> 595,30
823,165 -> 823,660
285,176 -> 375,176
915,826 -> 184,95
735,230 -> 667,230
934,865 -> 917,865
48,602 -> 737,602
477,319 -> 385,411
981,17 -> 11,987
458,401 -> 24,401
118,415 -> 849,415
176,678 -> 176,852
567,753 -> 567,37
285,868 -> 830,323
555,623 -> 822,623
522,546 -> 674,546
880,21 -> 23,878
591,103 -> 591,407
434,64 -> 434,401
245,968 -> 275,968
726,510 -> 450,786
768,366 -> 768,738
488,745 -> 488,94
675,674 -> 675,705
618,237 -> 265,237
802,709 -> 802,59
144,696 -> 144,542
547,381 -> 547,799
78,667 -> 78,916
409,271 -> 302,271
294,694 -> 938,50
140,571 -> 97,571
682,875 -> 682,534
748,816 -> 748,183
84,622 -> 84,258
485,696 -> 582,599
909,233 -> 954,233
203,711 -> 203,350
335,904 -> 455,904
578,778 -> 578,21
830,954 -> 902,954
78,252 -> 78,682
920,220 -> 684,220
309,301 -> 104,301
270,795 -> 270,919
906,479 -> 304,479
627,164 -> 627,986
122,960 -> 915,167
664,916 -> 770,810
692,810 -> 826,810
981,951 -> 192,162
183,423 -> 809,423
632,464 -> 567,464
94,266 -> 94,587
261,770 -> 569,770
51,403 -> 466,818
631,645 -> 187,645
141,238 -> 141,145
357,21 -> 173,21
138,248 -> 839,949
889,957 -> 807,957
399,431 -> 105,725
548,331 -> 548,821
790,844 -> 43,97
675,671 -> 221,671
874,143 -> 620,397
205,435 -> 205,546
521,434 -> 822,133
141,86 -> 257,86
427,28 -> 290,165
49,694 -> 567,694
846,344 -> 266,924
425,910 -> 433,918
956,498 -> 485,27
798,498 -> 798,634
879,13 -> 766,126
737,475 -> 737,425
338,473 -> 425,386
510,615 -> 214,319
758,415 -> 758,490
969,208 -> 239,938
917,188 -> 917,528
34,820 -> 806,820
85,633 -> 857,633
262,355 -> 262,748
373,784 -> 971,186
146,577 -> 60,663
613,570 -> 613,199
300,319 -> 300,108
764,171 -> 764,17
555,921 -> 555,825
241,197 -> 770,197
600,832 -> 600,807
934,987 -> 20,73
960,730 -> 837,730
976,50 -> 46,980
829,834 -> 153,158
785,835 -> 785,58
586,633 -> 689,736
804,250 -> 348,706
226,539 -> 16,539
411,940 -> 98,940
289,589 -> 893,589
738,616 -> 738,55
225,54 -> 542,54
793,246 -> 303,736
332,752 -> 984,100
413,18 -> 839,444
840,122 -> 840,233
989,970 -> 215,196
329,361 -> 573,605
242,537 -> 242,619
943,898 -> 943,535
469,865 -> 501,833
226,717 -> 196,687
819,803 -> 712,803
532,663 -> 532,672
61,931 -> 940,52
623,218 -> 274,567
281,326 -> 281,790
815,176 -> 679,176
790,862 -> 942,710
18,771 -> 18,514
479,377 -> 309,377
704,402 -> 704,150
961,335 -> 492,335
745,829 -> 745,477
556,543 -> 771,543
832,336 -> 917,251
742,755 -> 742,174
206,735 -> 493,735
151,216 -> 312,55
445,157 -> 615,157
781,143 -> 781,76
833,717 -> 514,398
357,14 -> 357,36
771,405 -> 771,422
662,886 -> 169,886
689,990 -> 22,990
680,445 -> 379,445
92,369 -> 502,779
64,948 -> 64,363
295,957 -> 976,276
113,920 -> 634,399
542,662 -> 305,899
566,514 -> 566,645
528,106 -> 549,106
205,367 -> 821,367
313,105 -> 313,928
532,177 -> 532,664
862,773 -> 905,816
800,796 -> 911,796
870,80 -> 11,939
188,900 -> 154,900
420,509 -> 520,609
540,863 -> 28,863
31,72 -> 78,72
823,648 -> 503,648
879,252 -> 606,252
677,117 -> 677,507
743,303 -> 196,850
220,491 -> 220,891
216,815 -> 577,815
540,819 -> 745,819
152,721 -> 382,721
280,745 -> 985,745
479,367 -> 358,488
913,413 -> 649,413
40,678 -> 817,678
467,533 -> 467,214
132,68 -> 843,779
519,109 -> 669,259
619,791 -> 221,791
114,622 -> 628,622
951,636 -> 866,636
172,569 -> 775,569
244,972 -> 173,972
283,64 -> 739,520
68,604 -> 68,156
529,30 -> 529,925
813,883 -> 137,883
893,231 -> 629,231
673,658 -> 673,389
725,899 -> 218,899
317,318 -> 105,318
82,706 -> 100,688
222,227 -> 440,227
810,371 -> 810,985
414,321 -> 289,446
901,158 -> 260,799
198,967 -> 717,448
928,454 -> 875,454
974,437 -> 974,764
657,13 -> 760,13
498,966 -> 976,966
66,104 -> 66,15
773,569 -> 980,362
420,496 -> 403,513
57,920 -> 85,920
879,551 -> 879,662
98,395 -> 98,398
483,685 -> 483,55
222,935 -> 586,935
89,926 -> 807,208
744,160 -> 744,462
588,973 -> 588,548
312,572 -> 38,298
27,131 -> 552,656
591,935 -> 591,86
907,478 -> 907,279
981,75 -> 981,972
316,947 -> 935,947
906,38 -> 906,216
374,521 -> 345,550
579,29 -> 579,107
444,636 -> 444,557
458,608 -> 830,980
479,839 -> 155,515
766,600 -> 766,71
976,965 -> 31,20
928,49 -> 269,708
787,238 -> 787,983
583,742 -> 112,742
966,268 -> 554,680
671,354 -> 671,966
274,340 -> 274,894
673,185 -> 607,185
73,171 -> 874,171
861,526 -> 861,410
739,591 -> 739,138
209,355 -> 209,146
286,501 -> 887,501
495,902 -> 700,902
192,889 -> 821,260
400,21 -> 154,21
861,301 -> 325,301
552,990 -> 511,990
908,21 -> 11,918
127,724 -> 821,30
935,46 -> 170,811
947,91 -> 374,91
625,420 -> 265,60
214,228 -> 546,228
375,547 -> 715,887
516,350 -> 870,350
610,138 -> 665,193
214,621 -> 678,621
497,248 -> 600,145
549,558 -> 576,558
364,537 -> 364,312
840,324 -> 310,854
441,945 -> 441,458
459,531 -> 459,100
937,113 -> 150,900
277,405 -> 259,405
409,527 -> 409,359
534,766 -> 534,740
534,934 -> 681,934
456,419 -> 83,419
871,986 -> 873,986
14,59 -> 916,961
911,963 -> 971,963
25,325 -> 139,211
937,184 -> 354,767
460,416 -> 289,245
193,171 -> 861,839
840,299 -> 840,911
531,45 -> 531,619
599,315 -> 455,315
455,97 -> 455,811
38,748 -> 392,748
841,79 -> 841,88
105,571 -> 105,545
801,458 -> 344,458
491,535 -> 558,535
835,814 -> 223,202
563,85 -> 405,85
410,396 -> 600,396
273,670 -> 818,125
671,647 -> 817,647
46,892 -> 678,260
456,736 -> 110,736
962,941 -> 619,598
388,406 -> 53,71
558,895 -> 227,564
944,182 -> 807,319
484,898 -> 59,473
808,214 -> 488,534
451,679 -> 155,383
858,931 -> 381,931
723,377 -> 723,281
694,283 -> 182,795
385,191 -> 320,256
33,380 -> 584,931
480,91 -> 817,91
677,91 -> 677,126
291,651 -> 760,182
832,962 -> 153,283
38,60 -> 479,501
249,350 -> 789,350
603,341 -> 266,678
52,303 -> 52,102
911,201 -> 559,201
46,210 -> 46,275
960,212 -> 554,212
375,374 -> 169,580
10,10 -> 989,989
844,140 -> 40,944
916,408 -> 916,815
834,401 -> 834,169
553,479 -> 784,248
543,452 -> 543,848
854,910 -> 334,390
685,491 -> 793,491
552,943 -> 709,943
723,367 -> 124,367
95,55 -> 881,841
155,267 -> 573,267
59,357 -> 84,357
218,435 -> 218,344
491,584 -> 491,649
676,445 -> 676,333
361,618 -> 783,618
220,295 -> 220,267
668,758 -> 299,389
965,845 -> 674,845
285,603 -> 47,603
853,417 -> 853,757
859,906 -> 856,906
55,364 -> 753,364
893,474 -> 978,474
602,32 -> 58,576
171,445 -> 96,370
214,592 -> 214,286
400,946 -> 745,946
559,37 -> 112,484
624,510 -> 90,510
329,714 -> 329,850
458,287 -> 657,287
99,385 -> 99,949
50,736 -> 719,67
273,195 -> 273,306
490,902 -> 490,798
619,131 -> 921,131
266,652 -> 266,730
745,661 -> 745,555
311,878 -> 311,679
491,982 -> 643,830
735,875 -> 816,875
936,353 -> 936,529
792,467 -> 565,467
141,140 -> 141,988
98,171 -> 414,487
257,259 -> 257,484
24,41 -> 969,986
302,453 -> 223,453
807,363 -> 492,678
823,22 -> 835,10
301,94 -> 399,94
946,110 -> 248,808
983,985 -> 21,23
510,145 -> 510,58
13,661 -> 13,639
218,260 -> 218,54
475,846 -> 475,770
458,644 -> 458,529
912,934 -> 912,136
152,823 -> 550,823
136,470 -> 443,470
253,871 -> 905,219
765,212 -> 793,240
11,402 -> 11,42
348,813 -> 348,768
368,321 -> 823,776
343,495 -> 343,809
117,616 -> 117,273
92,92 -> 732,92
914,31 -> 28,917
259,944 -> 214,944
630,759 -> 462,759
134,653 -> 134,610
14,989 -> 988,15
139,181 -> 139,451
598,636 -> 598,442
263,42 -> 686,465

1
2021/inputs/day06 Normal file
View File

@ -0,0 +1 @@
3,5,3,5,1,3,1,1,5,5,1,1,1,2,2,2,3,1,1,5,1,1,5,5,3,2,2,5,4,4,1,5,1,4,4,5,2,4,1,1,5,3,1,1,4,1,1,1,1,4,1,1,1,1,2,1,1,4,1,1,1,2,3,5,5,1,1,3,1,4,1,3,4,5,1,4,5,1,1,4,1,3,1,5,1,2,1,1,2,1,4,1,1,1,4,4,3,1,1,1,1,1,4,1,4,5,2,1,4,5,4,1,1,1,2,2,1,4,4,1,1,4,1,1,1,2,3,4,2,4,1,1,5,4,2,1,5,1,1,5,1,2,1,1,1,5,5,2,1,4,3,1,2,2,4,1,2,1,1,5,1,3,2,4,3,1,4,3,1,2,1,1,1,1,1,4,3,3,1,3,1,1,5,1,1,1,1,3,3,1,3,5,1,5,5,2,1,2,1,4,2,3,4,1,4,2,4,2,5,3,4,3,5,1,2,1,1,4,1,3,5,1,4,1,2,4,3,1,5,1,1,2,2,4,2,3,1,1,1,5,2,1,4,1,1,1,4,1,3,3,2,4,1,4,2,5,1,5,2,1,4,1,3,1,2,5,5,4,1,2,3,3,2,2,1,3,3,1,4,4,1,1,4,1,1,5,1,2,4,2,1,4,1,1,4,3,5,1,2,1

1
2021/inputs/day07 Normal file
View File

@ -0,0 +1 @@
1101,1,29,67,1102,0,1,65,1008,65,35,66,1005,66,28,1,67,65,20,4,0,1001,65,1,65,1106,0,8,99,35,67,101,99,105,32,110,39,101,115,116,32,112,97,115,32,117,110,101,32,105,110,116,99,111,100,101,32,112,114,111,103,114,97,109,10,36,179,113,77,919,469,943,361,320,513,272,735,839,82,41,318,295,1758,280,1294,368,455,165,475,865,864,90,481,485,1517,554,32,104,1125,518,1280,165,423,209,188,1803,338,165,295,1082,715,343,15,316,71,310,282,239,779,314,759,1092,609,268,490,175,10,241,246,949,75,217,1,97,81,509,552,642,55,221,105,131,906,247,500,534,400,268,727,1395,47,570,318,38,370,2,1290,95,285,11,453,563,6,64,379,823,52,815,1678,86,543,378,732,188,106,68,173,400,23,295,548,484,74,574,656,1010,1607,1170,256,381,1452,400,136,68,1285,145,595,512,26,1745,737,757,193,361,1284,127,96,659,272,114,409,393,868,270,740,326,902,1862,524,799,632,465,714,1416,1,10,921,181,1302,7,430,294,241,694,29,402,71,263,585,193,194,808,175,1240,245,309,108,989,287,8,422,1760,80,120,5,551,596,15,455,134,970,106,1041,600,158,221,88,115,284,68,378,1023,815,251,238,287,280,406,1398,690,612,285,1167,235,10,915,13,1497,254,1317,1482,1119,1207,829,165,280,438,669,482,550,775,727,1760,473,550,992,33,215,681,1789,821,492,230,12,629,55,1218,342,292,35,503,739,594,243,24,678,101,800,138,1652,512,73,318,1611,9,47,1041,168,880,72,121,313,201,605,865,249,356,568,513,618,184,481,111,1602,660,206,529,745,492,207,537,493,457,28,633,59,214,653,1250,1001,133,140,1496,109,893,323,6,649,653,264,255,1549,1814,440,72,347,353,420,662,592,840,78,238,1165,485,1544,515,297,531,258,305,149,129,5,19,235,1658,222,217,1180,627,51,1056,186,1345,468,77,111,305,183,312,367,293,775,777,103,418,295,1066,108,1544,234,225,39,1233,626,163,643,371,191,1588,279,1560,754,1198,580,82,43,975,92,1118,29,87,1162,80,537,1216,1332,298,91,747,264,29,910,136,11,22,21,115,17,958,722,678,734,2,438,313,210,109,151,1072,1,1270,326,276,472,964,1349,1390,27,810,42,33,411,545,147,10,944,1023,704,652,912,13,324,91,34,539,174,776,41,378,320,61,169,454,10,9,223,126,1,684,721,475,482,132,278,1635,943,41,182,417,142,387,540,205,1409,392,420,1430,78,473,1160,347,890,716,62,205,258,676,500,60,290,566,942,363,104,19,490,731,885,837,345,776,193,1679,361,75,26,11,972,252,230,1243,1829,65,210,291,545,306,316,31,841,582,24,452,459,571,362,178,277,844,175,1010,339,55,360,413,1555,320,1050,28,1417,285,109,448,188,119,538,136,430,971,144,324,276,993,795,246,47,1258,638,1149,743,288,181,470,280,459,1392,2,570,147,143,32,70,904,554,84,1092,555,722,419,576,434,216,783,752,667,136,765,64,86,648,685,105,865,80,365,410,799,981,1546,1215,212,1406,716,1053,158,259,52,48,311,294,1186,716,484,343,101,13,712,767,168,39,108,245,64,728,236,870,976,328,65,252,322,148,506,1347,1478,417,853,362,356,3,739,323,1068,499,644,1432,50,836,136,140,1276,1307,212,748,767,1012,1237,32,304,243,26,239,69,1133,528,303,658,335,373,10,36,47,143,1476,476,991,668,1447,157,243,225,737,1733,43,772,814,1032,24,41,365,69,260,49,567,1113,67,5,122,520,11,349,11,519,127,383,481,605,1196,749,260,67,201,78,451,267,332,15,1855,554,144,94,20,13,761,61,25,237,3,196,695,1202,692,156,558,1410,240,526,68,223,743,5,1067,985,29,944,324,1040,69,1204,67,37,837,366,698,704,864,771,0,63,305,754,529,522,112,247,521,526,341,551,40,531,46,118,212,1024,305,440,238,339,581,201,840,41,811,115,236,1000,434,187,290,705,456,625,280,22,1203,861,35,380,101,923,462,570,479,860,450,40,676,959,391,396,194,52,862,217,725,14,273,63,475,43,496,1174,397,281,963,160,113,146,244,912,923,467,561,1180,354,802,188,214,2,100,1789,534,362,34,1148,998,231,460,28,117,471,412,651,513,305,986,121,175,447,566,76,1212,634,92,1523,671,802,36,81,791,503,1277,35,379,45,677,156,1,518,205,656,170,797,445,307,899,319,1104,806,842,272,1047,230,19,507,162,498,524,678,262,108,143,221,155,629,681,309,156,35,396,1440,796,302,6,857,1218,737,767,1465,8,236,550,20,334,371,282,381,167,211,398,937,185,282,389,464,343,160

200
2021/inputs/day08 Normal file
View File

@ -0,0 +1,200 @@
bfdcga cgdfe egfda cbfeda ec efc gcfbd ebcg gdfbec adcgfeb | bgdfc ec dfgae gefcd
cafgbd bc gfdbae eacfb cbf debaf cdgefba fecag fbcdae ecbd | cdfabg cb adgfcb bface
afg daecgf aefbgdc fbge fg dabfg efabgd cbadge abcfd gbaed | acbdf egbda adbge fg
cbeafg fadce cdeabfg gbdefc ged ebcgf bfgd dg ecdgf bgedac | fgdb afcbeg gcfeba edg
efd aegdb efgdcb bafcd acef dfaeb ef fgbadec cadfgb bfecda | fedgcb begcfd def gfdbac
badce gbcda gad fgdc acbgf cfbage gcfbad gd dbafeg afcbged | ebdfag dfcbag gd fdeagb
gdbcaf da dcbeg cad edcbfg gdea baedc afbec baegdc gbfaedc | gbdcaf dbgec da gaed
bedga agbefd dbgfca gcafdbe begcdf gdabf abegc deb ed adef | bgade gacbe ebd cbefdg
eg edfcab gfde abedf fbgdea bgcad gefcba agbed ebg eafbcgd | ge fbdeca bdcfega cgadb
dgbaecf fegbd de fbgade fde gecfb ebda dbgfa dfegca dfagbc | afcegd fgdabce de efgdac
dgafe deafbg gdecbfa fgcad beagd gfbcae efa dbfe ef dcgeba | gafedb debacg ef dfbe
gbadcf bcade efdgbac bcf acebf bf egcfa ebdf acbgde cdabfe | fbcea eafcg fcbea dcbafge
dcfbge ecdabg gfbdae afecb cbg cbgae gacedbf gadc cg bedag | bgdae becga bdcgfe ebcgda
bde eb cgbfade cdgbef beag gabdf dafeb cadfe agdfcb eadgfb | begfdc dfbcga abfdg edagbf
dcbgea fced cgeaf cfaged gdeac dgbfca fc badgfce cfg egbfa | fbcdag feagb cdef fcg
gfdbc adebcg cbg dfcaeb cg bcaefdg bdgfec bdagf dcfeb egcf | fbgda aedfcb cfgbde defgcb
daf cagfeb adeg dcbef cdgbaf da efcag fbdegca ecafd dcaegf | da bgeafc bgdfac ecgdaf
gfdaeb gfde agebf bgf fg bgcfad afbde fdaecb dbeacfg eabcg | gecab baedf eadfb gcbdfa
bagcfed eafb acfgd cebdfg ead agbdef baedcg egfbd agefd ea | gacfd bgfed fgdae bfdeg
cgfab adcfebg cgdef eabc feagbd ebcfg feb eb bdfcga gbcfae | defgc bdcafg fgdec cegbf
cdfab gdf cfebg decbaf gd dcgbaf gcbfd cgad egdbaf badcfeg | gfcbd gd cbgfe ecbafd
faebd ba efacgd baedcf adcef abf dcfbgae dbac gdbfe begcaf | dcab dafec fecadg ebdfa
dfceab egbadcf ba fdcbg feba cgdfae dbegac abdfc cba ecfad | defacg dgbcf gbdcf efcdbga
cadgb bedg fgaceb eacbgd egbac cefadg gd cafdb eabgdfc gad | afgdce adcgb gbacd adg
acb adcgf adcfeb baedg cb becagd bfcadge abcdg ebgc gfdeba | gdafc acfdeb cb aebgd
fabcgd fcdgae facde bcafeg da geda gcebadf befcd eagfc adf | cfage fgeac fgdbaec fgeac
bafeg fabcdg efdgabc fgdbea gdae ae dgafb bae ebgcf fcadbe | begcf abgfe aegbf efbadc
fdeca cadegbf gce bafdge abcdeg dcgb ebcfga cg deagb dagce | bdeag aebdgf gce dbage
fcgbde cdgaebf dgbaef fed bade ed adfgb efdag fdabcg agefc | gfdab adbcfg gcfae dfagb
ebdgfc febad adbfc fc bdfcea badfge cfb eafc acdgb egcfdba | acbgd bgfead dfabc fcea
eb ebaf cbdgef gaedb afgebdc febdag dgefac agbcd beg deagf | dgfcea efabdg egabd geafd
cedfba efgbd gfbdac gfaecd bfa gdfba bcag ab cgdfa begdafc | dfbace dfgeb eafcdbg dfcag
cfdbge gdbefac dabf dgbcfa gacdf gebca fb agefdc bcgaf fbc | afbd gbcafed acgeb ebgfdc
fgbec fbgcd fdbaceg gafedc bfacge fge eafb agbced cbgea fe | abgce fadegc ebacg fagecd
bdgec bgecfa fcbed debfcg acebfd gcb adbecgf gb aegcd gbdf | ebgfdc geacbfd gcb gb
fbea bdfcag dceabg egfcd edcfbga abdge af adf dfbage egfad | fa deacgb agfdbce ebdag
abdecfg gbacf fdbcge gfd dg gdafbc adgb acfde fadgc fbeagc | dcgebf dacgf agfbc cdagbf
agcefd ged bdfagc ed ebdgf fcdbge dgfbc abegf cdfegab debc | cagdfe ged cgdafb bafdcg
cebgad fdgea abgf fdbcae af baedg dgfeba dfbagce edgfc fea | dabegcf agdbe afe acfedb
agdfe fedbcga gfedbc agcbe edb db fdba edbgaf gedafc abdeg | cdgabfe afegbd fegbcd eafgd
dea abgdfe edgfbac egdab de cadbef adfbg gbcea gfde dabgfc | cdafeb ed bafgde ed
adgfb cdgefa ea fea bcdef cfagbd fgecabd febda agbe fgabed | cdefb gbea bdacfg dcbef
cadbg ea fdgeab afcedg dae ebcfdga cdfge afec dbfgce ceagd | fbeacdg dgcab bgdca dae
ecdbfg caebd fcgde fgda aefbcg afedc fcabegd aef gcdaef af | ecdfa bdecfg fea dgcfbea
dbcagf afgec fcadb ead daefc dbcgae edfb cagbdfe fcdbae de | egdabc fdagbc cgafbd afdec
dgfabe egdcbfa beacdg dbcfg aefc cdbaf fbadec fa aedbc fab | eacf bcdfg efca ecbad
defbgc gbdef cg edgc egbadfc cbgef gafdeb gcf eacbf gbfdca | fbedg decg cgf egfcb
cfdgae abdgf gbcd cfdaeb afebcgd cafgd bdf bcfgad db gefba | egfba decgfa abfeg eafdcg
dfagb gdbface adefbc gbfae gae begc acebgf fdgeca ge cefba | cgefab dfgace fecagd beadfc
fedacgb ed cabdfg bfgade dbaefc gdfba def gead bgcfe bdfeg | adcefb gdbaf egad caebdf
agfbed ecfbg cdge cgb fcgbde ebcaf adfbcg dcegabf cg efdgb | bdfcga bfeadg ecgfb cg
bec becfdag bgcaf eb debf adcef cefba fbcade acbged fcadge | edacfb fdeca fgabc cgafb
bfcae gabc fegcdb adefgbc bcgfae gfb fbgea fdabec adgfe bg | dfcgeb fgbae fgb bedgfc
afedcbg ed dfagc gefcd dec agbdec bfecg gfedca efad dfabcg | edaf dec begadc dfagbc
cgebd befcadg ecg ec fcde dbfgc fgdabc becfga aegbd bfcged | cbgafd bcgfd fedc gfdbec
dfabeg acfebd bgfcde begfd bcagd cdafgbe gabed aeb fgae ea | gbedf gdebfa bfegcd bgefd
gdf dagec gf cfdbega cfdba edbcga ceadfg fcdag aegf cdbfge | eafg fgd dfg bdegcf
bcfae fabge cdegabf cdae ebc dfcba ecbdfg ce dagcfb fbedca | fdagcb bcedfa fceabdg adce
cgbaf ad fgcadeb cbfdae fbgdac bgda egdfc cefbag adc fcadg | cfdgbae adc ecafgb dgabfc
bafdc cfb cf abcfged acdbge dbgca aefdb afcg afcdgb gbefdc | dabfc cagf efbcgd abecdgf
de abgefdc fbed adbcgf gaecf eda aebdgf adbecg fegda bfagd | feagbd dbgfac ade adgfe
gacefb faebcgd decfgb fa abdgfe afb fdbge dacbg adfgb edfa | dgbac abcgd gbadc adbgf
fbadg fgbde fagebd agbcf gad gfcbed abde da cbdfaeg afegdc | ecfbdg agd efdgcba aefbdg
cbdge gfecd cfe cafgd dbfe fe bgefdca gedfcb gebfac dgbcea | dgecb bagcfde gecbaf gacbef
dfgecb agbfe dbeacf ebcdf cbad cadfbeg ca cfa abcef edfcga | afgdbce cabd fcbdae becaf
abcd fbade befdcag da fecdag ecfdab bgfced bfedc dae gbaef | da ebfdc cabd cfedbg
ecdab cfaged cbfd cfebad begda agbfce fecba cd acd fedcbga | cfdage daecb febca ebacf
fcdageb beadf dag dacfbg bacge deabg dfcabe gdbaef degf gd | bafcdg dgafbc bdaef gd
febcg cefbagd fegdbc bfeac ab gcba bfa fdbega cedfa cgfeab | eagbcf cbgef afb fcgbae
egfac acbdge fadcbg bgcedfa bdcafe bf ecadb fdeb fecba bfc | fgdcabe dcbfga aegcf fbcadeg
gcfebd acdgb faedcb gcdfb fd gdfe fcgbe fgacdeb baefcg dbf | cgfdb bgdcf gabcd edcbgf
aced fbacg adbcf cd fbade cdb decfbg faegdcb gedabf ecdfba | bdfae fdgcbae fdbgec fdecgb
gdbeac dfcaeb afbgecd dbcgf af fbacg cegbfa fba cagbe geaf | fgbdcae eabcg caebg afeg
ebfda dgfbe ae fcbgead deafgc fdbac eaf gaeb ecdbgf ebfgad | baedf debgfca efcbdg ea
dgcfe acbef cgaef fbdgace ecafbd gcebfa ga age gdfeba bgac | adfbce ga cegfa abcg
abcgd facd fag eacfbg gafdb fa bgfacd dcgeba befgd efgacbd | bdcegfa gbdaf cbgda egabcfd
bdefcga aecbg cgde agbed ecabfg dgb befda gcadbe gdbcfa dg | acgdeb dgb bfaed adbeg
cefgb bde adgceb dafgebc aefd debgaf gfedb agfdb de cgdfba | defa edbgf afbdg bgfad
fa caefg egcab fca gdbcea abef bceagdf dcfge acgfdb afbgec | abfe faebcg acgef geacf
cbfed egacdb eabfgd gdbac deacgfb aeb eacdb gacfbd ea cage | dbegacf aecdbg cage dcgbae
efgad agedcbf bcea ba ebdcfg efbcag bgaef gfabcd bga gfbce | fgdae ba fedgbc egfba
dbcfa bcagd gdbfae cdfg fecab bcfadg dcbgae dfb fd bcadfeg | daegbc befca cbfae dbgcae
egfa bcgdafe dcfea dcfeba cafgbd gf edgbc gfd egfdc edcgaf | gf dgafce fdg efcbda
fgecd afgcde gfcadeb dbcg dcfbeg facbe gbf gfbec gdeafb gb | abdgfe cegdf bgf ecgfbad
gdcbafe gaf agcfe bafc gfdcbe gbfdea cfegb gaedc gfbace fa | bfeacg acgfe bcaf gcade
egbcf fgcea decbf dgabef gb fabedc fbecdag fgdbec bcdg beg | bgdfaec acgdbfe defbca fcdeb
bdeafc cabegd acdbe fdba cfb bf edcfagb fecag cbafe bcfgde | bfda fdgaebc dbaec fb
bc ebdcg agcfebd cadeg ecb fdbaec befgd cbdgfe gabfed bgfc | dagbef bcgdfe bgedaf gdace
eb ebf gaedfc fagdb cabe fabecg bagef bdgafce cgdefb efcga | beacfgd efgbca efbgca ebfgac
cagdf gdacef fcdbga cb gcadb bgc fcab dbfcage baged gbdecf | aefcdg cb agdfc bdgfec
dfbaec abegdf daf edbgcaf bgfd eafgc gafed fd bedag gebdca | ecfgbda beafdgc facebd bdeag
bfaegd dbecga fcadbg dcfg dabcg gf acbfe fgbca fga aegdfcb | cegbda ecabdgf egcafdb fgcd
dbgcea agc aegbc fgceda abdfce cbdg begaf adbcefg cbade gc | dfecba gbedac cdfeab abecg
cfdeab fgbec eadg bga ga dcebagf beadgc gaebc bgfdca bcead | bgaced bdeacg cbgea beacgdf
bagfce ebcdfg fa cgade cfa bfcgeda ecbdf adfb fecbad efadc | ecdbf cfa bfceag bdfeac
af egdaf aef eacdg fdgeca cafg cdgfabe baedgc edfbg acbdef | edfga decagb bdecfa dacfge
dab gfbed bfdage ebdcgf baecg da dfacbeg eagbd beacfd gadf | egbda cbdfae cfadeb egabfd
bcgfaed bfgade bd gfcda acgedb bacefg caebg cbed abdcg bdg | cebag fcebag dbcaeg gbd
dgcfb begdf def fbaegd fegab ed cebagf cefdgab cebdfa gade | ebgdacf aefbgd de gfdbae
ab abdf agbcde aegfb eafgc fgcdeb fbged bea bgafced efdbga | gbafe gbafed gaefdcb gdfbec
eafbg abgdf eg aceg gabfce fge fcbedg ecfabd bafdceg caebf | cedbfa gbface eg fagbe
face bfe adgfeb acebg cdbfg fe gacbdfe gcaedb cgebf cgaefb | aefc gdbcf gecab gfcbd
agfecd fa gbfa fbdce gdfeacb dabfe fbadeg bgdaec begad afd | fda bdefc egadbf fa
ab bfedcg gfdcb deacg abdfce gcabd adcgfb eabfcdg abc abgf | decga debfac fcbdg gecdbaf
gfadcb dcgab abfgde fdcega acd adbgf cgdeb ac acfb befdcag | dbagf ca gdcfab gaebcdf
efcagd dbcef bgda gbf dfaegb cfegab bfged bg agcfbde afegd | bfagce cefdb fgeda aegfcd
cedafgb cbfeda bcegf gdbe gb fcgbad cedbgf gcaef bgf cefdb | ceagf dbfcge afdcbe ebdfgc
cgfed acfge bdecaf fdag fecgad fedgbc bacge af efa afegcbd | cgadbef gbdecf fgced fa
abegf fagcde ceb feabc ecfda cb acdb efcgdab cbgdfe ecadbf | eafcb ceb cadb bdeafc
fbgae begd abcfegd bfeda efd eagfdb de fgaecb acgdef dacbf | dagfce adefb bdfac dfegab
fd fed fgad dfecag gaedbfc gecafb bdceg cbdafe efcgd fcega | agfd dgaf gdafce eafcdb
befagd dfeb bf caebdg ebgda egfcba bgf gcadf gafbd fabgdec | agdefb eagcfb edacbg badfg
eagcd bdacgf gfeb fdgba be deb cefagdb afcdbe bdgae aegbfd | cfbgad dbage eb bgeadf
eacbfg debgac dbfcage dc eagbc cda cabdfe dfgea bgdc adegc | becag efbacg caebg cdgae
fed fcbagd acdebf gaef ef fgdec fecbagd dcegaf cbdeg agcfd | bdeacfg ef cadgf dcbeg
efc becdag afedc edgaf fc badgcfe fcdbge adfcbe cafb eabdc | dfebca acbed fc efacd
abfed dc fdcegb cgbfe cagfeb fdecb gbcadfe bgadcf gcde cdf | gecafb fbegdc febcdg cegafb
feagc daecfbg gdca dg fgd fdgec cebdf eagcfb efcgda fbdeag | defagb aedbfg gfd faegbc
cagdf ce bcegdf dbafeg cbeadf gbdaefc caeb cfe feadb efadc | ecba dcfae ec ce
fgabd abgdc dbcae cfadge cag cbge cg ebcadg cgfdeba fcbeda | dgabce dacegf baecd cfabed
efagc fdcgea geb bfdgec cgba fdcbgae adbfe bg bfcaeg fgeba | afegb daebf ceagdf agbc
ecgfbad ceg deca gbfed bagfdc cegfba cabdg ec agcdbe bdegc | agbcd ecbdg bcadg dcagb
aedbg bedca efbdag dgcb bfeac efgadc abegdc bfdegca cd edc | cbdae edcgfba ecd fdagbe
cfeagbd cfab bgc fbgdae fgdce gfadb bc ecadgb bcdfga gdbcf | cbfa cbadgf bfcdg abcf
edacg cdfbag fbeagdc cdgaef fc bagfe fac edabgc defc gcefa | dagcfb aegcf fc fegac
gfdabc dbgaef agbe cegadfb bdgaf gedafc fbced ge gfe befdg | dfcbga adbfge bdfeg cfadge
bcafge gbcd bc bfgdea cafdb fabdg acfdbg acefdgb acfde bfc | bfdac cbf fdabc edfca
gdcab cegd ebdcfga egb eg afceb cdgbfa acbge gdebaf bgcdea | agbce fceab dagfbe acebg
bagc cgf bacfd begfdc afdge bcagdf bcedfa cg becgafd dgfac | bdacf cfedab abcefd cafbd
ca cag gbfdc cadfbg eafcdg afcb edgab dgcbef cbgad abfdgce | cdbga bacf fgdace dcfgb
dcebf aefcbd gdcf fcbgde cbgef beacg gfebda gf fcdbgae feg | bfcadge cfbeg fg becgf
dcabfeg fbc cfgba dfabgc becadg fc dgebcf cfad cbagd gbeaf | ecadbg degabc aecbgd cf
cba efabd ebdcga cgeafbd cdabf fbce dbfcae bc cgdfa egbafd | abedf facdg ebcf cb
db efdcag dabf cagfdbe caegb decba bfcdeg fcabed fedca bde | edfacb adefc dbe dbe
fdabg efca bac ca fdacb becafdg fcdbe bcegad begdfc afbdce | gecdbf faec fadcb dbcaf
eg egad egfbadc bdecf feg agfcbe decfag dfceg cfgda cfbadg | fcabdg gef eg fecadg
fgad bgfde afe acebd dgfcbe af beadf ecabgf fbcedga abefgd | cbdegf edfab fegacb fa
efcgb beacfg gbecfda bfac afg dbfgce bfgdea fagce caedg af | gcebf aedfbg eafcbg fabecgd
bfdecga gaedfc ecga begcfd cfdab gbfade efa caedf ae defcg | daecf egca afcdeg caefd
decab efa dagefbc dagbce fcadg abdegf fe eafdc ebcf dcfabe | ebcf fe ebcf fae
begfd agedfc dabfce eadgf adf eacgfb afecbdg da feacg dcag | abcdfe daf debgf dbfeac
gbdfca gbefca cba cb ebcfagd gbafd fdacb fdgeab bcdg cadef | afbdc efdgabc dbagf gfdab
efdagb dae fcabedg caedb fdaecb ad ebdfc cdgfeb dfca eacbg | bedfgc fecdb edgfba cedfab
cd afdc cdg cbdgaf eagbd gacfb befdcga bdacg cbeafg ecfbgd | bdgacf dcfbeg dacgbf dagcb
begdaf gedbcfa dafc fea dfgce dgacfe gbedfc cfeag cbgea af | gecba agfbedc cbage egfdc
dc fgcd baefcg afbgecd bgeda ced baedfc cdeag gdafec efgca | bacfge bgdae abegfc afgbced
fc afcbgd bcf afebcgd bgdcf acdf bdfeg ecbagf cbdega adcgb | ceagbf befdcga edfagcb acdf
dbcgf degc bfgad bcfed gcb fceabdg gbfcde gc fbdaec afgebc | fecbdag fadgecb afbdg dgecfb
abcfg cfb eafgb bc cgbfda adfcge afdcg cfbgde cadb efgbcda | acgfb cb dfcag gdecfb
cdefb cfga edcgbfa cab abfge acfbe ca bcgaed bcaefg bdegaf | dbfce gdfcaeb fedabg fbcea
fgcae gafd eacdfgb baceg cadebf cfbged daefcg fge fg fceda | gceadbf dcbfage cafed ebacdf
fabdceg abcgde acebdf cfaeb fa egfcb dbfa fac abecd agefcd | cfeab edcbag acf dcabefg
dgbecfa abdfe acegd fdgabc gadef gfce ecbagd edagcf fg dfg | gdf fcegbda agcde fgd
dagf bcdaef ad acd cbeag febagdc dgbfac dgcab fcdbge bdgcf | fdbeac gcbda bcfdg bfcgd
fgdc gc gefdcab bdgec dbcefa gce bfgdec gcefab degab cebfd | bdfce gbecfd gadbe ebcadgf
fagc bdcfag fdacb agbedf daf aedgbc dbcga ebdgcfa cbdfe fa | febdc cfag af cadbg
bcd bfec dagbcf egcbfd bc edfgc bdecg edabg dcgeabf gdefca | bedag dbc fgcdbe ebdfcg
gedafcb dbagcf bcadeg fc gfc cebf edgfc cgdbe bcfdge egdfa | fc dabgec bdcge ebfc
gafbd ef becga ebgcaf agbef gfe gebcda gbfdce afce dbcgefa | ef gfe cabfeg gabecf
deab fbedgc eb bdacg dagcfbe abecg cfdagb beg baedcg gacfe | gacdb dbfgace dbea cadbg
badceg ced fecba fbdc adfec ebfcgad gecafb faedcb gfeda cd | fcead fbcaged adebgc ceabgd
bd bdcg fgcab abd cfaebd baecgf fecbgad agdfb efdga gfdacb | afebcd bfadg egbfca cgbfea
da decbf afdec begcad dcgefb gcafe edbfca dca fdab begdfca | efadc abdf ebcdfa fegac
gcbeaf geadbc fdbeagc bfdec cdbae ea agfdcb dabcg eac adeg | gcdba cebdf abecd gedcab
bcdae abedg ebg bfadec eg dbgaf egafcb gcadeb egdc abedfcg | dagfb ebg gebcaf eg
afb abgfed caegfd cfbd becag dcbgfea bf decaf faecb bedfac | daegfb dbaefc gacedf bfa
bgecf becfad ea adebgc cfdbgea dabcg eca eagd acbeg adfcgb | agdbc bagcd bgcda aedg
bf fagcde cfdb acfgd gfdaeb acdfegb gfacb bfg bgeca bcgafd | gfb gfacd agfdeb abcge
aegfd efcd bedfagc bacdgf gecadf aed egbdac fcagd ed afbeg | daefg dagfc acdbfg gbacfd
decga efbcd badcgf cfgdbe agefcbd fa ebcdaf fcdea eafb fda | dcfea fad ebadgfc afedcb
bf gebfcd bagfed bdagcfe cegbd fgbdc gfb ecgbad gdafc befc | fadbeg bcgde gbf bfg
df cbfged fgbca fbd bcafge bdeac agbfecd adcbf gdaf dabgfc | bcdea cafbd afdg gacfb
ecdbfa fadgce aceb fgebd bfcgad cdfae afgbced dfebc cfb cb | cfead fcb bc bedcf
fdbega cfegd cdbgae cdfebga fecadb aeg cbag ag adceb dcage | ebcagd gcead egdfc dagecb
cdbfeag gfdeba edfgca cead geadf gac fcbdg afgcd cabegf ca | fecgad gefda dafcg fdgca
cfgbae cgefb egdbfc dcg dfcbg ecbgfda badcf gfed edcgba gd | gd cbefdg adbceg badcf
bf bgf debfg bgade egbfcd cebdafg agdfce fgced dcbfag fcbe | adcgfe fdgeac fb ebfc
gefdc fdagcb gfdac bdafce caf ac daegcbf febgda cbga dbafg | dagbf ac faedcgb dfagb
ecfgadb dbgacf abfegc gd cefad fcgde cefdgb fcbge gdeb dgf | efacd bcegdaf bdgacf gd
cdfgb bdf fdcag bd cdba gbecf dfecga cfgebda gdefab dcbagf | begfc bcgfd gfbce afbgcd
fbe facb decgaf afdce fb bcdeaf bagdfe ecdbg dfbce bgedcfa | abdgfe eafdc efdbca acfgde
bgdcf cbaegd eabfdcg ceg eg aedcb deabfc dgea gfcaeb gecdb | eacgdb ge daebcf eg
egbdcaf gd cefabg dfge bcfagd afdegc caedg baecd gad caefg | gcedaf efgabc dag deagc
cdabf bgcfde afedgc fcb gcba gfacd bdaef bdegfac cb bdfagc | bcf bcedfg gaecdf cdgeabf
gf dcbfeg fcgdbea fge gedacb aefbg bgead gfad dfegba aebfc | aedgfb gf egf dfag
gbeacfd gacbd dcgfbe fg fgd dbacge bdagcf dfcea gafb fgadc | deagcb gf degfbc edcgbaf
ce gdbcae debcf cfdabe eacfbdg acef fgdbc begadf ecd afdbe | dbefa abegdc cbdfg acfbed
begdfc gbdc gedaf dc edgfc cdf fgbec ecdafb ebgafc degcbfa | egdfa edgbfca cbefg fagcbe
efcab dgbfc ag agdc cfagbde fbgeda fag acgdfb fcbga gbefcd | gacd gdac dcag gdac
bdage bdaefg gbe eb edfb bgafec dgbecaf egadf fdaecg dbacg | geb afgdbe dfbegac efgcba
ecgfa bec be ebfgc dgbcea adefgc egafbc egbafcd bafe gbfdc | aefb bce befa gfecab
ebgdc cbe ecdgab gacb gfced dbgea edbcfa fagcdeb gabfde bc | dgfec aebdgf abcdfeg fbaedc
daegbf adef dgcabe cafdgbe adcgfb dbegf ebgcf dbf ebadg fd | fcbge bgcef acfgdb efbgd
cdbge cfe adbcef fedgcb gfebcda cedgf edagf gdbcae cf gcfb | cdbeg gcdfe fabgdce aecbfd
beacg dafge gbeadc fcba bgdeafc begfa bf eabcfg ebgcdf bfg | gaefb bcfged degcab egdaf
acgefbd feb bf cdaef beadf gbaed abgced gabdef abfg gbfedc | begfda efcda bfe dgacbe
eacfgd fbdgce abfcge bcfea cafeg cagdbfe ebf debca bf fgba | fb fb acdbe cfdage
bfec cedagf aef ef degba bagcef dgcfab fgeab fecdgba bacfg | cbgaef efacgd aegfb aef
dbacfe edfc ec caebd agfebc cbe cbdag gfcbead bgfead bafde | deabc dfagbe cgbfea ec
ed dfgbec dfabg fbaec feacbg edafb aedc eadfcgb ebdacf dbe | deac bgeafc cebfdg fcdegb

100
2021/inputs/day09 Normal file
View File

@ -0,0 +1,100 @@
9234598321279999876543212397634598789843210123456789212999878987556456999878965432459101987654567899
8965987432367898989864301986545789698765421939697894349876967896432349899769896543598929898763478998
7896796543458997698765212987676994569865439898989965498765456987321099789858789654987898789854567987
6789899654569987549876943498787893498979698787678976789886349876532988656645699769876745699965679896
5678998965878976534989894999898932987898987656567898999943234987849876543234678998765434788978798765
4556987896989765423498789899989899876567986745456789898932145798769987653123789987654323487899899954
3249976987899654312987677789976798765456985432345689767991015679878996544012999899873212376789939853
4398765898998995499876585678965459854369876541237895456789324589989988432167898798765901234998749754
5469876789987989989965434567894398765498765430125789345695435678999876543456789679989892945897659886
6798987899876875679954321236789199876599876321234599216789576789656987664667894589998789896789769987
7987698998765654568899410145699989987987976532345678924597689996545698875798923678997656789899898798
9878549976543123456798921234987978999876986543467899435789799985324569989999434569976545689999997659
9963234898794012767987892349876867998765499876578929876789898765435678990196545698987438795498986543
9852123789989123459876789498765657898654345987689210989892999876549889991987656997696545894387897651
8743245678978954598975345998654545789654234599789329999901997987669998989998779886598767895256789872
7654346789567895987654249889843437678965123489895498999899886598798997678999898775459898952145699993
8765657893458976798765398776762123489987434567976987898789765439987876587999987654345999943234988989
9878767892599987899876987654321012591296545779989986789678954329876545456789876565234689895949877565
6989878901989898965987898765434323690987856889798765454599769212985434345699965432123456789899765454
5496989329878799654398969876567434589998967897659854343489898909874323234579876551012348997798974343
1345695498767678967989656987698997678969878998798765212378987898765210123567965432123459976656793212
0123987987654569979876545698789989789654989999897654324567896569984321234878998643234567895436789393
9294599876543456895987656789899879998793297899989775435978935498765432345679879784345678976545899989
8989678998765567984398768891998767899989356998978976567899321239886545456789769895456789987656789878
7879989889878678965679879932998658999979459897869987678989990347998676768896653939869893499767898769
6567897679989789976789989899876549679868998786458898789879889456789789879965432123978932349878987656
3458987567899897899895496798765434569659987655377789898767678968999997989987543234989321298989996543
4567893468998956568901345987654325698789876544265678987956567899019876596898655455696539987899987632
5678912345987545456912346998765412389896987432103459876545458942198765445798796578789998976989998321
6789101256996433347893459899898701278965496545212398765432369893239893234789987678999877965578999210
9893212369874321236789569789987632369896397876343459854321236789945984345696598789398765624466799321
9954323498765438345699998679876543456789298997456769968534345699896976789789459899299544312345678943
8765434789876567456789877545987854667892129976567878987678456789789899899892398978987632101234589654
9876545678987876569899965432398965878921012987678989898989567898679789921999987667898543612345678969
0988656789398987878998998321239878989432123698889998769499878977545678930198765456987659543456789878
1998767895459298989787987532456989996569234569999989654323989765434567921239874366798768767568999989
9879878987679109899656796543456799987898945678989978963212399874325656893498765234769979878679589995
8765989898998998768943987654697989998987896989878867942103456965412346789999979123458989988789678954
9654396789987987656792198967989978999896789898768756893214579876525457899889898938767996899898789543
8964245699876796545789999879878767998765458799657646789925689987436567988776767899878924456989899952
7893126988765987636799899998767656987654323678943434567899798998547679876565457789989313345678999891
6789019876854398747898789987654345698766434567932123456798987898798798765432345699993201234789998789
5698929865464239658975678998743234769876556778943254567987786799899899895601246899874312345899987678
4567897654321099899464568987645123456998667889765345678996695689932999954312356789965423656899876567
3456798976542987954353459876532012368909788998765456989985434599321098765424456899976534569998765456
2169989897953496543242365987432143499219899899878567899876745678934989989535767899876545698999764345
3298676789894569732101234599843254789398965674989698943987658789549876596546878999987676987899853234
4987545698789698654232345798754365678987894353499999432398767897698785459657989789998799876598767346
5988436789698789765343456799765496889876789212989894341239878998987654398768997696999899987439878457
9876521234589899876457667987989987898765678909978799210949999459896543239878978545789998996521989568
9983210123679956998568779995496798969876789998765678929898989598765432123989865734678987889432987689
9876421234598949987679899874345679654989892987654599898767678999989821012398754324569876767943698797
5987562455987898998789953965234989793498901296543456797656546789998733123579863213498765656794569896
4398778569876567899899899854345899989567892395432345987545435679987654534589965624569654345989678989
3219887698765475899999798765456789878978993987541256796432323778998768675799876787679643234578999678
7323998987654234789987659896567896767899989995432348989321012567899879786795987898798932123456789567
6567919999843044578996543919878975456999879876744559875458723478956989899894398999987321034569893478
7678909898762123459999432101989765349998767987865667996567654589547996987943239789996432123688954567
8789398789873434967898944912399854298767656799976878989998765695439875456894345678987853434567897678
9893299632986547898997899894498743197654745679987889877899877899523989567965456789998754545688999789
9999986521297656789986798789999654986543234568998998766899988978912399699979569899879867659789987993
8998765434398767898765987677898965697654345789999989454598999569923498789998678999769878767892396432
7899896565499878919874396565987896899865466789899876323457892398896569997999799987643989898901987541
6789987776987989434965989454576789919876778898798765212348901986789789346799989899952197999329987632
5899998889876799949879876323345892101987989987659854105459912965678991299899878788891016799498998543
6999879998785679899989965410236943232398999998639873212567899896789210989998767677789125678987899654
9899867987654563778999874322345894345989878996521964323456976789894329878987656565678934589776789765
8785659876543212567898765434456789657976569985439876434769765678965498769876543454567895997645678976
7654545987654103458929876546567898779865478976556989545678954567896987659876532143458797896534569987
6543434598763216567910997657698999989976678987767898767789323456789498546998321012345689994323459998
7652123569854347678921598798789998999987899499898929978894312348992349656989652123478998989012368999
8761012478965456989432459899899877889998989325979213989953201237893498979876543456567897879923479989
9872123569876578996563769953998765678999878934569101296543213456789987895987654567878996567895678978
9983237678989989987875878992199954345698967996678932987854324567899876843498765878989985459998789569
9994345789896593598989989989989893296987656789789949899765435878998765672349876989799876347899893458
8987656998795432699399899979878789989876545678999898789976546789329984421234987897653975456921932567
7699867897654321989498787656965698878965434567898785678987987899909793210123498998792986567890953678
6549878998975439878987655649879987667896545878987674569898998999897654321266569329989597678979894589
5432989899876598769876544434998865456789676789996543456789999898789987432345689499965498799567779694
4321399789987789653989432123987654325698989899985432359899988789678976543476789987857349895435567943
5930298698999899542398949239876543214567899969876545468999878656567897854589899976744234989323457892
9891976567899987653987898949989876523678998654998656567898764545456799765678999865433145678939598921
9769895498979898769856767898999965434789998743479787978999653232345678976789598764321034989998999210
7658789348968769898745654567899876545899989432369898989987632101457899987895439989452123899987895439
4545678957954356987632343456899987856789876543456999699876543234578995498999621296573234789876789598
3234569767893239898521012347898998768999987656767896545987654567899789239998990987684345679765678987
2123678979964198765432129469957989879459998797898987634598765678956689123987989998765456789654569876
1038789989979099898547298989239876989968929989989654323989876789244579019876567999876567894323498765
2149898798998987997656987892198765699899439878978993219876989892133459199965456789998778943212987854
3234989656487896598969876989019854569789598765767889109954599943012998989876345678919889654309876543
4545679545346789459896965678929543298678987654656778998765678932199897678987558789324998785412987642
5656795431257899398795454589998754596567896543244567899877899643989676567987678999939019876543965431
8767896910129998987684343456899765985456897654123456789989987659876543456798999998898923989659878932
9898959891235987897543212369989899874346798765034567896593498767987852349899212987677894598767989543
9949346789349876789654301298878987653245689872123458989432379979876543498954329876566789679878998654
8431245678998765678963212987767898732176789943234589878943467989987694987895698765445678989989998765
7510356799239854345894349896556789621018997654345678967894568997698989876799987654334569496799879876
6421237890198765676789498765445698542129998765456789656789879876569878985678998643210579345997764988
6532345893239976987896569874325987653457899877667897645678989985498765434567987654323478959876543499
7643456789345987898987689985434598764567899988798998798799999876349876546778998765434567899987201234

90
2021/inputs/day10 Normal file
View File

@ -0,0 +1,90 @@
<[<<<<[{[<({{({}<>)<[]{}>}[<<>{}>{<>{}}]}{(({}<>){()<>}){{[]<>}{[]}}})>([{{(()[])[{}()]}}(<{{}<>}
<<[<<{[<<<{{<(()[])>[({}{})]}}({{({}())[<>{}]}}{{(<><>)[<>()]}<<<>{}><<>()>>})>{[[<(<>[])[[]{}]>{{[]<>}<[]
<[{<<(<([{<[<{()<>}<{}[]>>([<>()]{<>()})]{[([][])<{}<>>][<<><>>]}>}][[[<{{[]{}}[[][]]}([{}[]]<[]<>
<{[(<<[({([{<[{}[]]{<>{}}>}[(({}()){[]<>])]]{{<<[]>([]<>)><<{}()>{<>[]}>}{({<><>}<<>{}>){(()[])<()<>>}}})
[{<{[(({[[<<<<<>()>{(){}}>[{[]{}}(<><>)]>{[<[][]>(()<>)]<<[]()><()()>>}>])}(<{<[<<{}[]>>{[()[]]({}{})}]>{
[<{<[[[<{[<<[{<>{}}<(){}>]{<{}{}><{}{}>}>{<(()<>){<><>}>}><[<{{}()}>{{<>()}{()<>}}]({<{}<>>}[{()<>}[()()]])
(([(<({[<<({{<()()]{[]{}}}[{<>()}[[]()]]}({[<><>]}<[<>{}][()<>]>)){{[[[]<>]<<><>>](({}{}){{}()})}}>>]})>)<((
(<<({((<<(<{([()]<()[]>)}[{(()<>)(()())}{{()<>}<()()>}]>)({[<(<>())((){})><{<><>}[{}<>]>][[[<>
[(<([{[[[{{{([()()]([]()))[<[][]>[<><>]]}{(<[]>[(){}]){[<>{}]{{}()}}}>[<<[[][]][{}()]>[<<>{}>
{<{[[[{<<([({[<><>][(){}]}({(){}}[{}<>]))<{[(){}][<>{}]}{(()()){{}[]}}>]{[((()[])<()[]>)<<(){}>{{
[<[{{{({([({<<(){}>[{}<>]><{{}<>}[<><>]>}[[<(){}>([]{})]<{(){}}[{}[]]>])[<({<>{}}<{}<>>)({<><>})>]]){(<(({
<<{[[{[[(<[{[[{}()][()[]]](<[]{}>(<>))}(([{}()])<[{}()](<>())))]><(<[[<>{}](<>())][[<>()][()]]>{<<<><>>[()[
<<([<[{{[[({[{()}[{}<>]]({{}{}}{<><>})}<{{{}()}<()[]>}<<{}{}><[][]>>>)<{([[]<>]<{}()>)][([{}()
[(<<[[{<<{<[[<()[]>({}<>)]<{[]<>}<{}<>>>]{<<()<>>[[]{}]>([{}()]{()()})}>[<{((){})[{}()]}[([]{})<()[
[<<(<{[{{[<{(([])({}())){<<>>{()[]}}}{[(<><>)[[]()]]{<<><>><()<>>]}><((<<>()>{<>{}})){[{()()}][[()[]]([]{})
((<[({<[(({[{(()())<(){}>}<[[]<>]{()()}>]({<()<>>(<>())})}<(<[[][]]{<>[]}><<[]<>>[{}[]]>)<{([]{})[{}()]}([[]
[([{<[{(<<({[<{}()>([][])]{({}<>){{}[]}}}[<((){}){<>{}})[{(){}}]])({([{}<>]{<>{}})})>[<<{<{}<>><[
[{{{[<({({{{[<{}()><[][]>]({{}{}}([]))}{<[<>{}]{{}{}>><{{}<>}>}}}[[[([{}()](()()))][({<>{}}{<>{}}){
[<{[{{(<{[<[(<()()>{()[]}){{{}{}}(<><>)}]<<({}{}){{}()}>{([])(<><>)}>>[({{[]{}}})<{(<><>){(){}}}((()<
<[<<[<(([<[{(<[][]>(<>[]}){{{}<>}[{}()]}}]<[[<{}{}>{()()}][[<>()]]]([<()>(()[])])>>][{[((<[
[{({<[[{<<[<[(<>{})<[]{}>]<<[]{}>[<><>]>>{({()<>}[<><>])}]><{{{{[]()}{<>[]}}<((){})>}({<(){}>[
{[<([[<(((<{<{[]<>}<[][]>>}>)))[<<{[([[]<>]([][]))(({}<>)<<><>>)]<{{{}{}}<<><>>}([()<>](()()>)>}>>]>{({<{
{{{{(([<(<{({(()())([][])}{({}()){[]{}}})}({(((){})[{}[]])}{((<><>){<><>}>[<{}[]>{<>[]}]})><[{<(<>[
<[<[<(<<<{(([[(){}]({}<>)]){<[()<>]{()()}>[[{}{}](<>)]})((((()<>)({}<>])[[{}<>][<><>]])(<<{}{}>(()()
[[{(([<{<[[({{{}{}}<[]<>>}{([]){<>()}})[(<[]()>(<><>)){<<>()>{()[]}}]]]>(<[[{(()<>)[[]{}]}(([]())(()
{<<(<<([(<(<({[]{}}{[]<>})>({([]<>)<[]{}>})){{([(){}]([]<>)){[[]()]}}}>{<{((()](<>()))}[(<{}<>>((){})
[({{{{{(<{({[{<>())(()())][<[]<>><[][]>]}{<[<><>][()()]>[<()()>([]{})]})<[[([][])<[]()>]<([][])<()<>>>]
[[[<([<[<(<{(([]<>)<{}<>>)<[{}[]]<()[]>>}{{([]()){()[]}}([{}{}](()()))}><{{<()<>><()()>}{<{}<>}{<>()}}}{{[[
(<({({[[(<[{<{(){}}[{}{}]><{()()}>}[([<>()]({}<>)){<{}()>({}[])}]]>)[[(([(<>[])<()<>>]){[<
({<[<{<<{{{({[()[]]})({[()()]{{}()}}(([]<>)<<>[]>))}}}>>(([({<[{[]}[[]()]][[<>[]]([]<>)]>({[<>()]{
{{(<[{({<[{{[{{}()}(<>{})]{[()[]]([]{})}}{([[]()][[]])[[[]()][()[]]}}}[<[<{}()>[{}[]]]>({<[]()>([
<(([(([[[[(([({}{}){()<>}]<{()[]}([]<>)]))]][{[({{<>()}<{}<>>})([[<>()]])](<[<<>()>]({()<>}{[]{}})>{[(()
([<{[<<<(<[{(<{}<>>[<>()])[<(){}>]}[[[()[]][()<>]]<<[]{}><<>()>>]]<[<{{}<>}{()<>}>{{[]()}})(<<<><>>>{
[{({{<(((({(<{(){}}>((())(()<>)))((<{}{}>((){}))<[[]]((){})>)})(<(([[]{}]<<><>>)<{()[]>(<>())>)>))))>}{{{({
[{(<<{{(<[{({{{}{}}{<><>}})}(<{({}<>)[<>{}]}<[{}{}]{{}{}}>>)]>([[{(<[][])<[]<>>)<(()<>)[[][]]>}[({()<>
<[([[((([{<[{(<>{}){<>()}}(({}[]])]([([]())<<>[]>])>[{<[{}<>](<>[])>}<[[(){}][{}()]]{{{}<>}[{}[]]}>]}])))][{(
(<[[(({({{[<<[<>[]][<>{}]>[[<>{}]((){})]><<<{}<>>[<>{}]><{[]{}}[()<>]>>]([[[<>{}]{()()}]<<()<
[{{{{<<{{{{<({<>()}((){}))(<[][]>{[][]})>{<(()<>)[()<>]><<{}{}>{{}[]}>}}<[[<{}{}>]{[<>()]<<><>>}]{<(()())<{}
([(<<{[{(<{<(<{}{}><{}<>>)[(<>[]){(){}}]>({<[]()>(<>{})}<{[]{}}[(){}]>)}>([[<<[]()>(<>)>(<<>[
<(<<{<{[{[<[{<()<>>([][])}]>]}]}><<<[([{(({}{})(()()))({()()}<<>>)}([(<>{})(<>[])][({}<>)[[]<>
<([[((<[<[[((<{}<>><{}()>)<(<>{})<[]<>>>)[<{()}({}())>{[[]{}]{()[]}}]]<<[(()[])(<>())]{<[]<>>
<<{{{<<({{<[<[<>()]{{}<>}>{<()<>>{[]{}}}]>}}{({[<[()[]][<>{}]>((()[])<{}()>)]}([{[[]{}]<[]<>>}{([]
(({[(<({<{[[{<<><>>({}[])}(<<><>>[[]{}]))(<{<>{}}[[]{}]>[[<>{}]({}{})])][<[<()[]><()<>>]><[({}[])[<>()]]<([](
([([[([(<{[<([<>{}][(){}]){<<>()><()<>>}>{[{()<>}[[][]]][[{}{}]<(){}>]}]([<[[]()]{{}[]}>[{<>[]}[[](
({((<[(<(({{([{}[]](<>()))[({}())]}[{[<>{}]<<>()>}{[{}]}]}({{<[][])[{}[]]}}((<<>{}><<>{}>))))<[<{[(){}][{
{([<{{(({[(<<{<>{}}[<><>]>{(<>[])({}())}>{((()[])[{}]){([][])((){})}})][<[<<[]()>{(){}}>]((<{}()>[{}()])<<{
{{<<(<[<(((({{{}<>}{[]<>}}[(<><>){[]()}]))[<{([]<>)<[]()>}([[]{}]<()>)>{{[<>[]]({}<>)}{<<>[]>[<><>
[<({{[{{[(<[[<[][]>{<>{}}][{{}[]}[(){}]]]>{{(<{}[]>(<>()))<((){})>}[{([])}]}){[<[{()<>}<[][]>][[
({<{{{(({({<(<{}[]>[[]<>])>})}<{(([{<>{}}<<>()>](([]<>){()[]}))([({}{}]{{}{}}][{()[]}{()()}]
((((<({[[<(<{(()[])((){})}>(([{}()]<<><>>)[{()[]]{{}}]))[[{(<>()){<><>}}{<<>[]>[[]<>]}][[{
({<[<((<({<<((<><>)(<>[]))[{[]{}}{[]{}}]>{[[()()]{()()}]{[<>{}]}}><({[[][]][()<>]})>}([[[(
({<(<<<<<(<[<[<>()](()>>][<<<>()>[{}[]]><(<><>)>]><({<<>{}>}[<<><>>{(){}}])[{{<>{}}<[]<>>}]>)(<{{{()()}
[<<[{[<{([([{<()()>[{}[]]}<<()[]>{()()}>][<<{}>[[]<>]>{[()[]][[]()]}]){[((()<>)<{}[]>){[[]()][{
[{[<{<{(({{<(({}[]))[[{}[]]{[][]}]>}}<([{(()[])}<[[]()]>]{<<<>()>[<>[]>>[[[]()][[][]]]})>){<<[<<{}()>(()
<(({{<{{<[{(<[[]<>]><({}{}){[]{}}>){{[[]{}]({}<>)}<((){})<<><>>>}}{[(([]<>)[{}<>])({<><>})]<(<()<>>{(
[[{[(<(<<[(<[[<>[]]((){})]{[<><>]<{}[]>}>)<[{{()[]>(<>{})}(({}[]){{}[]})]<<[{}{}]>{[{}{}]}>>][{([<()<>>({}
[({<({[[<[{<<{{}[]}<(){}>><[[]()][{}{}]>><{([])([])}[({}<>){()()}]>}{[{<{}{}>[<>()]}]({({}[
{{<[<[(([<{[{{[]{}}[[]{}]}]}>[[(<{[]()}(()())><{(){}}(<>())>)[<([]()){{}<>}>[<[]<>>{{}[]}]]](((({}
{(<<[(({{[[{([[][]]{{}()})([()<>][{}{}])}]([[{[]<>}({}{}]][<{}[]>]](({{}[]}){<{}[]>((){})}))][<((
{{{{({{({[{{([{}[]]<(){}>)<<[]()>([]<>)>>{[{{}()}]<[{}]<()()>>}}[[{<[][]>{[]{}}}({()[]}<[]()>)][<[{
[{{[[({[[[[((<{}[]><{}[]>){[{}{}]{()[]}})({{(){}}([])}<<[]()>[{}{}]>)]}{{{({[]}({}))<((){}){{}<>}>}{{
[<{([{(<{(((([()<>]<()<>>)[[<>()]([]{})])[(({}()))<<<>()><[]>>])[<{{<>{}}[()()]}(<[][]>{()()}
({(({{<[{<{((<{}{}>{{}[]})<{{}()}{{}()}>)[[({}()){[]<>}]{<()>[{}<>]}]}><{[[(<>{})<[][]>]<{{}<>}{{
(({{(({(<[[{[<<>{}>{[]()}][{[]{}]{(){}}]}(((()[]){{}{}})<(()())>)]([<[{}[]]>])][<{{[{}[]]<<><>>}{[[
((<[[<<<[([<[<<><>>([][])](<[][]>{<><>})>((({}<>)((){})))>[[<[<><>]<{}<>>><({}[])([]{})>]])[{[{({}<>)[()[]
[<((({{({(({<(()())<{}[]>>(<[]{}>({}{}))}))[<<[({}[])[{}[]]]<{{}{}}{[]}>>>]}[(<({<{}()>[<>()]}[<[]()>((){
[[([(((<{[[[<[{}()}({}<>)>]]{<{{<><>}({}())}{{<><>}([]{})}>}]}[([{[{[][]}(()<>)]{{<>{}}[<>(
<<([<{{<{<<(<([]<>)><(<><>){{}{}}>)<(<()<>>([]<>)){(<>{}><<>>}>>{(((()[]){{}[]})[[[][]][{}[]]])({([
[<[{<[<<(([{({[]{}}([][]))<[()<>]{{}<>}>}]<<[<{}>[<>{}]][([]<>)(<>[])]>[{((){})(()())}<[{}()]{<>()}>]>){([
[[[{[(({<<{{{((){})({})}{[<>()]([]<>)}}{[<<>{}>[{}[]]][[{}<>][()<>]]}}>{<{{([]{}){{}[]}}<{<>{
{{{<{[[<[{[<[<<>()>{{}()}][[<>{}][[]<>]]>]<{<{(){}}({}{})><(<>())[{}()]>)<{[()()]}[<()<>>(<>)]>>}
(([[<{(([<[((<(){}>[{}()]){([]{})[<>{}]})[[[<><>](<>[])]((()()))]][{{<()[]><<>{}>}}]>])<({[[({()<>}[<>{}])]]
{{({[({[[<(((({}[])(()()))))(<<<{}()>[{}]>>(<[<>[]]{[]()}>{({}<>)([][])}))>]{({{<(<><>)>[{
<<((({[([[{<<{<>{}}[[][]]><{()()}<{}<>>>>}[[[<<>()>([]())]({<><>}{{}[]})]<{<{}<>>[[]()]}{{(){}
<[{(([<(<{{[[{{}()}([]<>)](<{}()>{[]{}})]}<[[<()[]>(()())]{([]{})[<>{}]}]<<{[][]}><<<>()>>>>
<([(([{([([(<[{}[]][[]()]>(<{}[]>[<><>]))<<{{}()}<<>[]>>>])[[<[{<>()}[()()]]<[{}()]((){})>>]{[{(()[])<(
((<([<[[{[{{[(<><>)<[]()>][(<><>)[<>{}]]}}<(([{}()]{<><>})<([])[()()]>)>]{(({[()[])[[]()]}[(<>)])[<{{}
{<{<<{{[{<(([{(){}}<<>[]>]<{{}{}}{()[]}>)[<[[]{}><<><>>><[<>()]>])>{(<({{}{}}{<>{}})[<<>[]>]>)((<{
[<<<(({{{[(<{([][])[{}<>]}<(()[])(()())>>[{{<>{}}({})}[<<>>[<>]]]){([{()()}[()[]]]{[()[]]<<>>
<{{{<(<<{([[(<{}()>(<>{}))]](({[[][]]}({[]<>}{[]<>}))<([{}{}][[]])[<[]()><{}<>>]>))[<<<<()><[][]>>{(()())<[]
{{[[{[[{{{[{([<>[]][<>[]>)[({}[]){{}{}}]}[(((){})[()])(({}[])[<>])]]}<[<{<[]{}>({}<>)}{[{}[]]((){}
{([<([([{(((([()[]][[]<>])[<[]()><()>])({({}{})<[][]>}[([]<>){[]<>}])))<<{[[{}{}]][{(){}}{[]()}
<<[(([{<((<[({<>{}})[(()){[][]}]]>))>}]<({((([{([][])({}<>)}<<()()>([]())>])){{{{[{}{}]<<>[]>}{(()[])
[[{<([[{<{((({<>{}}[{}{}])([[]()]{{}[]}))({<[][]><<>{}>})){<(<<><>>({}<>))<([]){<>{}}>>(<<<
([({<<{<(<((<(<>{})({})><[[][]](()())>)([[{}{}]([]())][<()[]>[{}[]]])){<[<{}{}]{<>()}][([]{}){<><>}]>}>)>{[[(
{<(([<([(([(({[]<>}[{}<>])[(()<>){()[]}])<<{[][]}>({<>[]}{[]<>})>]{{{<(){}><()()>}({[]{}}{{}[]}))([([]())
{[<([[{[({[<{{(){}}}{(()[])<()[]>}>]<<<{()[]}><{{}()}([]{})>>{{<<>()><<>[]>>{{<>[]}{<><>}}}>
(<(<{[{[([[[([<><>])][({[]{}}({}[]))]]])[<[{({{}<>}([]()))(<{}><()()>)}(<<{}<>><<>()>)<<{}
(<[(({{<[{({{<()[]>}{{<>}<<>[]]}}{[{<><>}[{}<>]]((<>))})([[[<>{}]]<([])>])}{<({<[]<>><<>()>}[({}())[<>
{[({([(<{[[[<<<>[]>(()<>)>]<(([]{})[[][]])(<[]()><{}<>>)>](({{<><>}<()<>>}{[{}{}]([]<>)})[<{<>}[[]{}]

10
2021/inputs/day11 Normal file
View File

@ -0,0 +1,10 @@
4743378318
4664212844
2535667884
3273363861
2282432612
2166612134
3776334513
8123852583
8181786685
4362533174

24
2021/inputs/day12 Normal file
View File

@ -0,0 +1,24 @@
yb-start
de-vd
rj-yb
rj-VP
OC-de
MU-de
end-DN
vd-end
WK-vd
rj-de
DN-vd
start-VP
DN-yb
vd-MU
DN-rj
de-VP
yb-OC
start-rj
oa-MU
yb-de
oa-VP
jv-MU
yb-MU
end-OC

795
2021/inputs/day13 Normal file
View File

@ -0,0 +1,795 @@
241,142
57,889
1131,239
1076,828
495,612
656,775
977,665
65,627
1004,401
1245,627
567,750
1197,194
654,822
214,644
25,738
256,784
1044,485
957,102
291,673
271,715
400,182
415,245
1083,777
995,486
932,695
951,590
376,184
1200,879
234,156
276,807
1019,221
1110,171
764,54
594,317
706,711
348,485
567,751
835,360
239,425
169,634
1205,131
628,159
363,682
664,124
1096,26
1126,849
309,217
341,509
612,365
787,878
1096,560
378,599
956,112
1222,178
947,682
514,750
542,876
706,560
514,144
721,175
355,511
736,513
1260,560
20,746
28,211
721,681
604,199
589,715
140,555
967,550
877,565
1004,605
157,649
797,514
157,612
376,262
726,336
239,701
1126,798
1197,700
1290,596
390,607
226,791
254,182
1059,565
195,464
95,462
1064,494
656,248
1201,159
1191,843
157,359
105,439
1125,346
470,350
840,361
475,655
1159,486
982,241
515,301
415,469
557,175
179,534
850,632
1310,653
25,828
469,794
768,196
179,140
776,528
1265,348
1049,136
82,494
1103,639
57,5
706,199
1131,140
1010,782
956,782
1069,752
1135,178
760,109
30,400
214,71
221,539
915,880
105,91
751,432
1131,886
803,803
194,794
668,386
475,136
738,809
485,604
900,520
1305,306
1258,186
490,184
276,711
1140,198
1155,556
393,345
349,156
74,682
716,409
835,463
537,585
343,550
642,386
264,607
445,809
353,102
147,136
654,72
1159,408
716,317
1153,535
1153,649
1246,523
1201,761
77,599
214,876
85,711
882,551
594,577
17,117
808,464
102,485
181,117
930,193
485,148
522,411
88,548
82,641
415,873
430,261
850,140
841,346
661,761
1066,465
80,381
612,529
604,830
922,633
557,271
982,38
105,117
773,757
1064,752
1228,641
176,50
682,159
947,660
278,126
1071,425
1282,379
1083,565
75,730
830,883
1215,350
989,540
50,707
30,259
888,11
1201,180
632,773
897,752
1096,868
1039,715
841,548
604,560
1228,361
604,407
542,606
781,614
716,45
321,164
1305,588
378,466
1262,38
523,430
1015,142
1250,577
321,87
455,451
301,794
1201,831
87,751
1078,459
227,777
818,870
708,260
1207,44
967,136
1071,693
1230,694
554,287
937,285
1275,862
1096,879
868,40
728,264
1255,120
1258,193
898,31
485,232
493,432
8,882
244,353
50,560
649,596
914,211
1009,550
162,248
765,266
1029,197
999,662
1116,262
922,200
1258,813
549,551
132,754
1004,289
1228,494
1148,248
266,409
507,310
87,591
1148,465
1282,211
676,298
1213,773
1076,724
192,95
586,871
813,130
422,883
1203,395
994,435
835,136
835,239
408,513
321,535
1026,814
278,38
721,715
684,543
1210,103
1062,129
795,301
80,246
547,296
266,697
109,133
1260,793
433,565
1288,121
31,128
422,11
343,214
537,137
113,418
663,786
584,269
428,551
821,880
475,491
773,533
1236,660
396,211
589,213
848,543
900,429
818,24
109,581
105,791
880,261
1096,242
602,81
151,520
363,221
7,338
840,466
507,214
316,710
1101,796
639,662
565,502
934,574
803,584
922,493
261,758
1091,395
766,879
1245,267
1124,681
654,418
1245,696
266,493
1207,626
646,124
1076,211
1277,712
1054,784
5,456
594,409
103,268
929,210
1211,329
731,255
181,777
647,556
572,494
962,401
788,698
1052,423
363,212
633,380
801,565
856,378
1208,25
1245,715
348,849
760,561
731,117
502,235
266,485
691,227
523,878
1310,241
877,833
363,225
221,61
903,73
656,822
1019,212
1011,623
55,774
1283,271
962,267
687,80
408,142
1223,751
691,480
716,401
1289,828
1206,675
1131,360
967,214
566,794
214,375
162,86
1148,86
301,290
681,290
396,683
268,101
455,443
1284,560
1236,234
199,443
490,486
869,700
684,473
768,197
1021,726
311,680
803,399
856,516
467,334
1066,30
92,514
184,849
572,137
574,513
1235,117
870,252
769,194
661,92
97,719
525,294
328,241
95,350
470,361
1230,246
972,177
1205,803
373,285
142,25
475,534
502,883
1011,63
594,401
594,849
1253,889
1096,625
162,808
708,708
807,374
1071,21
621,854
432,449
761,509
1268,529
619,862
185,346
989,140
333,730
1287,789
167,730
430,633
378,295
315,486
1143,612
266,633
619,480
237,54
1034,183
768,249
321,428
284,814
53,12
492,248
773,85
803,455
989,428
1260,606
266,381
447,502
890,66
807,626
826,646
721,719
1298,386
1260,334
639,232
984,241
761,131
75,164
1036,641
1216,883
333,665
888,256
388,872
549,385
1146,520
522,262
408,400
843,334
194,100
151,486
151,626
65,719
972,688
407,73
475,808
353,100
788,632
917,345
740,98
1071,193
1153,282
420,549
1044,513
129,600
604,549
545,628
258,311
251,565
590,523
584,558
1116,885
75,117
924,793
985,350
336,98
412,31
803,758
929,628
972,733
604,194
415,425
1277,40
1101,85
545,266
1215,462
798,86
661,298
1049,399
1235,526
855,451
604,269
840,533
1129,117
412,191
945,278
246,374
1293,117
698,365
378,428
623,80
276,421
411,381
1248,567
489,14
50,101
351,105
661,596
634,596
1078,11
187,782
52,365
1103,502
21,290
261,399
70,522
768,700
547,395
1168,18
1170,144
1131,207
1034,635
224,633
1198,697
1123,334
74,234
1034,259
132,632
460,754
179,8
142,186
157,805
169,164
26,560
363,669
1257,882
234,828
1084,607
219,403
788,483
475,86
738,757
551,268
999,214
720,371
731,777
184,798
1305,802
1056,264
1062,765
1287,341
300,782
589,457
194,306
351,119
879,44
1158,435
333,754
686,35
807,38
1201,628
604,569
179,136
513,514
264,119
207,502
918,75
386,793
103,626
281,53
416,614
557,623
678,121
898,191
562,784
291,3
23,229
112,698
83,513
1091,499
604,625
929,511
917,121
306,858
567,303
60,409
284,80
1038,168
1290,298
417,840
475,239
365,278
10,357
460,710
1273,278
914,722
276,635
107,395
326,38
232,11
274,813
52,36
761,551
105,803
97,47
837,777
1134,760
142,96
738,400
922,175
1032,768
646,434
877,329
179,758
378,487
1034,421
162,429
60,241
460,306
1246,371
689,854
349,548
289,616
175,178
1233,599
1257,133
574,648
1159,520
1086,633
914,683
691,526
706,700
239,245
1287,229
175,716
276,183
820,856
837,117
1103,703
1170,555
1260,288
1034,199
1260,707
410,80
1141,306
567,591
348,401
169,306
276,259
251,789
1302,460
706,382
807,520
989,164
1021,840
989,730
435,296
1115,464
1110,826
816,415
736,246
507,584
776,366
299,271
1289,290
894,614
813,425
325,350
321,354
1001,217
957,100
1285,828
764,840
392,819
529,614
1200,431
1049,267
1280,259
316,206
580,660
207,639
5,306
137,603
706,247
184,45
550,333
50,869
289,168
1043,492
10,296
1303,108
184,533
303,105
679,889
934,618
649,438
462,351
23,553
894,728
1201,714
1004,858
880,421
1250,689
666,849
272,726
214,652
316,733
485,341
1258,529
42,813
484,198
763,403
306,401
381,658
863,278
763,499
28,351
388,633
1287,889
35,227
929,658
232,435
773,585
721,457
343,758
671,232
922,694
1088,667
661,754
803,491
1032,38
567,865
494,415
507,491
1148,696
1116,588
1223,469
869,28
5,140
667,38
195,528
fold along x=655
fold along y=447
fold along x=327
fold along y=223
fold along x=163
fold along y=111
fold along x=81
fold along y=55
fold along x=40
fold along y=27
fold along y=13
fold along y=6

102
2021/inputs/day14 Normal file
View File

@ -0,0 +1,102 @@
PBVHVOCOCFFNBCNCCBHK
FV -> C
SS -> B
SC -> B
BP -> K
VP -> S
HK -> K
FS -> F
CC -> V
VB -> P
OP -> B
FO -> N
FH -> O
VK -> N
PV -> S
HV -> O
PF -> F
HH -> F
NK -> S
NC -> S
FC -> H
FK -> K
OO -> N
HP -> C
NN -> H
BB -> H
CN -> P
PS -> N
VF -> S
CB -> B
OH -> S
CF -> C
OK -> P
CV -> V
CS -> H
KN -> B
OV -> S
HB -> C
OS -> V
PC -> B
CK -> S
PP -> K
SN -> O
VV -> C
NS -> F
PN -> K
HS -> P
VO -> B
VC -> B
NV -> P
VS -> N
FP -> F
HO -> S
KS -> O
BN -> F
VN -> P
OC -> K
SF -> P
PO -> P
SB -> O
FN -> F
OF -> F
CP -> C
HC -> O
PH -> O
BC -> O
NO -> C
BH -> C
VH -> S
KK -> O
SV -> K
KB -> K
BS -> S
HF -> B
NH -> S
PB -> N
HN -> K
SK -> B
FB -> F
KV -> S
BF -> S
ON -> S
BV -> P
KC -> S
NB -> S
NP -> B
BK -> K
NF -> C
BO -> K
KF -> B
KH -> N
SP -> O
CO -> S
KO -> V
SO -> B
CH -> C
KP -> C
FF -> K
PK -> F
OB -> H
SH -> C

100
2021/inputs/day15 Normal file
View File

@ -0,0 +1,100 @@
3885193879879881648295721863446819761149766587914443899626972913439119995971841919742454431896714994
7771129199159639477916156846991956691722436614294489569877288313857938998569854848811311873297851994
5397898789999499191819517198785943798491221139523487792596493985724999919868993675269878171629998699
8959899713991722957643961289419687998443291919429187159951653349827977821257719997961312718268193198
2846219932569842879891692234614311812799724893633989588399819579153814261516987262948716511752796311
6725199579118269699472336812618911979957922329399797959986179939314145983243295469598939327129574198
6818219696128568181789718885928896191549477191193599939262477914196391139665811994294494912838651859
2221716296945891267779128161299579949218877525184884798227965899389488291774899969293987797832516878
9213844231433499999179428692791378242173289513286965996976983442779617964787586326697988447265876996
6313993561615886999167182992899141648998552369794394923931327323397566885891787478878722831777571486
8713991289549818763589939991895849521891966988198382597778921227699759737659939699671923799995284356
9591399317958271818963894572368319763963548141193644118635854987471693848981917779146394281461959595
9371563863819447298489391362565198489677387981171916875818269275785921792592869889719184537255926941
9759413213254611555382917156331878594951999289273329999795947169439981616213999777916131384672945781
3679696586894978847711411569255844845182781854737976795191261169589939159794718699997493872499236216
8494291884994125877784376799158842599959994569992371213981397915549319462895179958195199263973799942
2735796245119192168162841995749994338197856789958799128998179176929129769798961229228259986315798618
3919549626995852791812998455881197733986917951189161796996622918479591289192199822989316196969797761
9221811969262729999666392749549395194914927623938931277683992712289972984156294168596935911994723579
9259839967959351183699987369122784879628595673587616317281991469967675676149919714698676133489158258
1871658432298942253177598476366881898185855558899669482116863111799951999125874191992364757787788358
8739852825782614519891679845942972188264816197178738927924889282235769279955911364987337173691463948
8299121513497179625559826719786159935487869889948649939416556967585528149132799993281891864295925273
9667999482981521598853938199191994937627975958963142955995573785779998768777953536129524791999139921
8565711677873119991423986336939891313758995995761498979518974799162693272998776826559842372285298158
6822737359889336999591591889475198863399198181192341869964891549839939496253238918989492776598168948
1932768376317118329349221931269281281579761312419134999386689181799263851995829415737796344479779161
1146699126764988361859799888677969955699566981916991732711866985948137842221879714999415127978969556
2716826999776621568995483149915971956954949792131367142893274976282898295419519294961429727779179618
9819689511469361769815986275122539755735877514917521784678889599769389571241738999916766875682319681
1739898836468191968269759173841389779923491989982797492258199917378161399777715818949121291398318935
8991681277139272161888388992817669861998471779697922729191795771917917339123894529985942176275989194
8788879213844991256944695116539936618798879147682219917761678773156192616821535733828489999993567517
9792112419978643891198386999273939716785777389699733728699741312154995954284998916346921276226192923
8936179399498567787146928338481217274594929625685299262145795358129817176299499988115561439969169721
3711996665399999667439695218315649989919198455461991968853148989594896318519998541221179229418248199
1291656132987641899759511819979169622814748741595934916983531975799629118915179362474688489529695892
8714922154618318979688217298952681635899934279199225395668557918594721827676544381719997629385251241
9593279399413929493478294797355334766829491318569163644378429481549576659858687835137187849471951446
5854979532981199699169869431926898918194919286675941191958919822798687999927843765176497122196781784
9997819331993888314786377865356591696892611198299964968995887152722272842273694726639232942699932183
1896184172814918918624961195543395551748983681949128898432976291935921971198195382973914172929297364
5837941661987651896287486979997298931652327946749692822583754186238849886262949839188999896727858939
4461864711682831868916812799119298619958698189619694951249686988389189729672287957439646596874979222
9992395918711165753212128992797846899956889991997831181969254119177984939821658789949262131839363344
9913929894915753891516982919449993561972671531999989189396939298993831699699189992855785911896267529
5977191539399768769691985346853389983329338128811976829923188998957757698766999482989529913351836217
5869199599389289736799521175141562189996727899189998168814918991864194179395421179268799759179886971
4995393573286591999148456775893729271716999944792426197991892963522993979581797912398388197438929879
8175985762297792193449825891451669173639831696686977185968298848778111519969913991892852196913658589
7551823929217592981312974557685142328463465848839872122469199897971199199199999869473895171251997563
1487931558946968829951763519656937487546792895476992624978852921947139983499286385266138258935193694
8195371149998678396987884326188152573756198921899135197653384711783648729791328851979354497969392986
9179155119423919779667686698689126113994825739951498172517199198989915292457344126929486295984699195
8692999656696952931996533623896191984859965893774589592193836681957292599821971991739911926636959666
9985998695572727293692296815985734817249613192327999997928979519414463322843958491689891537727548424
6785915139891383111991993528714959958913992938996589981164194172299991578319949554372972869927718986
6812969848431999313262899194267519731924982239497181155761348191171378191195481196281927177836119913
9241449944689196375316993727965949184951599169899984428189812459955788198778389997529996294911755145
8263933869291918953191161435562974124985817581189466197959111943314796298198689894947297889469378986
4993564891474912898412755199548395176295488917317973937991914952763769731425198161936449638498547989
3919725846368347989866832637399995924176992897196895631935386266839399384868371191995999792294157491
6721931979356517372592778489839423879114997193842669196756218474195487978729966911652681225999411831
9597499799876611196188943929378999389985498674958963168888777783921914243997878195898999269889294551
7897535911127197896722972984867282697846153651471124481587828169258769897847822878831383595997369791
5831297848191951191794896484123496673799414573379198153884568889918681971924789669965852999915958216
7823991369999344428821749717198796788139384181691959399667159925814883764695397857939481345499559511
9836733614869491139178987881497398239923811838118399887762713912361489159279391783489832826615994916
5877773698989894889438919996977776999993296984984712292923899479697593879272739579864981289939932771
2542185648228941381995651795998445875943469118314769118387799816194799838958843997735743139876711369
7882123912881669791399598994599691151814649879989998698859687888628677316516841799215998992997293761
7767319886981189839889892188919899791985112499817113117779879369341826441898281556786828873779689187
6517976954449996987552989793838655741268494369149928959518173199587537996199483924421127337969771577
1678653257398811536189799659999587998996928746191167927896289997861386532556616499279932951899917642
9572579385451723885561779217789536117629994941561764419872276282572795264367221933191167982181957692
6315852299992498418936196529371999229568595139535889371219877199885619437539359128266112177998914116
2985881397958192379949795596996995193595668153648864957619593653435123842865151846253963551826892972
9181619666251279936984265494857188682368994967895269896197989182176863694399432137388934122967614868
9593114153726456769958948828218389342288723549641819941784998231817667699584449492849222498974496136
9916299479892917793359999793199917957999777682139987212993989599198969329559479959128381894449114895
4921471293815869819213937928199292981798364834953986973773897966731399149773957385692948461798953879
7939219727388581199654888522599499194589989324361564926162951286688874312293589785941177395118942618
8437633823193749987229493992993524679593478997117499862387295887499449937233698762911944962872393932
1957595152944134991298986921999686429196188856825582891848975799829298278988951176691983617917489212
8139893189759536719371198967498834639886725963146991186976281274983731942436781991256754884914659449
4822925997999862149916429996168888845197975949578265942598274998974448539673169651999879289189841361
5241531889998799394875217768389396418913985512418883112994376949161819917922624829789318615483896826
6952433478181299923958981383758182467119587745189738489917881951247839114135919899874698935397678939
9998178281168138219688629715164393989381385362839223828189989111183769799437851885123913879668776872
3479299968682178666263899849126199949521388659643946294899888287792876178914598796793938289488163984
1225626697911721927373893967969993763233461954269119238318594463694999168939951368891298529984588448
7889492445296989153714423965492969819915271485178757588997394798779977871918771629125225796727359893
5778897199718433999153132896886712358389157788434824924928192158771497689159318619912199459651238768
1795836197799479917189998598989489967373995198279891918988899853122171424496868123951671992389679399
6529853939912918791899868397879535727748279386788285494854993938674449895593868599789269647149499765
1878818925186485199559539319973289118966119867769847635447481798718159348669599911752797688859935711
6236419319741929511583546874658811117988969497296985889278883242999599946847999979139915449889988998
1198678683349613936877939891939118912969187857959968963634732792198997359438989686371429988735182698
1998223474469228586568189895871742229825728879174631691151921998877937199256189155647765161238919158
6432548917454758948968687351996995554975421965763752579179713997554661699137621894836694779175686366

100
2021/inputs/day18 Normal file
View File

@ -0,0 +1,100 @@
[4,[3,[9,[9,0]]]]
[[[7,6],[2,[2,5]]],[5,[[7,3],8]]]
[4,[4,6]]
[[0,[5,6]],[[[1,3],[2,7]],[[0,6],4]]]
[6,[[3,[6,0]],3]]
[[7,[9,[8,5]]],[6,7]]
[[[[2,6],1],2],[3,[8,4]]]
[4,[[[5,4],[2,7]],[[8,0],[2,3]]]]
[[[[4,3],2],[[3,6],[2,5]]],[[[3,7],8],0]]
[[[8,[0,7]],1],[[9,[3,9]],9]]
[[[[3,0],[1,3]],[[0,9],8]],[[[7,2],9],[[1,4],[3,5]]]]
[[[[9,6],[4,4]],[1,3]],[[4,3],[[6,4],[8,4]]]]
[[[1,2],[[7,6],[2,3]]],[[4,6],[4,2]]]
[[[4,8],[[5,8],1]],[2,3]]
[[[5,2],[3,[5,7]]],[[2,9],5]]
[[[6,[3,2]],[2,6]],[[8,[4,2]],[[5,2],7]]]
[[[[2,6],[0,1]],[7,[3,6]]],[[1,6],[[7,9],0]]]
[[[0,3],[8,1]],[[[9,0],3],[0,2]]]
[[8,[[7,1],[4,7]]],[[0,[1,3]],[8,2]]]
[[[[2,3],4],[[0,8],[9,0]]],[1,[[5,3],4]]]
[[[[7,2],2],[[1,3],[8,3]]],[4,[[7,9],[0,6]]]]
[[[[2,2],[3,4]],[[1,5],[4,3]]],[6,[[7,2],1]]]
[1,[[[5,7],0],[9,[8,8]]]]
[[[[9,2],[0,9]],[4,[7,8]]],[[4,8],[[1,8],[4,9]]]]
[[[[4,7],2],2],4]
[1,[[2,[4,2]],1]]
[[[[7,2],[3,8]],[0,[1,3]]],[[[4,4],[2,4]],[8,2]]]
[[[[1,0],[0,5]],2],[[9,[5,0]],[[1,6],5]]]
[4,[[[8,1],[1,4]],[7,[1,3]]]]
[[[6,[0,4]],[[4,6],[2,4]]],[9,[1,5]]]
[[[[3,6],[3,3]],1],[0,[[8,8],2]]]
[[7,[5,[2,6]]],[[[7,9],6],[0,[3,6]]]]
[[[[6,7],4],[[2,9],2]],3]
[[[7,[1,7]],[5,4]],[[[1,1],[0,1]],5]]
[[6,[[1,0],6]],[0,[6,[0,5]]]]
[[[[2,4],[4,6]],9],[4,[[8,0],7]]]
[[[[9,9],[5,7]],[9,[8,6]]],[[3,[2,3]],0]]
[[0,[1,[5,3]]],[3,[8,[3,4]]]]
[[[[4,3],8],[2,9]],[[1,[6,5]],[[5,7],2]]]
[[[0,[7,4]],[9,[9,6]]],[[8,[5,5]],[[6,4],1]]]
[[[[7,3],[7,9]],[8,[6,2]]],[[8,[4,5]],[[6,4],[6,7]]]]
[[7,[[9,0],[9,0]]],[[[0,8],2],[8,[8,3]]]]
[4,[7,[5,6]]]
[7,[[[3,8],8],3]]
[[[4,[6,6]],0],[9,0]]
[[[[7,4],8],8],[[0,1],[[0,0],[2,4]]]]
[7,[1,[[9,4],[3,6]]]]
[[[[2,8],9],[[8,6],[2,2]]],[[[5,1],9],[2,[0,7]]]]
[8,7]
[[[[0,8],4],[[9,9],[9,9]]],[[[4,3],[1,0]],[6,8]]]
[[[[8,3],[8,9]],1],[[4,[1,0]],[[4,0],[2,3]]]]
[[[[4,7],[1,3]],[6,9]],[[1,0],[[1,8],5]]]
[[2,[4,[6,5]]],[3,[[9,9],5]]]
[[[[7,6],4],9],[8,[4,5]]]
[[[0,[6,6]],[7,[8,9]]],[[[0,0],[3,4]],[4,[1,8]]]]
[[[9,[7,0]],[5,8]],[6,[[5,0],[0,6]]]]
[[[[4,0],[1,9]],[7,[3,6]]],[[2,[8,6]],[[2,8],[8,2]]]]
[[[9,6],8],[[[5,5],[4,8]],0]]
[[[[1,7],1],2],[[[6,8],3],[[3,3],5]]]
[3,[5,[[3,8],6]]]
[3,[[[9,6],[5,8]],[9,2]]]
[[6,1],[6,4]]
[[2,6],[[[1,2],2],8]]
[[[[1,7],[3,6]],[2,[0,2]]],[[3,0],9]]
[1,[[0,[4,9]],5]]
[[[[5,5],[5,2]],[0,[6,4]]],8]
[0,[7,[[6,9],[6,0]]]]
[[[[2,2],[4,7]],[[7,4],6]],[[0,[1,7]],[[3,2],6]]]
[[9,8],0]
[[[[5,4],[4,8]],2],[3,[8,9]]]
[[[[7,0],8],5],[2,6]]
[[[5,[0,8]],5],[[[5,0],[1,8]],[[0,2],7]]]
[[[[9,4],8],[[6,5],4]],[[5,[8,9]],[4,[0,4]]]]
[[[[3,6],7],[[9,3],7]],[7,[[8,3],9]]]
[[[[0,7],5],[[5,7],2]],[[2,[9,5]],[[7,7],[5,0]]]]
[[[[7,5],2],[8,6]],[[2,[6,2]],[5,[3,1]]]]
[[9,[9,1]],6]
[[[0,7],[[5,9],2]],3]
[[[9,3],[8,8]],[0,[4,5]]]
[[[[6,2],5],[4,[3,1]]],[9,[2,8]]]
[[[1,[9,4]],[[0,0],2]],[[1,[2,1]],[[7,8],[3,2]]]]
[[[[0,6],[8,9]],[[4,7],[5,6]]],[[[1,4],[8,7]],[4,6]]]
[[[[6,4],[1,5]],[0,8]],[[[9,7],[1,2]],[9,4]]]
[[[[4,5],[0,7]],[9,[1,8]]],[[[5,0],6],7]]
[[[0,[6,9]],[5,[5,6]]],7]
[[4,5],[[7,[6,5]],1]]
[[[7,9],[6,7]],[4,1]]
[[[[9,6],1],[[3,1],[9,7]]],[1,[7,1]]]
[[[0,[2,0]],5],[[8,[7,6]],[[7,3],4]]]
[[[6,[1,7]],[9,[2,7]]],3]
[[[6,[8,2]],5],[4,[[1,3],[5,1]]]]
[[[4,[3,3]],[4,[2,4]]],[5,4]]
[[[1,6],[4,[4,0]]],[[8,[2,2]],[[8,1],[4,7]]]]
[[2,0],[[2,1],[[4,8],[2,7]]]]
[9,[[8,4],0]]
[[1,6],[[5,[1,3]],[9,[0,9]]]]
[[[0,[3,5]],3],[[2,[8,0]],[[2,0],[4,3]]]]
[[[1,[1,9]],[9,[7,9]]],[[2,2],[[6,7],[0,7]]]]
[[[4,6],[[6,2],[0,9]]],[[1,0],[1,[6,7]]]]
[9,[[[0,1],4],[[9,3],3]]]

1027
2021/inputs/day19 Normal file

File diff suppressed because it is too large Load Diff

136
2021/inputs/day19_test Normal file
View File

@ -0,0 +1,136 @@
--- scanner 0 ---
404,-588,-901
528,-643,409
-838,591,734
390,-675,-793
-537,-823,-458
-485,-357,347
-345,-311,381
-661,-816,-575
-876,649,763
-618,-824,-621
553,345,-567
474,580,667
-447,-329,318
-584,868,-557
544,-627,-890
564,392,-477
455,729,728
-892,524,684
-689,845,-530
423,-701,434
7,-33,-71
630,319,-379
443,580,662
-789,900,-551
459,-707,401
--- scanner 1 ---
686,422,578
605,423,415
515,917,-361
-336,658,858
95,138,22
-476,619,847
-340,-569,-846
567,-361,727
-460,603,-452
669,-402,600
729,430,532
-500,-761,534
-322,571,750
-466,-666,-811
-429,-592,574
-355,545,-477
703,-491,-529
-328,-685,520
413,935,-424
-391,539,-444
586,-435,557
-364,-763,-893
807,-499,-711
755,-354,-619
553,889,-390
--- scanner 2 ---
649,640,665
682,-795,504
-784,533,-524
-644,584,-595
-588,-843,648
-30,6,44
-674,560,763
500,723,-460
609,671,-379
-555,-800,653
-675,-892,-343
697,-426,-610
578,704,681
493,664,-388
-671,-858,530
-667,343,800
571,-461,-707
-138,-166,112
-889,563,-600
646,-828,498
640,759,510
-630,509,768
-681,-892,-333
673,-379,-804
-742,-814,-386
577,-820,562
--- scanner 3 ---
-589,542,597
605,-692,669
-500,565,-823
-660,373,557
-458,-679,-417
-488,449,543
-626,468,-788
338,-750,-386
528,-832,-391
562,-778,733
-938,-730,414
543,643,-506
-524,371,-870
407,773,750
-104,29,83
378,-903,-323
-778,-728,485
426,699,580
-438,-605,-362
-469,-447,-387
509,732,623
647,635,-688
-868,-804,481
614,-800,639
595,780,-596
--- scanner 4 ---
727,592,562
-293,-554,779
441,611,-461
-714,465,-776
-743,427,-804
-660,-479,-426
832,-632,460
927,-485,-438
408,393,-506
466,436,-512
110,16,151
-258,-428,682
-393,719,612
-211,-452,876
808,-476,-593
-575,615,604
-485,667,467
-680,325,-822
-627,-443,-432
872,-547,-609
833,512,582
807,604,487
839,-516,451
891,-625,532
-652,-548,-490
30,-46,-14

102
2021/inputs/day20 Normal file
View File

@ -0,0 +1,102 @@
#.#..#.#...##.###.##.#.###....#..##..#.#####.#.##.#.##..##..#.#.######..##..####.#....#.#....##....#####..#######..###..#.##..#....#....#....#..#..#..##...####..###.##..##..#.#.#.#.#.#.#..##.###.##.#.##.#.##.#####..###.#.#...##..##...###...###..##...##.######....####.###...####.##.....###.##.#.##.#.....##.##..###.....#..##....#.##.#...##.###.###.#..####....#.###...#....#..###...##..#####..#.######..#.#....####.####.#.#....#.###..##...#.###.####....#.##.#....##...##.#..#....#.##...#....#.####..#.#..####.#...
####.#.#####..#.#####..###.###...##...##.#.##.###..#...#......##.##..##.####.........#..##...#.####.
#.#.###...###.####....##..##......##.#.####...#########.#.###.#.#.#..###..##...###.###.#.######.#.#.
##...#.#..##.#.##...#..##.####.###.###..###...#####.##.#..##.#.#####.###...#.###.....#######..##...#
####..#.###..####..##...#..######.##.#...#.#..#...#.##..####...##...#.#.#.##.##......##.##.#.##.....
.#########.###.###..#......##.###.####.#..###.#.##.####.#..###....##.##.##.#..##..#..##..#.##.#.#...
..#.#.#...#.###...##..#.#....#.###..#.##...#.#....#.##.#.##.##..###.##.####..#.###.#.####..##....###
.##....#.#.##.....####..#..##...#..............#...###.####....#..#....##.####..###....##...#.###.##
.#.########..###.#..###.#..###.#.##.#.#.#.###...##..##.#.#..#..##.#......###.###..#.##.####.....#...
...###.#...#.##..#...##..###...###...#....#..#.#######...#..##..###.#.#......#.#..###..#.#.###.#..##
..#####...##.##.....#.#####....#..#.#......#.#.#....####.##..#.##.##..##.#########.##.###...###...##
#...#...#####....##.#.#.###......##.#####.#.###.#.#.#.####...##.#..#.#.#..#.#..####..##...#.#....#..
.#..#.##.#.#.##.#..#.######.#.#....#.##.#..#.#.##...####..##.##..####.####.#...#...#####.#....####..
.....#.##..#.#.###.##....##....##.##.#...###.#.#..#.##.###.#...#...#.#####..#.##.....#...#.#.#.#....
....##.##...##..##.########...###...###..###..#..#...####..#..#..####.#..#.#.....###.#..#.#...#..#..
...#.#.#.###...#...#####.#....##..####..##.####.#..###..#.##.###...#...#..#.##...##.#...#.....###...
##....#..#.#...#.......#.##.######....#..##.##..#...###.#..###..#.#..##.#.........##..###.#......#.#
###...#########.#....###...#.#...#.#..#..##.##.#..#.#......##.#.##.#....#########...#.#.##..########
.###...#######.#......####.#.##.###.##.#..##.###.##..########.#..##.##..#..#..#...#.#..###..##...###
..#...##.....#.#..###.#..#.##.#..#.#.#.##.#####....####.#.#..#...##.##.##.#..####.#..#.#####......#.
#...##..##########.......#.....##.####..#####..##...#...##..###.#.#.#.#.#####.####.##.##.#.#.....###
.#.###.#..#..###.#..#.#.#....#.#####.##....#.#.#..##.#.#.#.###.#..#..##..#..###....#...##.#..#.#.#.#
...###.#..#....##.#...#...#..#....###...#.....#..####.##..#.###...#....###..##.#.##...#..##..#.##.#.
#.#.###.#..#....##.#..#####..###...##.##...#...###.#.##.#.#.#...#.#.#....####..#.##..##...#.#.##...#
.#..#..#..##########.#.###.#..##..##.#.##.#..#.##..#..#.#.##....##..##....##.######..#....#.#..#####
...#.##.#.###.#..#####.#........#.#.####.##..##..#.#..##...#..#..#..#.#.#.#..#..#.###..#..#.####.###
.###...###.#..#..#....##.#.##.#.....#..#.#.#...##.##.#...####..##..#.#..#...#....###.#..#####.#####.
...#.#.##.#......#.#....#####..#.#..##..#.#.#..###.##...#..#..##...#...#######.###.#####.###...#....
.##....#...###..####....#.#..##.#.#.##..###########...#.###..#.##.##.##.#....##.##..####......###...
#.##......#.##.###.##...##..#.##.#.##.##..#..#.#####....##.##.###.#########.#..###.....#....##..##.#
#.####.#.#...#.#.#.##..##.###..###.#..#..#####...####.####....#.##...####..#######.#....#######.#.#.
##...#..#...##...#.#...#.##.#......#.#.#.....#.#.#....#.#.#...#.#.#######.##.#.#..##..#....#.#..#..#
#..##..#.#..#.#..#.#.#.#.#....#.#.##.##.#.##.....##...##...##.#####.#.###.#..#..####.#.#..#######.#.
.#.##..#.##..#....##.#.#..#..##..##...#...######.###....#..#...##..#.#..........#.######.........#..
###.#.#..#.#..#.#.#.##..######.#.......###.###.#..#....#.##.#####.#.###.##.####.#.##..##.##.####.#..
##.#...#.....#...##.##.##....########......#.#.#...#.#..#.#....###...##.##...........####.##.##..#.#
####.###.#.#...#.##....#.##..###..#.#.#####..####.#.#..#..#....#...#..#...##...#..#.###..###..#.#.##
#.#..#..#.###....##.#..##.#..#...##..##..#.#.#.#..#...##.######..#.#..####.#.###..####..##...#.#...#
.###...#...#####...#.#...#.##..#...###.##.###...#..#.#.#.#...#.##.##.##.##.##...#...#.###.#.#......#
#.......#.#....####.....#..#.#.#..##.#####..##..#..###.#..#..##...####....##.#.#..###...#.##.#.###..
#.#..#.#.##.#.#####.#######.#####.#..###..#.#.......#.##...#..##..##....#.#..######.....##.##..##.##
#####.#....######.....##.#...#..##....#...###.##..#..##..###.###..###.####..#...#######....######...
#####.........#....#....#..#####.###.#..#.#....##.##..###..#..#.#...#.##...#.#..##..#.#.###.####.#.#
...###.#####.#.##..###.....#.#.......##...#....#.#.##.#......#.#...#.#..#...#.####.######.##...##.##
#...#..#..#..#...##.#.....#.#.##..####..##.#..#.#.#####.#.##.###.#....###...######........#..#..##..
..##.......##.##.#....###.#...#...#.##.###..###.#..####.#.######.#..#######.......#.##..#.####...#.#
......##.##..#####.##....#..#..##.#...#...####..##...##.##.#....#....#.#.###.....##..##.#...##....#.
####...#......#.#........##.#..#...#.#.###..#....##.###.#..#.#.##.##......#.#...#.##...##.###..#.###
.##....##..##.########.##..##..#.#.....#..#...#.#.#.#..#.##..#.##.#..#.#....####......#..#...#.#.#..
.##.#...#.##.##.#.#..###..#.#...##.#.#.#.##..#..######..##.#.##....###.#....##..#.###.##.##..#...#.#
..#.#.#...#...###..##....#.##..#..#...#....#.#...#####...##.####.#.#...#..#.##.###...#...#..#.##....
...#.####.###.#...#####..####.####..#.##...########...#.#...#.##.#.#..##.#..#..##.###.#####..##.##.#
##.#.#..##.###.##.#......###.#..#.#..#.#...#.#.#...#.##.###.#####.##..##...##.#..#..#.....#.###....#
......##.#..###....#.#####.###.###.###...#.....####.###.........#....###.####.#.......#..#........#.
...####.##....#.#.#.#.##..#..#.#..##....#...##..#...#.#..#.####..#.##.##.##......###..#...####..#.##
##.#.#####.....#...####.##.#.#.####.#......#.######...######.##.######....##..######..##.#...##.#..#
..#.##.......#.#####.#......###.###.##..####.#.###....#.###.#..#..#########..#..#..##.##.#....#....#
....####...#.#.#...####.#.#..###...#...#..##.##..####.#.#..##.#.#.#.###...........##..##..####.####.
#.#..###..######..##.##..#...#.#####......#.....######.##..#.#####...##..####.###.#..######...#.###.
..#####.#..#...#.####.###.#..##....####.#.#.#.#.##.####.#.##.###.###...#..#...#.##..##...#.....#....
..#.##.#..##....####.#.....##.##...##.#.#.####.##.#..####...###..#.#.######.#.###..#..#...#....##.##
#...##.#...#.###...#.##...#.#..###.#####.#....#########....##.#..###..##......#.#.........#.#...##.#
##..##.#.#...#..#..#####..#.#....#...###.##..#.####..#......##..##..##..#....#..#####.#.#.####.##..#
#.###...###..#.......#.#.##.##..###.####...##.##.#..#.#..#..#.###...#..######......##...##.##.#..#.#
.####.#...##.#..#...#.###..##.#..##.....###..###..##.####...#....#######.#.############.##.....##.##
#..####.#..#........##.#.#.#####.#.#.#.#.##.#..#...#..##...#...#.#..##.###.#.#######.#.#####..#.###.
#######...#####.#.##..####.#......##.#..#.###.####.#......####.#.##.#..##...#.....#.##.####.##.....#
#.....#......##...#.#.##.####.######...#.....#..##..##.####....##..##..#.#.##..###.##...#.##..#..###
....##.#..#.#..##.####.#.##..##.#.##.##.#..##########.#..##.....##....#.##.#...#.#..#..#..#.#.#.###.
#......###......###.#.#.#..##....##..##..##.#..#.#.####.####...##.#...##.####..#.....#...#.#.#####..
###..###.#...#..###.#......####.##.#.#.###...#..........##......####.###.###.#..#.....#####..####.##
..#.####..#...##.###...####.##.......#.##.##.#.#.#.##....#..###.....#....###.#..#...######.#...#..#.
#..#..#.#..#...#.#.###.####.##........#.##.####..#..############.#.###...###.#######.#.#....#...###.
#.######.###.##.#..#####.#.#....##.#.##..#######..##...##...#...##..##...#.##.##.#####...##.#...##..
##.###.###..##..##.#.#.##..#...#.#...##.#.........#.#.#.......###...#.##..#.##.#.##.####...##...###.
..#.##..####.##...##....###.#...#..#..##.##..###..###.###...#.#.#.####..#.#.##...#.#..####...#..##.#
#.#.#..#....#.#.#.#......#..#..#...#.#...#...#..#..#.##..#..#....#.##..#..#...##.######..#..##.#####
.#..##..#.#...#..#..##....##.....#....##.#..######...##.##.......#.#.....#####.####.#.##.#.#.##.###.
##.#..##.#...#..#.####...###..##.#####....#..#...#.##...#.#..###...####.#.##....#..#.#.##.#..####...
#.#######...##.####..#...#...##.#.###..#..###.#.#..#.###.#.##.#.###....#.##..###..#.#.########......
###.##.###.#...##....#.#..##.###.#..#.#.##.#.##....#.#####...###..###..#..##..#..#.#..#####.###..#..
.###.###.##..##..#######.##########.#.###.#.#.#....#..#.###...##.##.....#..#....###.....#....##...##
##...###.##.##....#.#....#####..#.######.##.#########..#.#...#.##....#.####.#.###.##.####.#.#.#####.
###.###.....##.###.#..##.#...#......#.###.#..##.#...###..##.#.#.#...###.#.#...##..##....#####....##.
#.#..#..###.##.##.##....#..###.#.###..#######.#...####..#####..#.......#..#.#.##.#..##..#.####..##.#
..##....##...###.###...#.###.....####.#..###.#.........#....####.#..#.#.##...#...###...#.##.....###.
.#..#.##.#.#.#.#.#..###.#..#.#.#######.####.###..#.#.##.......##.#...#...##..##.##.#.#..##.###.###..
#.#..#...#...###.#.#....#..#..###.#####.#.#.#..##.#.#........###.#.#...#.....#..###..##.##..###..#..
....#.#..#..##..#....###....#....###..##...#.#....#.###.####..#.#.##.####.#..#..##.....#.##.#...#.#.
...#..#.#.#..#.###...###...####..#....###.##.#..###.##.#.#.#.##...#...#.#...##....#.#.##.#.##..#.#..
##.#..###...#...##..#....###.#.##....##.#.##.#.##....####..#...#.#####.....#.##.#..#.#.###.#....#..#
#.#.##..#..##.##..##.##.#####.####..#..#..#....###.##.#..#####.##.#####..######.#...#...#..#.#..###.
..#.#......#..##.#...#.#..###..####.##.##..#..#####.##....#.##.....###.###........##.......##.#.####
##..##.#.#.#..##..#.#.#..##.#.######...##..##...##..#####.#...#.#.....###.#...##....#...#.#.#...###.
#......#.###.##.#####..##.#..#.#...######....#..#....#...#####.#.#.#.#.#...####..#...#.....#..#.#.##
..##.##..####...##.#...##...#####...#...#.##.###..#....####.#..#..#.####.##..##.#..####..#.#..####..
#####.#...#.##..##.#..####.#.#..#.#....#.####.#.####..#..####...#.#..##.#.#....#####..#..####..#...#
..#.......##.#..##.#..#..#.######.#...#.....###.###.####..#.#....#..#...#.#..#..##...#.##.#######.##
#.##..##..#.#.#####.........###..##.#.#...###.#.###...###.#...###..##..#.###..#.#.#....####...##....
##....#.##.##.#..###...#.#.##..#.#......#...#.#.#.#.#..###.#.....#.##.##..#.###..##..###.##....#####
...#.#..#...#..##...##....##....#.#..###..#....#..#.#.###.....##....#..#....##.###....#.#..#.#.#.#..

2
2021/inputs/day21 Normal file
View File

@ -0,0 +1,2 @@
Player 1 starting position: 7
Player 2 starting position: 3

420
2021/inputs/day22 Normal file
View File

@ -0,0 +1,420 @@
on x=-13..37,y=-36..14,z=-3..45
on x=-1..43,y=-15..32,z=-35..15
on x=-7..44,y=-6..48,z=-13..38
on x=-42..3,y=-42..10,z=-3..44
on x=-34..13,y=-27..27,z=-31..23
on x=-14..39,y=-34..10,z=-40..10
on x=-12..34,y=-25..19,z=-32..15
on x=-47..6,y=-29..20,z=-45..9
on x=-37..16,y=-17..34,z=-25..29
on x=-28..20,y=-19..34,z=-3..47
off x=1..19,y=-30..-14,z=19..33
on x=-34..19,y=-22..25,z=-17..35
off x=-49..-32,y=-26..-13,z=19..38
on x=-28..25,y=-46..2,z=-11..43
off x=-30..-21,y=-44..-26,z=6..21
on x=-20..31,y=-39..11,z=-23..28
off x=33..49,y=29..47,z=8..25
on x=-28..25,y=-26..20,z=-49..-1
off x=-19..-5,y=3..18,z=-44..-27
on x=-34..15,y=-29..25,z=-34..17
on x=-77707..-66888,y=-15495..7977,z=21658..44356
on x=16734..33844,y=-90735..-54900,z=2270..19264
on x=37676..47017,y=-53726..-31603,z=-58485..-51594
on x=-25500..-16563,y=-6468..2463,z=69232..89880
on x=-35872..-12957,y=-84461..-60975,z=-20007..-9532
on x=-89647..-67921,y=-39059..-13640,z=-42281..-6574
on x=47838..82298,y=-43677..-35749,z=9027..31549
on x=-9400..11474,y=-39127..-21505,z=57808..89970
on x=61666..80803,y=10083..24758,z=37048..46860
on x=26068..46741,y=-77898..-58561,z=-30238..62
on x=-22689..-13065,y=-81029..-64591,z=-21055..3749
on x=38030..60209,y=-34391..-15028,z=-55983..-51628
on x=42982..62845,y=-54347..-47689,z=15630..45725
on x=-18872..11038,y=-76016..-52462,z=-42387..-37005
on x=-55695..-38898,y=36001..55982,z=-70788..-36425
on x=-7131..26336,y=42833..63923,z=-64129..-45423
on x=-60488..-40325,y=-47405..-31877,z=48181..58567
on x=-13302..15801,y=73748..92138,z=-34147..-17494
on x=31153..53512,y=41173..61390,z=38591..49656
on x=-35709..-8667,y=-34876..536,z=-79524..-59100
on x=45731..73067,y=50149..54110,z=-34129..-20399
on x=2923..23025,y=53277..82004,z=30350..45240
on x=-34895..-14927,y=27451..50766,z=-67502..-59363
on x=-8366..10206,y=22907..37139,z=70976..78784
on x=26000..31619,y=55905..81695,z=28039..45741
on x=-27099..342,y=70224..85805,z=-6497..11011
on x=-1601..9361,y=-40465..-9946,z=64120..76194
on x=-29110..-17895,y=38967..50663,z=56746..78592
on x=-77526..-50930,y=-60463..-42672,z=-16932..667
on x=-19801..1121,y=-95369..-68521,z=-2863..7840
on x=-56034..-34754,y=-4651..19561,z=61780..87310
on x=50357..81377,y=-54480..-35226,z=-13214..22298
on x=-37854..-29487,y=-24307..-9466,z=-70318..-65828
on x=-87626..-68588,y=-1140..28963,z=23659..43617
on x=10140..45670,y=19441..48501,z=52468..67612
on x=-61161..-46395,y=50168..60300,z=-43642..-22240
on x=-41791..-23146,y=59820..92015,z=-30219..-13117
on x=51416..66401,y=21581..26160,z=36042..66562
on x=43985..71278,y=-76853..-47487,z=10319..33057
on x=16554..44446,y=-83467..-49432,z=27702..46302
on x=-40078..-32697,y=-19712..13098,z=-79179..-70318
on x=-72544..-48748,y=-24529..-10822,z=25757..62217
on x=-49848..-23893,y=49735..70928,z=-17843..4166
on x=46504..62954,y=-63451..-39706,z=-7060..12582
on x=-18091..5639,y=-80367..-60849,z=20700..28381
on x=-70298..-58521,y=-36254..-16840,z=39462..58760
on x=-57895..-36812,y=-80262..-60063,z=17594..35827
on x=66005..74563,y=-40697..-10634,z=-28571..-12651
on x=-34740..-12979,y=14459..27693,z=72315..83610
on x=-54526..-27860,y=20919..36223,z=53916..69317
on x=5482..28204,y=-72328..-47181,z=36101..68864
on x=-10361..18618,y=50680..80016,z=29881..52293
on x=22013..53090,y=61184..77888,z=-690..15445
on x=49878..80860,y=-45597..-24600,z=8773..42131
on x=-21481..-2534,y=-52590..-35874,z=59304..71419
on x=-27491..-2116,y=-57213..-37184,z=35989..58007
on x=-27046..-11339,y=-93198..-69701,z=2894..23463
on x=-49531..-33827,y=-71407..-54183,z=28280..48597
on x=2360..31991,y=25158..56562,z=-80620..-60755
on x=-26128..-998,y=-62930..-52635,z=35279..63815
on x=48650..66941,y=-61055..-28617,z=29166..31637
on x=69844..85996,y=-22985..-2275,z=21553..38166
on x=2845..20505,y=49897..61909,z=53069..67906
on x=-28415..-3203,y=57533..73503,z=21661..31210
on x=8443..20885,y=34174..61857,z=57794..68245
on x=12152..42225,y=17448..37654,z=50480..71531
on x=57295..73077,y=-41599..-9861,z=-67808..-36322
on x=-39269..-26154,y=-14375..14800,z=71243..78784
on x=10757..31258,y=-62179..-38241,z=-79093..-48669
on x=-30816..-13772,y=31105..43599,z=56286..80856
on x=-81989..-50706,y=-30815..-14580,z=18775..44958
on x=40071..59419,y=44624..61873,z=29016..50450
on x=40251..59324,y=-67414..-49803,z=-36761..-11231
on x=27417..46406,y=-66475..-47513,z=-25177..-11900
on x=-65899..-38890,y=-12430..5965,z=57577..63876
on x=-25267..-2876,y=-44000..-32310,z=-80593..-53949
on x=-18326..-7876,y=43132..66145,z=-66613..-36605
on x=-57018..-53229,y=36751..59783,z=-30079..-9617
on x=-66290..-47772,y=-31894..-1002,z=33540..57723
on x=-125..24382,y=-80848..-72343,z=-49693..-15529
on x=-24015..-2898,y=-53625..-39125,z=55225..73628
on x=51897..80923,y=-4054..3520,z=-45412..-36746
on x=-30093..-1431,y=34246..47381,z=-75270..-59132
on x=31766..51586,y=48710..67006,z=39768..49335
on x=-20923..6424,y=1580..14928,z=-89071..-61335
on x=-78388..-68973,y=2726..15396,z=31839..51487
on x=-17101..1916,y=-31904..-18696,z=62499..86196
on x=60981..74827,y=-33558..-6318,z=17172..47217
on x=-3097..3774,y=74123..95012,z=-15851..19259
on x=-29901..-26536,y=-5670..9081,z=62581..77681
on x=-23676..-6641,y=-87054..-60450,z=6151..27241
on x=-75546..-60657,y=-46787..-18586,z=6164..28899
on x=-62447..-45293,y=-55081..-38324,z=-45488..-36816
on x=-35053..-11420,y=-78994..-73796,z=-27546..-2495
on x=14791..35832,y=8044..17682,z=-75881..-70257
on x=37114..54311,y=-62857..-40402,z=42866..62581
on x=-78891..-57261,y=-19933..2380,z=-46848..-34329
on x=-40885..-31987,y=56185..85808,z=-12714..14124
on x=-22584..-1227,y=62080..69853,z=31132..43774
on x=21369..37041,y=-29949..1877,z=-84346..-70161
on x=-32994..-11854,y=-23931..-13655,z=68474..75824
on x=28950..44900,y=37331..65913,z=-53762..-21514
on x=14251..32416,y=-59808..-39089,z=-69466..-54177
on x=-1001..11349,y=-91855..-70109,z=-20491..-5599
on x=-55376..-22523,y=26566..45387,z=53177..76643
on x=5773..21346,y=-24068..-6968,z=63947..88583
on x=-61909..-45698,y=56099..78327,z=-6552..20928
on x=-91524..-56986,y=-1853..11970,z=13238..33401
on x=65923..82086,y=-3320..28990,z=2252..31777
on x=-49874..-21418,y=3494..29323,z=-69436..-64723
on x=73184..89417,y=-42741..-7654,z=2716..14770
on x=-19543..5754,y=-45523..-35685,z=-69929..-58853
on x=20033..44221,y=-84229..-57579,z=-8712..5719
on x=-91462..-67462,y=4054..26833,z=-39415..-13802
on x=27732..50763,y=-58005..-35512,z=-66011..-34072
on x=27133..51350,y=45426..71070,z=-8192..-4652
on x=32748..56378,y=-70321..-50194,z=26633..50320
on x=-79635..-59790,y=-1252..13376,z=19282..37497
on x=63307..93679,y=7073..20800,z=1161..28560
on x=-36145..-14630,y=-37537..-21452,z=56070..76078
on x=30686..50529,y=-67131..-36989,z=35265..66047
on x=-15752..-11751,y=59850..88935,z=18731..42395
on x=38283..60807,y=51015..57433,z=-40995..-25599
on x=-28800..-5978,y=73498..82844,z=-33104..-12502
on x=38063..67439,y=-35709..-20195,z=-53965..-32238
on x=-68345..-50452,y=8456..26579,z=30921..48065
on x=-32241..-19903,y=41696..65189,z=51000..65538
on x=36262..42472,y=-64295..-31497,z=-60784..-48215
on x=-19510..-110,y=31699..54917,z=-67629..-53476
on x=-62256..-40043,y=-35060..-34579,z=-70111..-50680
on x=-39707..-23353,y=-19810..6512,z=-87108..-53181
on x=-82176..-51976,y=-50348..-40880,z=-33910..-14246
on x=-83924..-70902,y=-19175..2985,z=-15384..15455
on x=49316..72497,y=425..6060,z=52206..70825
on x=-83699..-57057,y=-27150..-4795,z=22540..29041
on x=-3101..12001,y=68638..91778,z=-40657..-29719
on x=2252..24442,y=34848..55848,z=-75998..-48307
on x=-5069..16361,y=-20661..-2439,z=65914..86332
on x=-57402..-38222,y=-69446..-40489,z=-54314..-29224
on x=-13242..408,y=68201..84940,z=-45871..-38004
on x=56749..63913,y=-8638..3672,z=47720..62702
on x=54011..76285,y=-62270..-39823,z=-22993..-14872
on x=58382..77062,y=-20697..-7882,z=46625..52172
on x=-47219..-11653,y=26546..45116,z=-73892..-62298
on x=52120..73926,y=32675..54357,z=-45806..-32181
on x=-11456..-3541,y=-68839..-41789,z=45637..76793
on x=-45992..-25163,y=70590..94451,z=-3611..27080
on x=-77343..-54249,y=25725..46466,z=-7443..1553
on x=53624..60939,y=16322..19384,z=-60689..-54993
on x=-62023..-51180,y=-11378..-249,z=-60785..-36599
on x=51752..62523,y=-55025..-48761,z=-35067..-13224
on x=-79436..-62124,y=17736..25062,z=-33415..-15642
on x=58309..68890,y=-53920..-35770,z=-5858..12657
on x=-70319..-60470,y=13686..43339,z=-44612..-11192
on x=-14271..3865,y=-5940..16892,z=-89272..-77708
on x=56603..74277,y=-30330..-17500,z=-65513..-34252
on x=70395..81599,y=-8116..-4807,z=-47231..-23373
on x=26409..53159,y=37900..58813,z=-58362..-44114
on x=-6833..22656,y=49013..66204,z=-64722..-42138
on x=-79939..-47600,y=-54134..-42160,z=7100..29266
on x=-12387..1516,y=-93270..-73717,z=21246..31778
on x=-68856..-43032,y=-13298..19069,z=45157..61355
on x=-52372..-35450,y=7419..16683,z=-86081..-55547
on x=24953..45687,y=45007..63906,z=14094..39220
on x=-55616..-27396,y=62300..72738,z=-2200..9190
on x=50053..83913,y=-11119..-1995,z=-60574..-21845
on x=-34214..-11133,y=-11996..-4356,z=72157..82626
on x=-81300..-54391,y=-17887..-200,z=31179..50660
on x=-16117..18870,y=61218..84345,z=33172..58266
on x=-94022..-70920,y=422..21148,z=-40110..-4601
on x=7997..32024,y=-93325..-76394,z=-1522..5982
on x=-9500..16520,y=23350..46041,z=-88268..-58078
on x=-23747..-4542,y=-58091..-41118,z=62263..73989
on x=-17732..-2905,y=-95543..-64883,z=-1683..25695
on x=75498..83226,y=-6258..14464,z=2112..14733
on x=20265..41561,y=11946..41840,z=50936..79878
on x=53047..82535,y=-14468..1393,z=-43142..-21193
on x=27130..52544,y=57145..81711,z=-35213..-9752
on x=-45338..-15941,y=-19607..110,z=67448..89256
on x=-59996..-26746,y=2539..21005,z=53468..67082
on x=3402..28703,y=-93591..-66413,z=8528..10542
on x=-49409..-35285,y=32697..52202,z=48515..71687
on x=49025..53870,y=-9075..16495,z=-66082..-46321
on x=30601..51564,y=-69996..-47533,z=-25031..2209
on x=5635..35015,y=53724..79653,z=-26973..-16059
on x=55318..86926,y=-23333..-9355,z=7047..44226
on x=-30289..-12285,y=-68389..-57981,z=-48161..-40552
on x=58882..92805,y=23648..37563,z=5964..22967
on x=34496..42738,y=-72380..-48483,z=-34740..-955
on x=20317..32221,y=20101..38130,z=-86821..-68574
on x=-34120..-25879,y=-55894..-44842,z=-55903..-40976
on x=-45645..-28331,y=-74951..-59701,z=30291..41140
on x=-18717..-645,y=-49850..-25005,z=-85064..-56705
on x=-66069..-62114,y=-7151..16958,z=31325..61285
on x=-8768..2875,y=70141..79960,z=-16283..162
on x=48671..75660,y=34126..57253,z=25955..40686
on x=1592..40495,y=17266..42218,z=53722..79079
on x=-19745..6994,y=-93790..-75591,z=-28647..9949
on x=-33893..-12969,y=-90507..-60780,z=-42644..-10587
on x=60910..79183,y=-49087..-26806,z=-209..8359
on x=-35209..-832,y=18733..37433,z=-77554..-53413
off x=-24707..-6441,y=-41376..-10856,z=55331..90949
off x=6474..32653,y=-14454..17574,z=-88453..-71268
on x=-13493..-6403,y=47314..66556,z=-54874..-29147
on x=-9291..12608,y=53741..85000,z=-46306..-17017
off x=13983..32183,y=38353..59846,z=44630..60489
on x=-20250..12042,y=6499..35623,z=-81728..-71834
off x=-12034..26843,y=-13773..3,z=-84021..-75465
on x=-26797..-16552,y=-49960..-32197,z=-65821..-61668
on x=8368..23515,y=21417..44347,z=55621..84595
off x=49540..69051,y=31705..39693,z=-42453..-14061
on x=-69780..-50337,y=-64895..-31351,z=-1140..22240
on x=70874..82029,y=-4927..29616,z=-17097..7597
off x=-35974..-21133,y=-17861..70,z=66698..84031
off x=-47342..-11961,y=-672..21189,z=-74692..-65282
off x=24383..49319,y=48619..83833,z=15987..31130
off x=4559..23214,y=61581..86675,z=11178..41759
on x=61861..73539,y=-60405..-42686,z=5953..23802
off x=-59929..-28960,y=-56097..-28974,z=-52538..-46415
off x=-72615..-55995,y=-36832..-13278,z=19227..40885
on x=-12406..8284,y=-92734..-74910,z=-35203..-11978
off x=11249..35967,y=28322..57776,z=56548..84816
off x=44731..62241,y=35624..44662,z=-66511..-34520
off x=-87104..-74134,y=-13992..12953,z=-3294..10178
on x=-28985..-3937,y=-56788..-26115,z=63095..78456
off x=22993..41149,y=-72025..-38641,z=53155..65281
off x=-70263..-64986,y=10277..24698,z=17534..54469
on x=33137..54068,y=49394..60447,z=14589..36485
off x=1761..5646,y=-30207..-23218,z=67948..86068
off x=23532..51240,y=-68091..-30165,z=-66152..-47659
on x=63492..78630,y=26451..49621,z=-16485..2633
on x=61364..70239,y=-44857..-25262,z=-8792..15341
off x=-44240..-24659,y=40477..65486,z=46273..50810
on x=-82196..-65068,y=22741..26991,z=21666..26831
on x=19512..39779,y=51290..71942,z=33521..52593
off x=52818..66473,y=38215..68935,z=11423..29773
off x=19475..48035,y=50117..69010,z=-49063..-24987
on x=-14143..9865,y=-10817..8431,z=65536..80561
off x=-72733..-48163,y=-25291..-9724,z=-66757..-36479
off x=-43106..-20567,y=58626..65043,z=30453..56787
off x=13154..16214,y=5656..13752,z=66016..80418
off x=-11408..18735,y=39272..59415,z=60254..73108
on x=-77078..-61965,y=-17101..-10110,z=44955..62934
off x=40661..68779,y=45899..59382,z=-21792..-15201
off x=53315..78287,y=-31686..-15404,z=-41990..-23080
off x=-18699..12677,y=-34848..-11433,z=63732..95545
off x=-24502..-17077,y=-91563..-71124,z=15320..22882
on x=24300..44953,y=-8117..20940,z=-85817..-64192
off x=-57159..-39199,y=-29219..-23341,z=-68301..-54847
on x=34394..67095,y=-53551..-28864,z=43253..61926
off x=-50069..-30721,y=-14112..20450,z=-84644..-54725
on x=23629..36100,y=59625..71637,z=-42808..-14597
on x=-48311..-40298,y=-52473..-36850,z=-55879..-29005
on x=-12671..11981,y=-46219..-25335,z=68262..79543
on x=-4192..11450,y=-33767..-22561,z=62929..78589
on x=-72223..-46005,y=-407..27380,z=-64061..-33742
off x=41077..57062,y=-58884..-45405,z=19829..48890
off x=49487..69913,y=17640..41283,z=44735..66488
off x=-73528..-49377,y=-49007..-39363,z=9948..35961
off x=-71643..-56910,y=30988..61528,z=1455..7445
off x=-37842..-11285,y=64140..77407,z=-1880..26818
on x=-73578..-43035,y=9872..28002,z=44466..65647
off x=326..24287,y=68067..99200,z=-19343..11282
on x=55367..74607,y=22023..39362,z=-34371..-18588
off x=58603..79981,y=-22871..1116,z=22611..39894
off x=47930..73685,y=-6214..-2685,z=-60846..-31022
off x=22820..41562,y=-16265..-4928,z=58506..83229
off x=-88133..-62301,y=15247..30618,z=-10265..10510
off x=1253..22476,y=-60567..-30741,z=51569..81597
off x=63494..75187,y=-55856..-27033,z=-16423..-4091
off x=52204..70316,y=21707..45143,z=24511..43927
off x=27774..33872,y=30457..60549,z=52881..74012
off x=-67751..-48677,y=6535..14109,z=41406..63051
on x=62817..79049,y=4793..27715,z=-40593..-20781
on x=21141..51290,y=-74209..-55507,z=15792..30070
on x=-32225..-15877,y=21103..45553,z=-66267..-46475
off x=-53085..-35827,y=-36046..-19282,z=55940..62461
off x=17599..44204,y=13384..25615,z=-76042..-64772
on x=-23704..-3540,y=-20375..10502,z=59465..97525
off x=-82359..-68971,y=12420..30737,z=-38435..-11957
off x=-40061..-9787,y=-1989..10412,z=57295..74944
on x=-76144..-61483,y=-58373..-37868,z=-43080..-14295
on x=7696..27949,y=-72779..-56254,z=-54768..-32949
off x=39003..59670,y=-62963..-47662,z=1974..16893
off x=29968..35020,y=-22383..-11225,z=61966..80305
on x=50004..63242,y=-20016..6273,z=44941..69658
off x=-59279..-55566,y=-61178..-54387,z=-29065..-8057
off x=-61413..-26740,y=60749..79809,z=-21764..16450
off x=32196..66439,y=-60264..-26865,z=26941..60013
on x=-58520..-43376,y=37472..61676,z=23422..43293
off x=-56396..-25541,y=-68416..-55661,z=-19690..-9207
on x=18618..44778,y=-85629..-64714,z=-8305..17838
on x=-61504..-52282,y=-57912..-39990,z=-14780..6801
on x=11156..42237,y=11867..43976,z=-85896..-64810
on x=-55007..-28867,y=52919..63309,z=-40553..-23411
off x=59765..80865,y=35650..56453,z=-27643..-24090
off x=43182..81228,y=-34129..-7000,z=40063..52672
on x=-13505..20448,y=64022..91445,z=26743..48275
on x=27815..43279,y=-70617..-52124,z=24964..51972
off x=35675..49869,y=-62404..-56365,z=18269..35287
off x=35300..54594,y=35804..62612,z=-52851..-29341
off x=-71395..-53018,y=-19495..-4921,z=24089..52405
on x=-33332..-3755,y=-59570..-40365,z=56013..63939
on x=42324..60577,y=-49964..-34186,z=-52816..-27743
off x=48768..67360,y=-61320..-28892,z=-37831..-21312
on x=16338..40996,y=-53751..-18105,z=48116..68706
off x=-27168..-9712,y=-84533..-68775,z=4825..41138
off x=-60047..-36975,y=37870..61975,z=32191..46708
on x=26376..40244,y=-65020..-54338,z=43732..56693
off x=-91738..-68157,y=-24748..6980,z=-39819..-19451
on x=-5317..14596,y=-21035..-10563,z=71696..82823
off x=49847..64417,y=23298..37336,z=21615..52831
off x=-52432..-40255,y=-26836..-5279,z=-70876..-60890
off x=-20102..9857,y=-1721..20913,z=78025..98271
off x=-4990..6648,y=-21613..4090,z=-86165..-59847
on x=43038..56116,y=-63896..-49438,z=-26881..-4325
on x=-4380..2751,y=55174..85405,z=-46983..-21937
on x=70338..80320,y=-37100..-1120,z=-25918..-14953
on x=-54364..-27158,y=23057..50821,z=50502..69300
on x=1520..12529,y=-78320..-56572,z=38211..50552
off x=49738..66773,y=30561..59431,z=2951..29462
off x=16271..28523,y=-45270..-31343,z=63465..75526
on x=71234..85618,y=-41395..-7960,z=-4130..3364
on x=-69317..-40653,y=-67757..-43558,z=6142..24036
on x=25022..40901,y=-60207..-43245,z=29925..58586
off x=-81117..-47868,y=-43751..-16831,z=-35356..-29663
on x=-1180..17290,y=67627..89970,z=11528..29483
on x=-61937..-38595,y=-63471..-51265,z=-41226..-7643
off x=-79920..-67593,y=23081..43335,z=-27955..-4111
on x=52546..75163,y=49315..56898,z=-14675..7154
off x=3726..34564,y=-66091..-47518,z=-66664..-37455
on x=34949..60501,y=-28771..-11144,z=51352..61485
on x=-12954..14301,y=-93475..-65638,z=-10004..11614
on x=11713..39311,y=-13965..-4062,z=-81763..-73474
on x=51282..59807,y=-57951..-35734,z=5994..36901
off x=-7411..26099,y=32784..55370,z=51744..64477
off x=28307..41980,y=-60121..-44354,z=-62749..-36419
off x=67213..84298,y=-29046..-11454,z=21296..44275
off x=-63074..-36397,y=-44584..-33108,z=-62259..-41864
on x=-52919..-32901,y=-76109..-58400,z=-18640..-10098
off x=22269..46465,y=-75997..-51073,z=-46540..-31244
on x=-13358..1813,y=-48320..-19885,z=65575..90081
on x=57248..73703,y=50245..59021,z=-23752..-325
off x=-61356..-40218,y=-63746..-48236,z=-4162..13109
on x=-86721..-52575,y=18886..39871,z=-27525..-18940
off x=-32958..-9613,y=54585..89567,z=-25434..-6238
on x=-34933..-16868,y=35195..53598,z=53014..59010
on x=-50111..-41812,y=53666..72265,z=-43276..-17297
off x=-48541..-31980,y=-29629..-9928,z=-72149..-56249
off x=8404..34890,y=-91946..-64517,z=-36821..-5171
on x=-61476..-46150,y=34461..64440,z=-52672..-31719
on x=17053..48276,y=8196..30921,z=-90002..-67999
off x=30567..51548,y=48492..49629,z=-60064..-40577
off x=-11485..16121,y=49496..85403,z=-58551..-28464
off x=-71575..-66788,y=-28618..-14850,z=25881..53946
on x=-82870..-69951,y=-31733..-21150,z=2448..31565
off x=21102..31260,y=28479..55875,z=53439..84269
on x=-92343..-73224,y=-5440..30589,z=-11302..13705
off x=57846..67138,y=-51876..-19075,z=25743..40789
on x=-42146..-14334,y=-91427..-56913,z=11466..17841
on x=-8337..5046,y=-97914..-59588,z=-17297..-3854
on x=72959..77792,y=-7695..23596,z=16641..36941
off x=48708..70778,y=-52975..-24049,z=38893..49884
off x=-48001..-30155,y=-34640..-8100,z=-68127..-58824
on x=-23589..-642,y=-55673..-20006,z=53073..77106
on x=-33552..-8377,y=53425..81818,z=-47589..-31657
on x=-4435..19578,y=50903..85239,z=-52340..-31908
off x=-65297..-43991,y=45255..59229,z=-39945..-7463
off x=-27752..-7352,y=56826..62480,z=-59434..-52524
on x=-52395..-36890,y=-60404..-53667,z=-52971..-34646
on x=-17036..-10608,y=22073..34956,z=-87647..-59521
on x=-20406..2585,y=-75526..-51689,z=-53856..-28503
off x=57297..67915,y=40135..59210,z=-10318..20975
on x=54413..78003,y=2451..10064,z=24601..41429
off x=-30323..-21158,y=35905..68915,z=-71573..-39806
off x=-24500..-12434,y=-76402..-60478,z=-18069..-8858
off x=60931..77777,y=-41037..-25321,z=-7530..26700
off x=37607..47278,y=-15018..6458,z=67782..87778
off x=-32488..-5083,y=26413..40281,z=60169..76864
off x=7746..18062,y=45927..81504,z=29094..62804
off x=-60955..-54035,y=33191..54217,z=25181..37101
on x=52094..81032,y=-29343..-25525,z=-50030..-21747
off x=57932..85467,y=-4500..2029,z=-46429..-9720
on x=36386..64660,y=-73512..-44017,z=16903..32394
on x=-1492..33205,y=-82073..-69752,z=5149..23012
off x=-6314..2597,y=-82434..-52899,z=-54568..-42166
off x=47307..75857,y=-39178..-30672,z=23379..47503
on x=64489..84771,y=-20277..-8288,z=-10334..20346
off x=-40498..-13375,y=-21960..-1763,z=-89263..-65000
on x=19554..31662,y=55672..61731,z=-60358..-37905
on x=-39219..-7291,y=35227..63484,z=-72685..-36545
on x=43613..70012,y=-33475..-18062,z=33764..41733
on x=19674..39635,y=-73170..-53816,z=-59139..-34916
on x=-2303..14767,y=69085..89874,z=-44748..-25607
off x=-41923..-21656,y=-11475..12712,z=-92655..-63472
off x=-65609..-28677,y=49338..76417,z=-17143..20767
on x=-66708..-54445,y=-8844..3726,z=40665..69409
on x=57741..80306,y=-53751..-27969,z=-2005..11767
off x=-36833..-8071,y=11487..45001,z=-74496..-55088
on x=-33089..-16969,y=-41928..-15082,z=-82121..-64107

7
2021/rustfmt.toml Normal file
View File

@ -0,0 +1,7 @@
newline_style = "Unix"
max_width = 140
imports_granularity = "Crate"
struct_field_align_threshold = 25
where_single_line = true
edition = "2021"
use_small_heuristics = "Max"

43
2021/setup_day.sh Executable file
View File

@ -0,0 +1,43 @@
#!/bin/sh
today=$(date +%d)
aocd > inputs/day$today
echo '#![feature(test)]
extern crate test;
use aoc2021::common::*;
const DAY: usize = '$today';
type Parsed = Vec<usize>;
fn parse_input(raw: &str) -> Parsed {
todo!()
}
fn part1(parsed: &Parsed) -> usize {
todo!()
}
fn part2(parsed: &Parsed) -> usize {
todo!()
}
fn main() {
let input = parse_input(&read_file(DAY));
println!("Part 1: {}", part1(&input));
println!("Part 2: {}", part2(&input));
}
#[cfg(test)]
mod tests {
use super::*;
use aoc2021::*;
const TEST_INPUT: &str = "";
test!(part1() == 0);
test!(part2() == 0);
bench!(part1() == 0);
bench!(part2() == 0);
bench_input!(Vec::len => 0);
}' > src/bin/day$today.rs

48
2021/src/bin/day01.rs Normal file
View File

@ -0,0 +1,48 @@
#![feature(array_windows)]
#![feature(test)]
extern crate test;
use aoc2021::common::{parse_nums, *};
const DAY: usize = 1;
type Parsed = Vec<usize>;
fn parse_input(raw: &str) -> Parsed {
parse_nums(raw)
}
fn part1(parsed: &Parsed) -> usize {
parsed.array_windows().filter(|[a, b]| a < b).count()
}
fn part2(parsed: &Parsed) -> usize {
parsed.array_windows().filter(|[a, _, _, b]| a < b).count()
}
fn main() {
let input = parse_input(&read_file(DAY));
println!("Part 1: {}", part1(&input));
println!("Part 2: {}", part2(&input));
}
#[cfg(test)]
mod tests {
use super::*;
use aoc2021::*;
const TEST_INPUT: &str = "199
200
208
210
200
207
240
269
260
263";
test!(part1() == 7);
test!(part2() == 5);
bench!(part1() == 1316);
bench!(part2() == 1344);
bench_input!(Vec::len => 2000);
}

68
2021/src/bin/day02.rs Normal file
View File

@ -0,0 +1,68 @@
#![feature(test)]
extern crate test;
use aoc2021::common::*;
const DAY: usize = 2;
type Parsed = Vec<Movement>;
#[derive(Debug, Clone, Copy)]
enum Movement {
Up(i64),
Down(i64),
Forward(i64),
}
fn parse_input(raw: &str) -> Parsed {
raw.lines()
.filter_map(|l| l.split_once(' '))
.map(|(dir, dist)| match dir {
"up" => Movement::Up(dist.parse().unwrap()),
"down" => Movement::Down(dist.parse().unwrap()),
"forward" => Movement::Forward(dist.parse().unwrap()),
_ => unreachable!(),
})
.collect()
}
fn part1(parsed: &Parsed) -> i64 {
let (depth, distance) = parsed.iter().fold((0, 0), |(depth, distance), &mov| match mov {
Movement::Up(x) => (depth - x, distance),
Movement::Down(x) => (depth + x, distance),
Movement::Forward(x) => (depth, distance + x),
});
depth * distance
}
fn part2(parsed: &Parsed) -> i64 {
let (depth, distance, _) = parsed.iter().fold((0, 0, 0), |(depth, distance, aim), &mov| match mov {
Movement::Up(x) => (depth, distance, aim - x),
Movement::Down(x) => (depth, distance, aim + x),
Movement::Forward(x) => (depth + aim * x, distance + x, aim),
});
depth * distance
}
fn main() {
let input = parse_input(&read_file(DAY));
println!("Part 1: {}", part1(&input));
println!("Part 2: {}", part2(&input));
}
#[cfg(test)]
mod tests {
use super::*;
use aoc2021::*;
const TEST_INPUT: &str = "forward 5
down 5
forward 8
up 3
down 8
forward 2";
test!(part1() == 150);
test!(part2() == 900);
bench!(part1() == 1698735);
bench!(part2() == 1594785890);
bench_input!(Vec::len => 1000);
}

110
2021/src/bin/day03.rs Normal file
View File

@ -0,0 +1,110 @@
#![feature(test)]
extern crate test;
use aoc2021::common::*;
const DAY: usize = 3;
type Parsed = Vec<usize>;
fn parse_input(raw: &str) -> Parsed {
raw.lines().map(|line| usize::from_str_radix(line, 2).unwrap()).collect()
}
fn bit_at(x: usize, n: usize) -> bool {
(x >> n) & 1 != 0
}
fn most_common(parsed: &Parsed, bits: usize) -> usize {
(0..bits).rev().map(|n| most_common_at(parsed, n)).fold(0, |acc, b| (acc << 1) | (b as usize))
}
fn most_common_at(parsed: &Parsed, n: usize) -> bool {
parsed.iter().filter(|&&x| bit_at(x, n)).count() * 2 >= parsed.len()
}
fn invert(n: usize, bits: usize) -> usize {
!n & ((1 << bits) - 1)
}
fn part1(parsed: &Parsed, bits: usize) -> usize {
let gamma = most_common(parsed, bits);
let epsilon = invert(gamma, bits);
gamma * epsilon
}
fn part2(parsed: &Parsed, bits: usize) -> usize {
let mut matching_gamma = parsed.clone();
let mut matching_epsilon = parsed.clone();
for i in (0..bits).rev() {
let gamma = most_common_at(&matching_gamma, i);
let epsilon = !most_common_at(&matching_epsilon, i);
matching_gamma.retain(|&n| bit_at(n, i) == gamma);
if matching_epsilon.len() > 1 {
matching_epsilon.retain(|&n| bit_at(n, i) == epsilon);
}
}
debug_assert_eq!(matching_gamma.len(), 1);
debug_assert_eq!(matching_epsilon.len(), 1);
matching_gamma[0] * matching_epsilon[0]
}
fn main() {
let raw = read_file(DAY);
let input = parse_input(&raw);
let line_length = raw.find('\n').unwrap();
println!("Part 1: {}", part1(&input, line_length));
println!("Part 2: {}", part2(&input, line_length));
}
#[cfg(test)]
mod tests {
use super::*;
use aoc2021::*;
const TEST_INPUT: &str = "00100
11110
10110
10111
10101
01111
00111
11100
10000
11001
00010
01010";
#[test]
fn most_common_test() {
let parsed = parse_input(TEST_INPUT);
assert_eq!(most_common(&parsed, 5), 0b10110)
}
#[test]
fn invert_test() {
let gamma = 0b10110;
assert_eq!(invert(gamma, 4), 0b01001);
}
#[test]
fn most_common_at_test() {
let parsed = parse_input(TEST_INPUT);
assert_eq!(most_common_at(&parsed, 4), true);
}
#[test]
fn bit_at_test() {
assert_eq!(bit_at(0b111, 0), true);
assert_eq!(bit_at(0b111, 1), true);
assert_eq!(bit_at(0b111, 2), true);
assert_eq!(bit_at(0b111, 3), false);
assert_eq!(bit_at(0b101, 1), false);
assert_eq!(bit_at(0b11101, 3), true);
}
test!(part1(5) == 198);
test!(part2(5) == 230);
bench!(part1(12) == 3549854);
bench!(part2(12) == 3765399);
bench_input!(Vec::len => 1000);
}

137
2021/src/bin/day04.rs Normal file
View File

@ -0,0 +1,137 @@
#![feature(test)]
extern crate test;
use aoc2021::common::*;
use itertools::Itertools;
const DAY: usize = 4;
const BOARD_SIZE: usize = 5;
type Board = Vec<Vec<u8>>;
const WINNING_INDICES: [[usize; BOARD_SIZE]; BOARD_SIZE * 2] = {
let mut out = [[0; BOARD_SIZE]; BOARD_SIZE * 2];
let mut i = 0;
while i < BOARD_SIZE {
// tfw there are no for loops in const fn
let mut j = 0;
while j < BOARD_SIZE {
out[i][j] = i * 5 + j;
out[BOARD_SIZE + i][j] = i + j * 5;
j += 1;
}
i += 1;
}
out
};
#[derive(Debug, Clone)]
struct BingoGame {
input_numbers: Vec<u8>,
boards: Vec<Board>,
}
impl BingoGame {
fn mark_number(&mut self, n: &u8) {
for board in self.boards.iter_mut() {
// Actually using sets instead of vectors here takes twice as long,
// so just pretend these are actually sets.
for winning_set in board.iter_mut() {
winning_set.retain(|e| e != n);
}
}
}
fn find_winner(&self) -> Option<&Board> {
self.boards.iter().find(|b| has_won(b))
}
// For assertions in the bechmark
#[cfg(test)]
fn len(&self) -> usize {
self.boards.len()
}
}
fn has_won(board: &Board) -> bool {
board.iter().any(|s| s.is_empty())
}
fn parse_input(raw: &str) -> BingoGame {
let (input_numbers, boards) = raw.split_once("\n\n").unwrap();
let input_numbers = input_numbers.split(',').map(parse_num).collect();
let boards = boards
.split("\n\n")
.map(|b| b.split_ascii_whitespace().map(parse_num).collect())
.map(|v: Vec<u8>| {
debug_assert_eq!(v.len(), BOARD_SIZE * BOARD_SIZE);
WINNING_INDICES.map(|row_or_col| row_or_col.map(|i| v[i]).to_vec()).to_vec()
})
.collect();
BingoGame { input_numbers, boards }
}
fn board_score(board: &Board, current_number: u8) -> usize {
let remainder: usize = board.iter().flatten().unique().map(|&n| n as usize).sum();
remainder * (current_number as usize)
}
fn part1(parsed: &BingoGame) -> usize {
let mut game = parsed.to_owned();
for n in &game.input_numbers.clone() {
game.mark_number(n);
if let Some(board) = game.find_winner() {
return board_score(board, *n);
}
}
unreachable!("Game should have ended at some point")
}
fn part2(parsed: &BingoGame) -> usize {
let mut game = parsed.to_owned();
for n in &game.input_numbers.clone() {
game.mark_number(n);
if game.boards.len() == 1 && has_won(&game.boards[0]) {
return board_score(&game.boards[0], *n);
}
game.boards.retain(|b| !has_won(b));
}
unreachable!("Game should have ended at some point")
}
fn main() {
let input = parse_input(&read_file(DAY));
println!("{input:?}");
println!("Part 1: {}", part1(&input));
println!("Part 2: {}", part2(&input));
}
#[cfg(test)]
mod tests {
use super::*;
use aoc2021::*;
const TEST_INPUT: &str = "7,4,9,5,11,17,23,2,0,14,21,24,10,16,13,6,15,25,12,22,18,20,8,19,3,26,1
22 13 17 11 0
8 2 23 4 24
21 9 14 16 7
6 10 3 18 5
1 12 20 15 19
3 15 0 2 22
9 18 13 17 5
19 8 7 25 23
20 11 10 24 4
14 21 16 12 6
14 21 17 24 4
10 16 15 9 19
18 8 23 26 20
22 11 13 6 5
2 0 12 3 7";
test!(part1() == 4512);
test!(part2() == 1924);
bench!(part1() == 74320);
bench!(part2() == 17884);
bench_input!(BingoGame::len => 100);
}

88
2021/src/bin/day05.rs Normal file
View File

@ -0,0 +1,88 @@
#![feature(int_abs_diff)]
#![feature(test)]
extern crate test;
use aoc2021::common::*;
const DAY: usize = 5;
type Coordinate = (i16, i16); // twice as fast as using i64s ¯\_(ツ)_/¯
type Parsed = Vec<(Coordinate, Coordinate)>;
// Memes :pepeHype:
/*
macro_rules! parse {
($($x1: literal, $y1: literal -> $x2: literal, $y2: literal)*) => {
[ $((($x1, $y1), ($x2, $y2)),)* ]
};
}
*/
fn parse_input(raw: &str) -> Parsed {
raw.lines()
.filter_map(|line| line.split_once(" -> "))
.filter_map(|(c1, c2)| c1.split_once(',').zip(c2.split_once(',')))
.map(|((x1, y1), (x2, y2))| ((parse_num(x1), parse_num(y1)), (parse_num(x2), parse_num(y2))))
.collect()
}
fn solve<F: FnMut(&(Coordinate, Coordinate)) -> Vec<Coordinate>>(parsed: &Parsed, f: F) -> usize {
let max_x = *parsed.iter().flat_map(|((x1, _), (x2, _))| [x1, x2]).max().unwrap() + 2;
let max_y = *parsed.iter().flat_map(|((_, y1), (_, y2))| [y1, y2]).max().unwrap() + 2;
let mut counts = vec![vec![0; max_x as _]; max_y as _];
parsed.iter().flat_map(f).for_each(|(x, y)| counts[x as usize][y as usize] += 1);
counts.into_iter().flatten().filter(|n| n > &1).count()
}
fn part1(parsed: &Parsed) -> usize {
solve(parsed, |&cs| match cs {
((x1, y1), (x2, y2)) if x1 == x2 => (y1.min(y2)..=y1.max(y2)).map(|y| (x1, y)).collect(),
((x1, y1), (x2, y2)) if y1 == y2 => (x1.min(x2)..=x1.max(x2)).map(|x| (x, y1)).collect(),
_ => vec![],
})
}
fn part2(parsed: &Parsed) -> usize {
let offset = |x1, x2| (x1 < x2) as i16 - (x1 > x2) as i16;
solve(parsed, |&((mut x1, mut y1), (x2, y2))| {
let mut coords = Vec::with_capacity(x1.abs_diff(x2).max(y1.abs_diff(y2)) as usize + 1);
let x_offset = offset(x1, x2);
let y_offset = offset(y1, y2);
loop {
coords.push((x1, y1));
if x1 == x2 && y1 == y2 {
break;
}
x1 += x_offset;
y1 += y_offset;
}
coords
})
}
fn main() {
let input = parse_input(&read_file(DAY));
println!("Part 1: {}", part1(&input));
println!("Part 2: {}", part2(&input));
}
#[cfg(test)]
mod tests {
use super::*;
use aoc2021::*;
const TEST_INPUT: &str = "0,9 -> 5,9
8,0 -> 0,8
9,4 -> 3,4
2,2 -> 2,1
7,0 -> 7,4
6,4 -> 2,0
0,9 -> 2,9
3,4 -> 1,4
0,0 -> 8,8
5,5 -> 8,2";
test!(part1() == 5);
test!(part2() == 12);
bench!(part1() == 5280);
bench!(part2() == 16716);
bench_input!(Vec::len => 500);
}

44
2021/src/bin/day06.rs Normal file
View File

@ -0,0 +1,44 @@
#![feature(test)]
extern crate test;
use aoc2021::common::*;
use std::iter;
const DAY: usize = 6;
const FERTILITY_CYCLE: usize = 7;
const INITIAL_DELAY: usize = FERTILITY_CYCLE + 2;
type Parsed = Vec<usize>;
fn parse_input(raw: &str) -> Parsed {
parse_nums_comma(raw)
}
fn simulate<const LIMIT: usize>(parsed: &Parsed) -> usize {
let next_fertile_day = |day: &usize| Some(day + FERTILITY_CYCLE).filter(|n| n < &LIMIT);
let mut fish_from_day = [1; LIMIT];
for i in (0..LIMIT - INITIAL_DELAY).rev() {
fish_from_day[i] += iter::successors(Some(i + INITIAL_DELAY), next_fertile_day).map(|n| fish_from_day[n]).sum::<usize>()
}
let adult_from_day: Vec<usize> =
(0..FERTILITY_CYCLE).map(|i| iter::successors(Some(i), next_fertile_day).map(|i| fish_from_day[i]).sum()).collect();
parsed.iter().map(|&i| 1 + adult_from_day[i]).sum()
}
fn main() {
let input = parse_input(&read_file(DAY));
println!("Part 1: {}", simulate::<80>(&input));
println!("Part 2: {}", simulate::<256>(&input));
}
#[cfg(test)]
mod tests {
use super::*;
use aoc2021::*;
const TEST_INPUT: &str = "3,4,3,1,2";
test!(simulate<80>() == 5934);
test!(simulate<256>() == 26984457539);
bench!(simulate<80>() == 365862);
bench!(simulate<256>() == 1653250886439);
bench_input!(Vec::len => 300);
}

41
2021/src/bin/day07.rs Normal file
View File

@ -0,0 +1,41 @@
#![feature(int_abs_diff)]
#![feature(test)]
extern crate test;
use aoc2021::common::*;
const DAY: usize = 7;
type Parsed = Vec<usize>;
fn parse_input(raw: &str) -> Parsed {
parse_nums_comma(raw)
}
fn part1(parsed: &Parsed) -> usize {
let mut nums = parsed.to_owned();
let median = *nums.select_nth_unstable(parsed.len() / 2).1;
parsed.iter().map(|p| p.abs_diff(median)).sum()
}
fn part2(parsed: &Parsed) -> usize {
let avg = parsed.iter().sum::<usize>() / parsed.len();
parsed.iter().map(|p| p.abs_diff(avg)).map(|n| (0..=n).sum::<usize>()).sum()
}
fn main() {
let input = parse_input(&read_file(DAY));
println!("Part 1: {}", part1(&input));
println!("Part 2: {}", part2(&input));
}
#[cfg(test)]
mod tests {
use super::*;
use aoc2021::*;
const TEST_INPUT: &str = "16,1,2,0,4,2,7,1,2,14";
test!(part1() == 37);
bench!(part1() == 328318);
bench!(part2() == 89791146);
bench_input!(Vec::len => 1000);
}

122
2021/src/bin/day08.rs Normal file
View File

@ -0,0 +1,122 @@
#![feature(array_from_fn)]
#![feature(array_zip)]
#![feature(test)]
extern crate test;
use aoc2021::common::*;
use itertools::Itertools;
use std::array;
const DAY: usize = 8;
type Parsed = Vec<([Ssd; 10], [Ssd; 4])>;
const VALID_DISPLAYS: [Ssd; 10] = [119, 36, 93, 109, 46, 107, 123, 37, 127, 111];
type Ssd = u32;
struct Mapping([Ssd; 7]);
impl Mapping {
fn translate(&self, i: usize) -> Ssd {
1 << self.0[i]
}
}
const INPUT_MASK: [Ssd; 8] = [1, 2, 4, 8, 16, 32, 64, 128];
fn parse(s: &str) -> Ssd {
s.bytes().map(|b| INPUT_MASK[(b - b'a') as usize]).sum()
}
fn bit_at(x: Ssd, n: usize) -> bool {
(x >> n) & 1 != 0
}
fn difference(lhs: Ssd, rhs: Ssd) -> Ssd {
lhs & !rhs
}
fn parse_input(raw: &str) -> Parsed {
raw.lines()
.map(|l| l.split_once(" | ").unwrap())
.map(|(input, output)| {
let mut input = input.split(' ').map_into();
let mut output = output.split(' ').map_into();
(array::from_fn(|_| parse(input.next().unwrap())), array::from_fn(|_| parse(output.next().unwrap())))
})
.collect()
}
fn part1(parsed: &Parsed) -> usize {
parsed.iter().flat_map(|(_, output)| output).filter(|input| [2, 3, 4, 7].contains(&input.count_ones())).count()
}
fn part2(parsed: &Parsed) -> usize {
parsed
.iter()
.map(|(input, output)| {
let [&one, &four, &seven] = [2, 4, 3].map(|n| input.iter().find(|s| s.count_ones() == n).unwrap());
// We know the position of a for sure because it’s the only difference between 7 and 1
let a = (0..7).position(|n| bit_at(difference(seven, one), n)).unwrap();
// And c and f are these two (both used in 1).
let (c, f) = (0..7).positions(|n| bit_at(one, n)).next_tuple().unwrap();
// Determine which is which by their frequency in the input.
let (c, f) = if input.iter().filter(|&&i| bit_at(i, c)).count() == 8 { (c, f) } else { (f, c) };
// 4 uses b, c, d, f, but we already know c and f from 1, so this leaves b and d.
let (b, d) = (0..7).positions(|n| bit_at(difference(four, one), n)).next_tuple().unwrap();
let (b, d) = if input.iter().filter(|&&i| bit_at(i, b)).count() == 6 { (b, d) } else { (d, b) };
// Now e and g have to be in the remaining two positions.
let (e, g) = (0..7).filter(|n| ![a, b, c, d, f].contains(n)).map_into().next_tuple().unwrap();
let (e, g) = if input.iter().filter(|&&i| bit_at(i, e)).count() == 4 { (e, g) } else { (g, e) };
let mut m = [0; 7];
let mut cur = 0;
#[allow(clippy::explicit_counter_loop)] // it’s faster this way
for i in [a, b, c, d, e, f, g] {
// We know they’re all in range, and this is actually a few % faster.
unsafe { *m.get_unchecked_mut(i) = cur };
cur += 1;
}
let mapping = Mapping(m);
output
.iter()
.map(|&i| (0..7).map(|n| (bit_at(i, n) as Ssd) * mapping.translate(n)).sum())
.map(|ssd: Ssd| VALID_DISPLAYS.iter().position(|d| &ssd == d).unwrap())
.fold(0, |acc, n| (acc + n) * 10)
/ 10
})
.sum()
}
fn main() {
let raw = read_file(DAY);
let input = parse_input(&raw);
println!("Part 1: {}", part1(&input));
println!("Part 2: {}", part2(&input));
}
#[cfg(test)]
mod tests {
use super::*;
use aoc2021::*;
const TEST_INPUT: &str = "be cfbegad cbdgef fgaecd cgeb fdcge agebfd fecdb fabcd edb | fdgacbe cefdb cefbgd gcbe
edbfga begcd cbg gc gcadebf fbgde acbgfd abcde gfcbed gfec | fcgedb cgb dgebacf gc
fgaebd cg bdaec gdafb agbcfd gdcbef bgcad gfac gcb cdgabef | cg cg fdcagb cbg
fbegcd cbd adcefb dageb afcb bc aefdc ecdab fgdeca fcdbega | efabcd cedba gadfec cb
aecbfdg fbg gf bafeg dbefa fcge gcbea fcaegb dgceab fcbdga | gecf egdcabf bgf bfgea
fgeab ca afcebg bdacfeg cfaedg gcfdb baec bfadeg bafgc acf | gebdcfa ecba ca fadegcb
dbcfg fgd bdegcaf fgec aegbdf ecdfab fbedc dacgb gdcebf gf | cefg dcbef fcge gbcadfe
bdfegc cbegaf gecbf dfcage bdacg ed bedf ced adcbefg gebcd | ed bcgafe cdgba cbgef
egadfb cdbfeg cegd fecab cgb gbdefca cg fgcdab egfdb bfceg | gbdfcae bgc cg cgb
gcafb gcf dcaebfg ecagb gf abcdeg gaef cafbge fdbac fegbdc | fgae cfgab fg bagce";
#[test]
fn test_parse() {
assert_eq!(parse("cgeb"), 86);
}
test!(part1() == 26);
test!(part2() == 61229);
bench!(part1() == 239);
bench!(part2() == 946346);
bench_input!(Vec::len => 200);
}

89
2021/src/bin/day09.rs Normal file
View File

@ -0,0 +1,89 @@
#![feature(test)]
extern crate test;
use std::collections::HashSet;
use aoc2021::common::*;
const DAY: usize = 9;
type Parsed = Vec<Vec<u8>>;
fn parse_input(raw: &str) -> Parsed {
raw.lines().map(|l| l.bytes().map(|b| b - b'0').collect()).collect()
}
fn part1(parsed: &Parsed) -> usize {
find_lows(parsed).into_iter().map(|(x, y)| parsed[x][y] as usize + 1).sum()
}
fn find_lows(parsed: &Parsed) -> Vec<(usize, usize)> {
(0..parsed.len())
.flat_map(|x| (0..parsed[x].len()).map(move |y| (x, y)))
.filter(|&(x, y)| {
// There’s gotta be some incomplete_windows or similar that makes this not as horrible
let cur = parsed[x][y];
all_neighbors(x, y).into_iter().filter_map(|(x, y)| parsed.get(x).and_then(|ys| ys.get(y))).all(|&n| n > cur)
})
.collect()
}
fn all_neighbors(x: usize, y: usize) -> Vec<(usize, usize)> {
[x.checked_add(1).map(|x| (x, y)), x.checked_sub(1).map(|x| (x, y)), y.checked_add(1).map(|y| (x, y)), y.checked_sub(1).map(|y| (x, y))]
.into_iter()
.flatten()
.collect()
}
fn grow_basin(parsed: &Parsed, points_in_basin: &mut HashSet<(usize, usize)>, (x, y): (usize, usize)) -> bool {
let cur = parsed[x][y];
let mut new_points = Vec::new();
for (x, y) in all_neighbors(x, y).into_iter().filter(|p| !points_in_basin.contains(p)) {
if parsed.get(x).and_then(|ys| ys.get(y)).unwrap_or(&0) > &cur {
new_points.push((x, y));
}
}
if new_points.iter().any(|&p| grow_basin(parsed, points_in_basin, p)) {
points_in_basin.insert((x, y));
true
} else {
false
}
}
fn part2(parsed: &Parsed) -> usize {
let lows = find_lows(parsed);
let mut basins = Vec::new();
for (x, y) in lows {
let mut points_in_basin = HashSet::new();
grow_basin(parsed, &mut points_in_basin, (x, y));
basins.push(points_in_basin);
}
basins.sort_unstable_by_key(HashSet::len);
basins.reverse();
println!("{basins:?}");
// basins.iter().take(3).map(|b| b.len()).product();
unimplemented!()
}
fn main() {
let input = parse_input(&read_file(DAY));
println!("Part 1: {}", part1(&input));
println!("Part 2: {}", part2(&input));
}
#[cfg(test)]
mod tests {
use super::*;
use aoc2021::*;
const TEST_INPUT: &str = "2199943210
3987894921
9856789892
8767896789
9899965678";
test!(part1() == 15);
// test!(part2() == 1134);
bench!(part1() == 478);
// bench!(part2() == 0);
bench_input!(Vec::len => 100);
}

103
2021/src/bin/day10.rs Normal file
View File

@ -0,0 +1,103 @@
#![feature(test)]
extern crate test;
use aoc2021::common::*;
const DAY: usize = 10;
fn solve(input: &str) -> (usize, usize) {
let mut p1_score = 0;
let mut p2_scores = Vec::new();
let mut stack = Vec::new();
for line in input.lines() {
match is_well_formed(line, &mut stack) {
Ok(s) => p2_scores.push(autocomplete_points(s)), // <- clears the stack internally
Err(p) => {
p1_score += p;
stack.clear();
}
}
}
let p2_len = p2_scores.len();
(p1_score, *p2_scores.select_nth_unstable(p2_len / 2).1)
}
fn is_well_formed<'a>(line: &str, stack: &'a mut Vec<u8>) -> Result<&'a mut Vec<u8>, usize> {
for c in line.bytes() {
match c {
b'(' | b'[' | b'<' | b'{' => stack.push(c),
b']' | b'}' | b'>' if stack.last().unwrap() + 2 == c => {
stack.pop();
}
b')' if stack.last().unwrap() == &b'(' => {
stack.pop();
}
b')' => return Err(3),
b']' => return Err(57),
b'}' => return Err(1197),
b'>' => return Err(25137),
_ => unreachable!(),
}
}
Ok(stack)
}
fn autocomplete_points(stack: &mut Vec<u8>) -> usize {
let mut points = 0;
for p in stack.drain(..).rev() {
points *= 5;
match p {
b'(' => points += 1,
b'[' => points += 2,
b'{' => points += 3,
b'<' => points += 4,
_ => unreachable!(),
}
}
points
}
fn main() {
let raw = read_file(DAY);
let (p1, p2) = solve(&raw);
println!("Part 1: {p1}");
println!("Part 2: {p2}");
}
#[cfg(test)]
mod tests {
use super::*;
use aoc2021::*;
const TEST_INPUT: &str = "[({(<(())[]>[[{[]{<()<>>
[(()[<>])]({[<{<<[]>>(
{([(<{}[<>[]}>{[]{[(<()>
(((({<>}<{<{<>}{[]{[]{}
[[<[([]))<([[{}[[()]]]
[{[{({}]{}}([{[{{{}}([]
{<[[]]>}<{[{[{[]{()[[[]
[<(<(<(<{}))><([]([]()
<{([([[(<>()){}]>(<<{{
<{([{{}}[<[[[<>{}]]]>[]]";
#[bench]
fn bench_autocomplete_points(b: &mut test::Bencher) {
let sample_stack = vec![b'<', b'{', b'(', b'['];
b.iter(|| assert_eq!(autocomplete_points(test::black_box(&mut sample_stack.clone())), 294));
}
#[test]
fn part1_test() {
assert_eq!(solve(TEST_INPUT).0, 26397);
}
#[test]
fn part2_test() {
assert_eq!(solve(TEST_INPUT).1, 288957);
}
#[bench]
fn bench_solution(b: &mut test::Bencher) {
let raw = read_file(DAY);
b.iter(|| assert_eq!(solve(test::black_box(&raw)), (358737, 4329504793)))
}
}

84
2021/src/bin/day11.rs Normal file
View File

@ -0,0 +1,84 @@
#![feature(bool_to_option)]
#![feature(test)]
extern crate test;
use aoc2021::{
common::*,
grid::{Grid, HashGrid, PositionND},
};
const DAY: usize = 11;
const ROUNDS: usize = 100;
type Parsed = HashGrid<u8, 2>;
fn parse_input(raw: &str) -> Parsed {
HashGrid::<u8, 2>::from_bytes_2d(raw, |b: u8| b - b'0')
}
fn part1(parsed: &Parsed) -> usize {
let mut grid = parsed.to_owned();
(0..ROUNDS).map(|_| make_step(&mut grid)).sum()
}
fn part2(parsed: &Parsed) -> usize {
let mut grid = parsed.to_owned();
(0..).position(|_| make_step(&mut grid) == parsed.len()).unwrap() + 1
}
fn make_step(grid: &mut Parsed) -> usize {
let mut flashed: Vec<_> = grid
.fields
.iter_mut()
.filter_map(|(p, energy)| {
*energy += 1;
(*energy == 10).then_some(*p)
})
.collect();
for p in flashed.clone() {
flash(grid, &p, &mut flashed);
}
for p in &flashed {
*grid.fields.get_mut(p).unwrap() = 0;
}
flashed.len()
}
fn flash(grid: &mut Parsed, position: &PositionND<2>, flashed: &mut Vec<PositionND<2>>) {
for n in position.neighbors() {
if let Some(p) = grid.fields.get_mut(&n) {
*p += 1;
if p == &10 {
flashed.push(n);
flash(grid, &n, flashed);
}
}
}
}
fn main() {
let input = parse_input(&read_file(DAY));
println!("Part 1: {}", part1(&input));
println!("Part 2: {}", part2(&input));
}
#[cfg(test)]
mod tests {
use super::*;
use aoc2021::*;
const TEST_INPUT: &str = "5483143223
2745854711
5264556173
6141336146
6357385478
4167524645
2176841721
6882881134
4846848554
5283751526";
test!(part1() == 1656);
test!(part2() == 195);
bench!(part1() == 1741);
bench!(part2() == 440);
bench_input!(HashGrid::len => 100);
}

123
2021/src/bin/day12.rs Normal file
View File

@ -0,0 +1,123 @@
#![feature(test)]
extern crate test;
use std::collections::HashMap;
use aoc2021::common::*;
use itertools::Itertools;
const DAY: usize = 12;
type Parsed<'a> = HashMap<Node<'a>, Vec<Node<'a>>>;
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
enum Node<'a> {
Start,
End,
Small(&'a str),
Big(&'a str),
}
impl<'a> From<&'a str> for Node<'a> {
fn from(s: &'a str) -> Self {
match s {
"start" => Node::Start,
"end" => Node::End,
cave if cave.chars().all(|c| c.is_ascii_uppercase()) => Node::Big(cave),
cave if cave.chars().all(|c| c.is_ascii_lowercase()) => Node::Small(cave),
_ => unreachable!(),
}
}
}
fn parse_input(raw: &str) -> Parsed {
raw.lines()
.map(|l| l.split_once('-').unwrap())
.map(|(from, to)| (Node::from(from), Node::from(to)))
.flat_map(|(a, b)| [(a, b), (b, a)]) // connections always go both ways
.into_group_map()
}
fn part1(parsed: &Parsed) -> usize {
possible_paths(parsed, &Node::Start, &Vec::new(), false)
}
fn part2(parsed: &Parsed) -> usize {
possible_paths(parsed, &Node::Start, &Vec::new(), true)
}
fn possible_paths<'a>(map: &'a Parsed, position: &'a Node<'a>, visited: &[&'a Node<'a>], small_cave_allowed: bool) -> usize {
map.get(position)
.unwrap()
.iter()
.map(|p| match p {
Node::Big(_) => possible_paths(map, p, visited, small_cave_allowed),
Node::Small(_) if !visited.contains(&p) || small_cave_allowed => {
let mut new_visited = visited.to_owned();
new_visited.push(p);
possible_paths(map, p, &new_visited, !visited.contains(&p) && small_cave_allowed)
}
Node::Start | Node::Small(_) => 0,
Node::End => 1,
})
.sum()
}
fn main() {
let raw = read_file(DAY);
let input = parse_input(&raw);
println!("Part 1: {}", part1(&input));
println!("Part 2: {}", part2(&input));
}
#[cfg(test)]
mod tests {
use super::*;
use aoc2021::*;
const TEST_INPUT: &str = "start-A
start-b
A-c
A-b
b-d
A-end
b-end";
const TEST_INPUT_2: &str = "dc-end
HN-start
start-kj
dc-start
dc-HN
LN-dc
HN-end
kj-sa
kj-HN
kj-dc";
const TEST_INPUT_3: &str = "fs-end
he-DX
fs-he
start-DX
pj-DX
end-zg
zg-sl
zg-pj
pj-he
RW-he
fs-DX
pj-RW
zg-RW
start-pj
he-WI
zg-he
pj-fs
start-RW";
test!(part1() == 10);
test!(with _2: part1() == 19);
test!(with _3: part1() == 226);
test!(part2() == 36);
test!(with _2: part2() == 103);
test!(with _3: part2() == 3509);
bench!(part1() == 4411);
bench!(part2() == 136767);
bench_input!(HashMap::len => 13);
}

122
2021/src/bin/day13.rs Normal file
View File

@ -0,0 +1,122 @@
#![feature(test)]
extern crate test;
use aoc2021::common::*;
use itertools::Itertools;
const DAY: usize = 13;
// Turns out the grid is so sparse, a set would have been better. Welp.
type Parsed = (Vec<Vec<bool>>, Vec<Fold>);
enum Fold {
X(usize),
Y(usize),
}
impl Fold {
fn fold(&self, grid: &mut Vec<Vec<bool>>) {
match *self {
Fold::Y(at) => {
for x in 0..at {
for y in 0..grid[x].len() {
grid[x][y] |= grid.get(at + at - x).map(|ys| ys[y]).unwrap_or(false);
}
}
grid.truncate(at);
}
Fold::X(at) => {
for ys in grid {
for y in 0..at {
ys[y] |= *ys.get(at + at - y).unwrap_or(&false);
}
ys.truncate(at);
}
}
}
}
}
fn parse_input(raw: &str) -> Parsed {
let (points, folds) = raw.split_once("\n\n").unwrap();
let points: Vec<(usize, usize)> =
points.lines().map(|line| line.split_once(',').unwrap()).map(|(x, y)| (parse_num(x), parse_num(y))).collect();
let mut grid = vec![vec![false; points.iter().map(|&(x, _)| x).max().unwrap() + 1]; points.iter().map(|&(_, y)| y).max().unwrap() + 1];
for (y, x) in points {
grid[x][y] = true;
}
let folds = folds
.lines()
.map(|line| {
if let Some(x) = line.strip_prefix("fold along x=") {
Fold::X(parse_num(x))
} else if let Some(y) = line.strip_prefix("fold along y=") {
Fold::Y(parse_num(y))
} else {
unreachable!("{}", line)
}
})
.collect();
(grid, folds)
}
fn part1((grid, folds): &Parsed) -> usize {
let mut folded = grid.to_owned();
folds[0].fold(&mut folded);
folded.into_iter().flatten().filter(|&b| b).count()
}
fn part2((grid, instructions): &Parsed) -> String {
let mut paper = grid.to_owned();
for instruction in instructions {
instruction.fold(&mut paper); // :thanking:
}
const OUTPUT_CHARS: [char; 2] = [' ', '#'];
paper.into_iter().map(|ys| ys.into_iter().map(|b| OUTPUT_CHARS[b as usize]).collect::<String>()).join("\n")
}
fn main() {
let input = parse_input(&read_file(DAY));
println!("Part 1: {}", part1(&input));
println!("Part 2:\n{}", part2(&input));
}
#[cfg(test)]
mod tests {
use super::*;
use aoc2021::*;
const TEST_INPUT: &str = "6,10
0,14
9,10
0,3
10,4
4,11
6,0
6,12
4,1
0,13
10,12
3,4
3,0
8,4
1,10
2,14
8,10
9,0
fold along y=7
fold along x=5";
test!(part1() == 17);
bench!(part1() == 661);
bench_input!(input_len_for_bench => 902);
#[bench]
fn part2_bench(b: &mut test::Bencher) {
let parsed = parse_input(&read_file(DAY));
b.iter(|| assert_eq!(part2(&parsed).len(), 245));
}
fn input_len_for_bench((grid, folds): &Parsed) -> usize {
grid.len() + folds.len()
}
}

90
2021/src/bin/day14.rs Normal file
View File

@ -0,0 +1,90 @@
#![feature(array_windows)]
#![feature(test)]
extern crate test;
use aoc2021::common::*;
use fnv::FnvHashMap;
const DAY: usize = 14;
type Parsed = (FnvHashMap<[u8; 2], u8>, String);
fn parse_input(raw: &str) -> Parsed {
let (state, rules) = raw.split_once("\n\n").unwrap();
let rules = rules.lines().map(|line| line.as_bytes()).map(|bytes| ([bytes[0], bytes[1]], bytes[bytes.len() - 1])).collect();
(rules, state.to_owned())
}
fn grow_polys((rules, raw_state): &Parsed, generations: usize) -> usize {
let mut state = FnvHashMap::default();
for polymer in raw_state.as_bytes().array_windows() {
*state.entry(*polymer).or_insert(0) += 1;
}
for _ in 0..generations {
for ([p1, p2], quantity) in state.clone() {
let output = rules[&[p1, p2]];
*state.entry([p1, output]).or_insert(0) += quantity;
*state.entry([output, p2]).or_insert(0) += quantity;
*state.get_mut(&[p1, p2]).unwrap() -= quantity;
}
}
let mut charcounts = FnvHashMap::default();
for (p, q) in state.into_iter().flat_map(|([p1, p2], q)| [(p1, q), (p2, q)]) {
*charcounts.entry(p).or_insert(0) += q;
}
for (&p, q) in charcounts.iter_mut() {
// This implementation counts each element except the very first and very last twice.
// We add 1 for those and then divide by 2.
*q += (p == raw_state.bytes().next().unwrap()) as usize;
*q += (p == raw_state.bytes().last().unwrap()) as usize;
*q /= 2;
}
charcounts.values().max().unwrap() - charcounts.values().filter(|&&q| q != 0).min().unwrap()
}
fn part1(parsed: &Parsed) -> usize {
grow_polys(parsed, 10)
}
fn part2(parsed: &Parsed) -> usize {
grow_polys(parsed, 40)
}
fn main() {
let input = parse_input(&read_file(DAY));
println!("Part 1: {}", part1(&input));
println!("Part 2: {}", part2(&input));
}
#[cfg(test)]
mod tests {
use super::*;
use aoc2021::*;
const TEST_INPUT: &str = "NNCB
CH -> B
HH -> N
CB -> H
NH -> C
HB -> C
HC -> B
HN -> C
NN -> C
BH -> H
NC -> B
NB -> B
BN -> B
BB -> N
BC -> B
CC -> N
CN -> C";
test!(part1() == 1588);
test!(part2() == 2188189693529);
bench!(part1() == 3587);
bench!(part2() == 3906445077999);
bench_input!(input_size => 120);
fn input_size((m, s): &Parsed) -> usize {
m.len() + s.len()
}
}

69
2021/src/bin/day15.rs Normal file
View File

@ -0,0 +1,69 @@
#![feature(drain_filter)]
#![feature(test)]
extern crate test;
use aoc2021::{
common::*,
grid::{Grid, PositionND, VecGrid},
};
use itertools::Itertools;
const DAY: usize = 15;
type Parsed = VecGrid<u8>;
fn parse_input(raw: &str) -> Parsed {
VecGrid::from_bytes_2d(raw, |b| b - b'0')
}
// I win the award for slowest solution, at least.
fn part1(parsed: &Parsed, grid_size: usize) -> usize {
let mut paths = vec![(PositionND::from([0, 0]), 0)];
let end = PositionND::from([grid_size - 1, grid_size - 1]);
let mut max_risk = 0usize;
loop {
let min_index = paths.iter().position_min_by_key(|(_, c)| c).unwrap();
let (next_candidate, risk_so_far) = paths.swap_remove(min_index);
for (risk, position) in next_candidate.neighbors_no_diagonals().into_iter().filter_map(|p| parsed.get(&p).zip(Some(p))) {
let new_risk = risk_so_far + *risk as usize;
max_risk = max_risk.max(new_risk);
paths.push((position, new_risk));
}
paths.sort_unstable_by_key(|(p, _)| p.points[0] as usize * grid_size + p.points[1] as usize);
paths = paths.into_iter().coalesce(|(p, r), (p2, r2)| if p == p2 { Ok((p, r.min(r2))) } else { Err(((p, r), (p2, r2))) }).collect();
if let Some((_, risk)) = paths.iter().filter(|(p, _)| p == &end).min_by_key(|(_, r)| r) {
return *risk;
}
}
}
fn part2(_parsed: &Parsed) -> usize {
todo!()
}
fn main() {
let input = parse_input(&read_file(DAY));
println!("Part 1: {}", part1(&input, 100));
println!("Part 2: {}", part2(&input));
}
#[cfg(test)]
mod tests {
use super::*;
use aoc2021::*;
const TEST_INPUT: &str = "1163751742
1381373672
2136511328
3694931569
7463417111
1319128137
1359912421
3125421639
1293138521
2311944581";
test!(part1(10) == 40);
test!(part2() == 0);
bench!(part1(100) == 656);
bench!(part2() == 0);
bench_input!(VecGrid::len => 100);
}

95
2021/src/bin/day17.rs Normal file
View File

@ -0,0 +1,95 @@
#![feature(test)]
extern crate test;
use std::ops::RangeInclusive;
type TargetArea = (RangeInclusive<isize>, RangeInclusive<isize>);
type Probe = ((isize, isize), (isize, isize));
#[derive(Debug, PartialEq)]
enum ProbeStatus {
Hit,
Miss,
NoLongerReachable,
}
#[inline]
fn calc_status(((xvel, _), (x, y)): &Probe, (xtarget, ytarget): &TargetArea) -> ProbeStatus {
if xtarget.contains(x) && ytarget.contains(y) {
ProbeStatus::Hit
} else if y < ytarget.start() || x > xtarget.end() || (xvel == &0 && !xtarget.contains(x)) {
ProbeStatus::NoLongerReachable
} else {
ProbeStatus::Miss
}
}
#[inline]
fn step(((xvel, yvel), (x, y)): &Probe) -> Probe {
((xvel - xvel.signum(), yvel - 1), (x + xvel, y + yvel))
}
fn get_target() -> TargetArea {
(34..=67, -215..=-186)
}
fn part1(hits: &[isize]) -> isize {
(1..=*hits.iter().max().unwrap()).sum()
}
fn find_hits(target: &TargetArea) -> Vec<isize> {
// Doing y in the outer loop and x in the inner would allow us to call last() instead of max()
// in part1, however, for reasons unknown to me, that makes this function 20% slower.
(1..=*target.0.end())
.flat_map(move |x| (*target.1.start()..-target.1.start()).map(move |y| (x, y)))
.filter_map(|(startx, starty)| {
let mut probe = ((startx, starty), (0, 0));
loop {
probe = step(&probe);
match calc_status(&probe, target) {
ProbeStatus::Hit => return Some(starty),
ProbeStatus::Miss => continue,
ProbeStatus::NoLongerReachable => return None,
}
}
})
.collect()
}
fn main() {
let hits = find_hits(&get_target());
println!("Part 1: {}", part1(&hits));
println!("Part 2: {}", hits.len());
}
#[cfg(test)]
mod tests {
use super::*;
use aoc2021::*;
#[test]
fn part1_test() {
let input = (20..=30, -10..=-5);
let hits = find_hits(&input);
assert_eq!(part1(&hits), 45);
}
#[test]
fn part2_test() {
let input = (20..=30, -10..=-5);
let hits = find_hits(&input);
assert_eq!(hits.len(), 112);
}
#[bench]
fn bench_find_hits(b: &mut test::Bencher) {
let input = get_target();
b.iter(|| assert_eq!(find_hits(test::black_box(&input)).len(), 2040))
}
#[bench]
fn bench_part1(b: &mut test::Bencher) {
let input = get_target();
let hits = find_hits(&input);
b.iter(|| assert_eq!(part1(test::black_box(&hits)), 23005))
}
}

265
2021/src/bin/day18.rs Normal file
View File

@ -0,0 +1,265 @@
#![feature(box_patterns)]
#![feature(test)]
extern crate test;
use aoc2021::common::*;
use itertools::Itertools;
use std::{fmt, ops::Add};
const DAY: usize = 18;
type Parsed = Vec<Node>;
impl Add for Node {
type Output = Node;
fn add(self, rhs: Self) -> Self::Output {
Node::Pair(Box::new((self, rhs)))
}
}
#[derive(Debug, PartialEq, Clone)]
enum Node {
Number(usize),
Pair(Box<(Node, Node)>),
}
impl fmt::Display for Node {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match &self {
Node::Number(n) => write!(f, "{n}"),
Node::Pair(box (a, b)) => write!(f, "[{a},{b}]"),
}
}
}
fn parse_input(raw: &str) -> Parsed {
raw.lines().map(|l| parse_node(l).0).collect()
}
fn parse_node(raw: &str) -> (Node, usize) {
if let Some(inner) = raw.strip_prefix('[') {
let (first, offset) = parse_node(inner);
let (second, offset2) = parse_node(&inner[offset..]);
(first + second, offset + offset2 + 2 /* 1 for the opening [ and 1 for the comma */)
} else {
let n = raw.as_bytes()[0] - b'0';
debug_assert!(n <= 9);
(Node::Number(n as _), 2)
}
}
#[derive(Debug, PartialEq, Clone, Copy)]
enum Explosion {
None,
Partial,
Full,
}
impl Node {
fn reduce(mut self) -> Self {
while self.explode() || self.split() {}
self
}
fn explode(&mut self) -> bool {
self.explode_inner(0, &mut None, &mut None, Explosion::None) != Explosion::None
}
fn split(&mut self) -> bool {
match self {
Node::Number(n) if *n >= 10 => {
*self = Node::Number(*n / 2) + Node::Number(*n / 2 + (*n & 1));
true
}
Node::Pair(box (a, b)) => a.split() || b.split(),
_ => false,
}
}
fn magnitude(&self) -> usize {
match self {
Node::Number(n) => *n,
Node::Pair(box (a, b)) => 3 * a.magnitude() + 2 * b.magnitude(),
}
}
fn explode_inner<'a, 'b>(
&'a mut self,
depth: usize,
previous_number: &'b mut Option<&'a mut usize>,
for_next: &'b mut Option<usize>,
state: Explosion,
) -> Explosion {
match self {
Node::Number(n) => match &for_next {
Some(x) => {
*n += x;
*for_next = None;
Explosion::Full
}
None => {
*previous_number = Some(n);
state
}
},
&mut Node::Pair(box (Node::Number(left), Node::Number(right))) if depth == 4 && state == Explosion::None => {
if let Some(prev) = previous_number {
**prev += left;
}
*for_next = Some(right);
*self = Node::Number(0);
Explosion::Partial
}
Node::Pair(box (a, b)) => match a.explode_inner(depth + 1, previous_number, for_next, state) {
f @ Explosion::Full => f,
e => b.explode_inner(depth + 1, previous_number, for_next, e),
},
}
}
}
fn part1(parsed: &Parsed) -> usize {
add_and_reduce(parsed.clone()).unwrap().magnitude()
}
fn add_and_reduce(parsed: Parsed) -> Option<Node> {
parsed.into_iter().reduce(move |acc, new| (acc + new).reduce())
}
fn part2(parsed: &Parsed) -> usize {
parsed.iter().permutations(2).map(|n| (n[0].clone() + n[1].clone()).reduce().magnitude()).max().unwrap()
}
fn main() {
let input = parse_input(&read_file(DAY));
println!("Part 1: {}", part1(&input));
println!("Part 2: {}", part2(&input));
}
#[cfg(test)]
mod tests {
use super::*;
use aoc2021::*;
use test_case::test_case;
const TEST_INPUT_SINGLE_ADDITION: &str = "[[[[4,3],4],4],[7,[[8,4],9]]]
[1,1]";
const OTHER_TEST_INPUT: &str = "[1,2]
[[1,2],3]
[9,[8,7]]
[[1,9],[8,5]]
[[[[1,2],[3,4]],[[5,6],[7,8]]],9]
[[[9,[3,8]],[[0,9],6]],[[[3,7],[4,9]],3]]
[[[[1,3],[5,3]],[[1,3],[8,7]]],[[[4,9],[6,9]],[[8,2],[7,3]]]]";
const TEST_INPUT: &str = "[[[0,[5,8]],[[1,7],[9,6]]],[[4,[1,2]],[[1,4],2]]]
[[[5,[2,8]],4],[5,[[9,9],0]]]
[6,[[[6,2],[5,6]],[[7,6],[4,7]]]]
[[[6,[0,7]],[0,9]],[4,[9,[9,0]]]]
[[[7,[6,4]],[3,[1,3]]],[[[5,5],1],9]]
[[6,[[7,3],[3,2]]],[[[3,8],[5,7]],4]]
[[[[5,4],[7,7]],8],[[8,3],8]]
[[9,3],[[9,9],[6,[4,9]]]]
[[2,[[7,7],7]],[[5,8],[[9,3],[0,2]]]]
[[[[5,2],5],[8,[3,7]]],[[5,[7,5]],[4,4]]]";
#[test]
fn test_example_parsing() {
let [first, second]: [Node; 2] = parse_input(TEST_INPUT_SINGLE_ADDITION).try_into().unwrap();
assert_eq!(
first,
(((Node::Number(4) + Node::Number(3)) + Node::Number(4)) + Node::Number(4))
+ (Node::Number(7) + ((Node::Number(8) + Node::Number(4)) + Node::Number(9)))
);
assert_eq!(second, (Node::Number(1) + Node::Number(1)));
}
#[test]
fn test_node_display() {
for (actual, expected) in parse_input(OTHER_TEST_INPUT).into_iter().zip(OTHER_TEST_INPUT.lines()) {
assert_eq!(expected, actual.to_string());
}
}
#[test_case("[[[[[9,8],1],2],3],4]" => "[[[[0,9],2],3],4]")]
#[test_case("[7,[6,[5,[4,[3,2]]]]]" => "[7,[6,[5,[7,0]]]]")]
#[test_case("[[6,[5,[4,[3,2]]]],1]" => "[[6,[5,[7,0]]],3]")]
#[test_case("[[3,[2,[1,[7,3]]]],[6,[5,[4,[3,2]]]]]" => "[[3,[2,[8,0]]],[9,[5,[4,[3,2]]]]]")]
#[test_case("[[3,[2,[8,0]]],[9,[5,[4,[3,2]]]]]" => "[[3,[2,[8,0]]],[9,[5,[7,0]]]]")]
#[test_case("[[[[4,0],[5,0]],[[[4,5],[2,6]],[9,5]]],[7,[[[3,7],[4,3]],[[6,3],[8,8]]]]]" => "[[[[4,0],[5,4]],[[0,[7,6]],[9,5]]],[7,[[[3,7],[4,3]],[[6,3],[8,8]]]]]")]
fn test_single_explosion(raw: &str) -> String {
let mut i = parse_node(raw).0;
assert!(i.explode());
i.to_string()
}
#[test_case("[[1,2],[[3,4],5]]" => 143)]
#[test_case("[[[[0,7],4],[[7,8],[6,0]]],[8,1]]" => 1384)]
#[test_case("[[[[1,1],[2,2]],[3,3]],[4,4]]" => 445)]
#[test_case("[[[[3,0],[5,3]],[4,4]],[5,5]]" => 791)]
#[test_case("[[[[5,0],[7,4]],[5,5]],[6,6]]" => 1137)]
#[test_case("[[[[8,7],[7,7]],[[8,6],[7,7]]],[[[0,7],[6,6]],[8,7]]]" => 3488)]
#[test_case("[[[[6,6],[7,6]],[[7,7],[7,0]]],[[[7,7],[7,7]],[[7,8],[9,9]]]]" => 4140)]
fn test_magnitude(raw: &str) -> usize {
parse_node(raw).0.magnitude()
}
#[test]
fn test_full_chain() {
let lhs = parse_node("[[[[4,3],4],4],[7,[[8,4],9]]]").0;
let rhs = parse_node("[1,1]").0;
let mut res = lhs + rhs;
assert_eq!(res.to_string(), "[[[[[4,3],4],4],[7,[[8,4],9]]],[1,1]]");
let mut res2 = res.clone();
res.explode();
assert_eq!(res.to_string(), "[[[[0,7],4],[7,[[8,4],9]]],[1,1]]");
res.explode();
assert_eq!(res.to_string(), "[[[[0,7],4],[15,[0,13]]],[1,1]]");
res.split();
assert_eq!(res.to_string(), "[[[[0,7],4],[[7,8],[0,13]]],[1,1]]");
res.split();
assert_eq!(res.to_string(), "[[[[0,7],4],[[7,8],[0,[6,7]]]],[1,1]]");
res.explode();
assert_eq!(res.to_string(), "[[[[0,7],4],[[7,8],[6,0]]],[8,1]]");
// should be done now
res = res.reduce();
assert_eq!(res.to_string(), "[[[[0,7],4],[[7,8],[6,0]]],[8,1]]");
// now again using .reduce() from the beginning
res2 = res2.reduce();
assert_eq!(res, res2);
}
#[test]
fn test_single_reduction() {
assert_eq!(
parse_node("[[[[0,[4,5]],[0,0]],[[[4,5],[2,6]],[9,5]]],[7,[[[3,7],[4,3]],[[6,3],[8,8]]]]]").0.reduce().to_string(),
"[[[[4,0],[5,4]],[[7,7],[6,0]]],[[8,[7,7]],[[7,9],[5,0]]]]"
);
}
#[test_case("[1,1]\n[2,2]\n[3,3]\n[4,4]" => "[[[[1,1],[2,2]],[3,3]],[4,4]]")]
#[test_case("[1,1]\n[2,2]\n[3,3]\n[4,4]\n[5,5]" => "[[[[3,0],[5,3]],[4,4]],[5,5]]")]
#[test_case("[1,1]\n[2,2]\n[3,3]\n[4,4]\n[5,5]\n[6,6]" => "[[[[5,0],[7,4]],[5,5]],[6,6]]")]
#[test_case("[[[0,[4,5]],[0,0]],[[[4,5],[2,6]],[9,5]]]
[7,[[[3,7],[4,3]],[[6,3],[8,8]]]]
[[2,[[0,8],[3,4]]],[[[6,7],1],[7,[1,6]]]]
[[[[2,4],7],[6,[0,5]]],[[[6,8],[2,8]],[[2,1],[4,5]]]]
[7,[5,[[3,8],[1,4]]]]
[[2,[2,2]],[8,[8,1]]]
[2,9]
[1,[[[9,3],9],[[9,0],[0,7]]]]
[[[5,[7,4]],7],1]
[[[[4,2],2],6],[8,7]]" => "[[[[8,7],[7,7]],[[8,6],[7,7]]],[[[0,7],[6,6]],[8,7]]]")]
fn test_list_reduction(raw: &str) -> String {
let parsed = parse_input(raw);
add_and_reduce(parsed).unwrap().to_string()
}
test!(part1() == 4140);
test!(part2() == 3993);
bench!(part1() == 4173);
bench!(part2() == 4706);
bench_input!(Vec::len => 100);
}

54
2021/src/bin/day19.rs Normal file
View File

@ -0,0 +1,54 @@
#![allow(unused)]
#![feature(test)]
extern crate test;
use aoc2021::common::*;
use itertools::Itertools;
const DAY: usize = 19;
type Parsed = Vec<Scanner>;
#[derive(Debug)]
struct Scanner {
no: usize,
coords: Vec<ScanPoint>,
}
type ScanPoint = [isize; 3];
fn parse_input(raw: &str) -> Parsed {
raw.split("\n\n")
.map(|raw_scanner| {
raw_scanner.lines().skip(1).map(|l| l.split(',').map(|n| n.parse().unwrap()).collect_vec().try_into().unwrap()).collect()
})
.enumerate()
.map(|(no, coords)| Scanner { no, coords })
.collect()
}
fn part1(parsed: &Parsed) -> usize {
unimplemented!()
}
fn part2(parsed: &Parsed) -> usize {
unimplemented!()
}
fn main() {
let input = parse_input(&read_file(DAY));
println!("Part 1: {}", part1(&input));
println!("Part 2: {}", part2(&input));
}
#[cfg(test)]
mod tests {
use super::*;
use aoc2021::*;
const TEST_INPUT: &str = include_str!("../../inputs/day19_test");
test!(part1() == 0);
test!(part2() == 0);
bench!(part1() == 0);
bench!(part2() == 0);
bench_input!(Vec::len => 37);
}

117
2021/src/bin/day20.rs Normal file
View File

@ -0,0 +1,117 @@
#![feature(derive_default_enum)]
#![feature(test)]
extern crate test;
use aoc2021::{
common::*,
grid::{get_boundaries, Boundaries, Grid, HashGrid, Position2D},
};
use itertools::Itertools;
use std::fmt;
#[derive(Debug, PartialEq, Default, Clone, Copy)]
enum Pixel {
Bright,
#[default]
Dark,
}
#[rustfmt::skip]
impl fmt::Display for Pixel {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", match self { Pixel::Bright => '#', Pixel::Dark => '.' })
}
}
impl From<u8> for Pixel {
fn from(b: u8) -> Self {
match b {
b'#' => Pixel::Bright,
b'.' => Pixel::Dark,
_ => unreachable!(),
}
}
}
const DAY: usize = 20;
type Parsed = ([Pixel; 512], HashGrid<Pixel, 2>);
fn parse_input(raw: &str) -> Parsed {
let (enhance, image) = raw.split_once("\n\n").unwrap();
// type inference on these methods is absolute magic
(enhance.bytes().map_into().collect_vec().try_into().unwrap(), HashGrid::from_bytes_2d(image, Pixel::from))
}
fn neighbors_plus_self(p: Position2D) -> Vec<Position2D> {
(-1..=1)
.rev() // my grid has (0,0) at top left which doesn’t seem to match the task
.flat_map(|x| (-1..=1).rev().map(move |y| Position2D::from([y, x])))
.map(|offset| p + offset)
.collect()
}
fn step(grid: HashGrid<Pixel, 2>, lookup: &[Pixel; 512], iteration: usize) -> HashGrid<Pixel, 2> {
let Boundaries { x_min, x_max, y_min, y_max } = get_boundaries(&grid.fields.keys().collect_vec());
(x_min - 1..=x_max + 1)
.flat_map(|x| (y_min - 1..=y_max + 1).map(move |y| Position2D::from([x, y])))
.map(|p| (p, lookup[lookup_index(p, &grid, iteration)]))
.collect()
}
const OUTSIDE: [Pixel; 2] = [Pixel::Dark, Pixel::Bright];
fn lookup_index(p: Position2D, grid: &HashGrid<Pixel, 2>, iteration: usize) -> usize {
neighbors_plus_self(p)
.into_iter()
.rev()
.map(|p| grid.get(&p).unwrap_or(&OUTSIDE[iteration & 1]) == &Pixel::Bright)
.fold(0, |acc, n| (acc << 1) | n as usize)
}
fn step_times(grid: &HashGrid<Pixel, 2>, lookup: &[Pixel; 512], iterations: usize) -> usize {
let mut grid = grid.to_owned();
for i in 0..iterations {
grid = step(grid, lookup, i);
}
grid.fields.values().filter(|&&p| p == Pixel::Bright).count()
}
fn part1((lookup, grid): &Parsed) -> usize {
step_times(grid, lookup, 2)
}
fn part2((lookup, grid): &Parsed) -> usize {
step_times(grid, lookup, 50)
}
fn main() {
let input = parse_input(&read_file(DAY));
println!("Part 1: {}", part1(&input));
println!("Part 2: {}", part2(&input));
}
#[cfg(test)]
mod tests {
use super::*;
use aoc2021::*;
const TEST_INPUT: &str = "#.#.#..#####.#.#.#.###.##.....###.##.#..###.####..#####..#....#..#..##..###..######.###...####..#..#####..##..#.#####...##.#.#..#.##..#.#......#.###.######.###.####...#.##.##..#..#..#####.....#.#....###..#.##......#.....#..#..#..##..#...##.######.####.####.#.#...#.......#..#.#.#...####.##.#......#..#...##.#.##..#...##.#.##..###.#......#.#.......#.#.#.####.###.##...#.....####.#..#..#.##.#....##..#.####....##...##..#...#......#.#.......#.......##..####..#...#.#.#...##..#.#..###..#####........#..####......#...
#..#.
#....
##..#
..#..
..###";
#[test]
fn lookup_index_test() {
let grid = HashGrid::from_bytes_2d("...\n#..\n.#.", Pixel::from);
let p = Position2D::from([1, 1]);
let idx = lookup_index(p, &grid, 0);
assert_eq!(idx, 34);
}
test!(part1() == 24);
bench!(part1() == 5503);
bench!(part2() == 19156);
bench_input!(|(_, g): &Parsed| g.len() => 10_000);
}

97
2021/src/bin/day21.rs Normal file
View File

@ -0,0 +1,97 @@
#![feature(test)]
use fnv::FnvHashMap;
extern crate test;
type Parsed = (u16, u16);
const INPUT: Parsed = (7, 3);
fn part1((p1, p2): Parsed) -> usize {
(1..=100)
.cycle()
.skip(1)
.step_by(3)
.scan(GameState { odd_round: false, scores: [(p1, 0), (p2, 0)] }, |game, die| {
advance_game(game, die * 3);
Some((game.scores[0].1, game.scores[1].1))
})
.zip(1..)
.find_map(|((s1, s2), r)| (s1 >= 1000 || s2 >= 1000).then(|| r * 3 * (s1.min(s2) as usize)))
.unwrap()
}
#[derive(Debug, Hash, PartialEq, Eq, Clone, Copy)]
struct GameState {
odd_round: bool,
// Tuples are (position, total score)
scores: [(u16, usize); 2],
}
// Just this, but cached and grouped because I don’t want to calc it in the loop
// iproduct!(1..=3, 1..=3, 1..=3).map(|(a, b, c)| a + b + c)
const POSSIBLE_ROLLS: [(u16, usize); 7] = [(6, 7), (5, 6), (7, 6), (4, 3), (8, 3), (3, 1), (9, 1)];
fn part2((p1, p2): Parsed) -> usize {
let mut games = FnvHashMap::default();
games.insert(GameState { odd_round: false, scores: [(p1, 0), (p2, 0)] }, 1);
let mut wins = [0, 0];
let mut storage = Vec::with_capacity(100_000);
while !games.is_empty() {
for (start, count) in games.drain() {
for &(die, count2) in &POSSIBLE_ROLLS {
let mut new_state = start;
advance_game(&mut new_state, die);
if new_state.scores[start.odd_round as usize].1 >= 21 {
wins[new_state.odd_round as usize] += count * count2;
} else {
storage.push((new_state, count * count2));
}
}
}
// Of all the versions I’ve tried, temporarily storing in a vector and then sorting back
// into the map was by far the fastest.
for (k, v) in storage.drain(..) {
*games.entry(k).or_insert(0) += v;
}
}
wins[0].max(wins[1])
}
fn advance_game(game: &mut GameState, die: u16) {
let index = game.odd_round as usize;
let mut points = game.scores[index].0 + die;
points -= (points - 1) / 10 * 10;
game.scores[index].0 = points;
game.scores[index].1 += points as usize;
game.odd_round = !game.odd_round;
}
fn main() {
println!("Part 1: {}", part1(INPUT));
println!("Part 2: {}", part2(INPUT));
}
#[cfg(test)]
mod tests {
use super::*;
use aoc2021::*;
#[test]
fn part1_test() {
assert_eq!(part1((4, 8)), 739785);
}
#[test]
fn part2_test() {
assert_eq!(part2((4, 8)), 444356092776315);
}
#[bench]
fn part1_bench(b: &mut test::Bencher) {
b.iter(|| assert_eq!(part1(test::black_box(INPUT)), 551901))
}
#[bench]
fn part2_bench(b: &mut test::Bencher) {
b.iter(|| assert_eq!(part2(test::black_box(INPUT)), 272847859601291))
}
}

603
2021/src/bin/day22.rs Normal file
View File

@ -0,0 +1,603 @@
#![feature(drain_filter)]
#![feature(array_windows)]
#![feature(test)]
extern crate test;
use itertools::{iproduct, Itertools};
use std::{collections::HashSet, ops::Range};
type Parsed = Vec<(Cube, bool)>;
#[derive(Debug, PartialEq, Clone, Hash, Eq)]
struct Cube {
x: Range<isize>,
y: Range<isize>,
z: Range<isize>,
}
impl Cube {
fn contains(&self, other: &Cube) -> bool {
self.x.start <= other.x.start
&& self.x.end >= other.x.end
&& self.y.start <= other.y.start
&& self.y.end >= other.y.end
&& self.z.start <= other.z.start
&& self.z.end >= other.z.end
}
fn intersects(&self, Cube { x: x2, y: y2, z: z2 }: &Cube) -> bool {
let Cube { x: x1, y: y1, z: z1 } = self;
!((x1.end < x2.start || x2.end < x1.start)
&& (y1.end < y2.start || y2.end < y1.start)
&& (z1.end < z2.start || z2.end < z1.start))
}
fn split(self, other: Cube) -> Vec<Cube> {
if !self.intersects(&other) {
return vec![self, other];
}
let Cube { x: x1, y: y1, z: z1 } = self;
let Cube { x: x2, y: y2, z: z2 } = other;
let mut xs = vec![x1.start, x1.end, x2.start, x2.end];
xs.sort_unstable();
let mut ys = vec![y1.start, y1.end, y2.start, y2.end];
ys.sort_unstable();
let mut zs = vec![z1.start, z1.end, z2.start, z2.end];
zs.sort_unstable();
xs.push(xs[xs.len() - 1] + 1);
ys.push(ys[ys.len() - 1] + 1);
zs.push(zs[zs.len() - 1] + 1);
iproduct!(xs.array_windows::<2>(), ys.array_windows::<2>(), zs.array_windows::<2>())
// .inspect(|x| println!("{x:?}"))
.map(|(&[x1, x2], &[y1, y2], &[z1, z2])| Cube { x: x1..x2 - 1, y: y1..y2 - 1, z: z1..z2 - 1 })
.filter(|Cube { x, y, z }| x.start <= x.end && y.start <= y.end && z.start <= z.end)
.collect()
}
fn len(&self) -> usize {
(self.x.len() + 1) * (self.y.len() + 1) * (self.z.len() + 1)
}
fn try_combine(self, Cube { x: x2, y: y2, z: z2 }: Cube) -> Option<Cube> {
// println!("Trying to combine {self:?} with ({x2:?}, {y2:?}, {z2:?})");
let Cube { x: x1, y: y1, z: z1 } = self;
if x1 == x2 && y1 == y2 && z1 == z2 {
return Some(Cube { x: x1, y: y1, z: z1 });
}
if x1 == x2 && y1 == y2 && (z1.end == z2.start || z2.end == z1.start) {
return Some(Cube { x: x1, y: y1, z: z1.start.min(z2.start)..z1.end.max(z2.end) });
}
if x1 == x2 && z1 == z2 && (y1.end == y2.start || y2.end == y1.start) {
return Some(Cube { x: x1, y: y1.start.min(y2.start)..y1.end.max(y2.end), z: z1 });
}
if z1 == z2 && y1 == y2 && (x1.end == x2.start || x2.end == x1.start) {
return Some(Cube { x: x1.start.min(x2.start)..x1.end.max(x2.end), y: y1, z: z1 });
}
// println!("Did not combine");
None
}
}
#[allow(non_upper_case_globals)]
const on: bool = true;
#[allow(non_upper_case_globals)]
const off: bool = false;
macro_rules! parse {
($($b: ident x=$x: expr,y=$y: expr,z=$z: expr)*) => {
[$( (Cube { x: $x, y: $y, z: $z, }, $b), )*].to_vec()
};
}
fn part1(parsed: &Parsed) -> usize {
let mut cubes: Vec<Cube> = vec![];
for (new_cube, state) in parsed {
if new_cube.x.start.abs() > 50 {
break;
}
let new_intersections: HashSet<_> = cubes
.drain_filter(|c| c.intersects(&new_cube))
.flat_map(|cube| {
let mut cube_copy = new_cube.clone();
// println!("new: {new_cube:?}");
/*
if !state {
cube_copy.x.end += 1;
cube_copy.y.end += 1;
cube_copy.z.end += 1;
}*/
let mut cs = cube.clone().split(cube_copy);
if *state {
cs.drain_filter(|c| !cube.contains(c) && !new_cube.contains(c));
} else {
cs.retain(|c| cube.contains(c) && !new_cube.contains(c));
// cs.drain_filter(|c| !(cube.contains(c) && !new_cube.contains(c)))
// .for_each(|c| println!("Turning off {c:?} because it’s in {new_cube:?} or not in {cube:?}"));
}
cs
})
.collect();
if new_intersections.is_empty() && *state {
cubes.push(new_cube.clone());
} else {
for e in new_intersections {
cubes.push(e);
}
}
let con: usize = cubes
.iter()
// .inspect(|c| println!("{c:?}")) //
.map(Cube::len)
.sum();
println!("{con}");
/*
let v = cubes
.iter()
.flat_map(|Cube { x, y, z }| iproduct!(x.start..=x.end, y.start..=y.end, z.start..=z.end))
.sorted_unstable_by_key(|(x, y, z)| x * 10000 + y * 100 + z)
.collect_vec();
// println!("{v:?}");
*/
}
cubes.iter().map(Cube::len).sum()
// cubes.into_iter().inspect(|c| println!("{c:?}")).flat_map(Cube::points).collect::<HashSet<_>>().len()
}
fn part2(parsed: &Parsed) -> usize {
todo!()
}
fn main() {
let input = parse_input();
println!("Part 1: {}", part1(&input));
println!("Part 2: {}", part2(&input));
}
#[cfg(test)]
mod tests {
use super::*;
use aoc2021::*;
#[test]
fn part1_test() {
let input = parse! {
on x=10..12,y=10..12,z=10..12
on x=11..13,y=11..13,z=11..13
off x=9..11,y=9..11,z=9..11
on x=10..10,y=10..10,z=10..10
};
assert_eq!(part1(&input), 39);
}
#[test]
fn contains_top_right_test() {
let c = Cube { x: 9..11, y: 9..11, z: 9..11 };
let tr = Cube { x: 11..11, y: 11..11, z: 11..11 };
assert!(c.contains(&tr));
assert!(c.intersects(&tr));
}
}
fn parse_input() -> Parsed {
parse! {
on x=-13..37,y=-36..14,z=-3..45
on x=-1..43,y=-15..32,z=-35..15
on x=-7..44,y=-6..48,z=-13..38
on x=-42..3,y=-42..10,z=-3..44
on x=-34..13,y=-27..27,z=-31..23
on x=-14..39,y=-34..10,z=-40..10
on x=-12..34,y=-25..19,z=-32..15
on x=-47..6,y=-29..20,z=-45..9
on x=-37..16,y=-17..34,z=-25..29
on x=-28..20,y=-19..34,z=-3..47
off x=1..19,y=-30..-14,z=19..33
on x=-34..19,y=-22..25,z=-17..35
off x=-49..-32,y=-26..-13,z=19..38
on x=-28..25,y=-46..2,z=-11..43
off x=-30..-21,y=-44..-26,z=6..21
on x=-20..31,y=-39..11,z=-23..28
off x=33..49,y=29..47,z=8..25
on x=-28..25,y=-26..20,z=-49..-1
off x=-19..-5,y=3..18,z=-44..-27
on x=-34..15,y=-29..25,z=-34..17
on x=-77707..-66888,y=-15495..7977,z=21658..44356
on x=16734..33844,y=-90735..-54900,z=2270..19264
on x=37676..47017,y=-53726..-31603,z=-58485..-51594
on x=-25500..-16563,y=-6468..2463,z=69232..89880
on x=-35872..-12957,y=-84461..-60975,z=-20007..-9532
on x=-89647..-67921,y=-39059..-13640,z=-42281..-6574
on x=47838..82298,y=-43677..-35749,z=9027..31549
on x=-9400..11474,y=-39127..-21505,z=57808..89970
on x=61666..80803,y=10083..24758,z=37048..46860
on x=26068..46741,y=-77898..-58561,z=-30238..62
on x=-22689..-13065,y=-81029..-64591,z=-21055..3749
on x=38030..60209,y=-34391..-15028,z=-55983..-51628
on x=42982..62845,y=-54347..-47689,z=15630..45725
on x=-18872..11038,y=-76016..-52462,z=-42387..-37005
on x=-55695..-38898,y=36001..55982,z=-70788..-36425
on x=-7131..26336,y=42833..63923,z=-64129..-45423
on x=-60488..-40325,y=-47405..-31877,z=48181..58567
on x=-13302..15801,y=73748..92138,z=-34147..-17494
on x=31153..53512,y=41173..61390,z=38591..49656
on x=-35709..-8667,y=-34876..536,z=-79524..-59100
on x=45731..73067,y=50149..54110,z=-34129..-20399
on x=2923..23025,y=53277..82004,z=30350..45240
on x=-34895..-14927,y=27451..50766,z=-67502..-59363
on x=-8366..10206,y=22907..37139,z=70976..78784
on x=26000..31619,y=55905..81695,z=28039..45741
on x=-27099..342,y=70224..85805,z=-6497..11011
on x=-1601..9361,y=-40465..-9946,z=64120..76194
on x=-29110..-17895,y=38967..50663,z=56746..78592
on x=-77526..-50930,y=-60463..-42672,z=-16932..667
on x=-19801..1121,y=-95369..-68521,z=-2863..7840
on x=-56034..-34754,y=-4651..19561,z=61780..87310
on x=50357..81377,y=-54480..-35226,z=-13214..22298
on x=-37854..-29487,y=-24307..-9466,z=-70318..-65828
on x=-87626..-68588,y=-1140..28963,z=23659..43617
on x=10140..45670,y=19441..48501,z=52468..67612
on x=-61161..-46395,y=50168..60300,z=-43642..-22240
on x=-41791..-23146,y=59820..92015,z=-30219..-13117
on x=51416..66401,y=21581..26160,z=36042..66562
on x=43985..71278,y=-76853..-47487,z=10319..33057
on x=16554..44446,y=-83467..-49432,z=27702..46302
on x=-40078..-32697,y=-19712..13098,z=-79179..-70318
on x=-72544..-48748,y=-24529..-10822,z=25757..62217
on x=-49848..-23893,y=49735..70928,z=-17843..4166
on x=46504..62954,y=-63451..-39706,z=-7060..12582
on x=-18091..5639,y=-80367..-60849,z=20700..28381
on x=-70298..-58521,y=-36254..-16840,z=39462..58760
on x=-57895..-36812,y=-80262..-60063,z=17594..35827
on x=66005..74563,y=-40697..-10634,z=-28571..-12651
on x=-34740..-12979,y=14459..27693,z=72315..83610
on x=-54526..-27860,y=20919..36223,z=53916..69317
on x=5482..28204,y=-72328..-47181,z=36101..68864
on x=-10361..18618,y=50680..80016,z=29881..52293
on x=22013..53090,y=61184..77888,z=-690..15445
on x=49878..80860,y=-45597..-24600,z=8773..42131
on x=-21481..-2534,y=-52590..-35874,z=59304..71419
on x=-27491..-2116,y=-57213..-37184,z=35989..58007
on x=-27046..-11339,y=-93198..-69701,z=2894..23463
on x=-49531..-33827,y=-71407..-54183,z=28280..48597
on x=2360..31991,y=25158..56562,z=-80620..-60755
on x=-26128..-998,y=-62930..-52635,z=35279..63815
on x=48650..66941,y=-61055..-28617,z=29166..31637
on x=69844..85996,y=-22985..-2275,z=21553..38166
on x=2845..20505,y=49897..61909,z=53069..67906
on x=-28415..-3203,y=57533..73503,z=21661..31210
on x=8443..20885,y=34174..61857,z=57794..68245
on x=12152..42225,y=17448..37654,z=50480..71531
on x=57295..73077,y=-41599..-9861,z=-67808..-36322
on x=-39269..-26154,y=-14375..14800,z=71243..78784
on x=10757..31258,y=-62179..-38241,z=-79093..-48669
on x=-30816..-13772,y=31105..43599,z=56286..80856
on x=-81989..-50706,y=-30815..-14580,z=18775..44958
on x=40071..59419,y=44624..61873,z=29016..50450
on x=40251..59324,y=-67414..-49803,z=-36761..-11231
on x=27417..46406,y=-66475..-47513,z=-25177..-11900
on x=-65899..-38890,y=-12430..5965,z=57577..63876
on x=-25267..-2876,y=-44000..-32310,z=-80593..-53949
on x=-18326..-7876,y=43132..66145,z=-66613..-36605
on x=-57018..-53229,y=36751..59783,z=-30079..-9617
on x=-66290..-47772,y=-31894..-1002,z=33540..57723
on x=-125..24382,y=-80848..-72343,z=-49693..-15529
on x=-24015..-2898,y=-53625..-39125,z=55225..73628
on x=51897..80923,y=-4054..3520,z=-45412..-36746
on x=-30093..-1431,y=34246..47381,z=-75270..-59132
on x=31766..51586,y=48710..67006,z=39768..49335
on x=-20923..6424,y=1580..14928,z=-89071..-61335
on x=-78388..-68973,y=2726..15396,z=31839..51487
on x=-17101..1916,y=-31904..-18696,z=62499..86196
on x=60981..74827,y=-33558..-6318,z=17172..47217
on x=-3097..3774,y=74123..95012,z=-15851..19259
on x=-29901..-26536,y=-5670..9081,z=62581..77681
on x=-23676..-6641,y=-87054..-60450,z=6151..27241
on x=-75546..-60657,y=-46787..-18586,z=6164..28899
on x=-62447..-45293,y=-55081..-38324,z=-45488..-36816
on x=-35053..-11420,y=-78994..-73796,z=-27546..-2495
on x=14791..35832,y=8044..17682,z=-75881..-70257
on x=37114..54311,y=-62857..-40402,z=42866..62581
on x=-78891..-57261,y=-19933..2380,z=-46848..-34329
on x=-40885..-31987,y=56185..85808,z=-12714..14124
on x=-22584..-1227,y=62080..69853,z=31132..43774
on x=21369..37041,y=-29949..1877,z=-84346..-70161
on x=-32994..-11854,y=-23931..-13655,z=68474..75824
on x=28950..44900,y=37331..65913,z=-53762..-21514
on x=14251..32416,y=-59808..-39089,z=-69466..-54177
on x=-1001..11349,y=-91855..-70109,z=-20491..-5599
on x=-55376..-22523,y=26566..45387,z=53177..76643
on x=5773..21346,y=-24068..-6968,z=63947..88583
on x=-61909..-45698,y=56099..78327,z=-6552..20928
on x=-91524..-56986,y=-1853..11970,z=13238..33401
on x=65923..82086,y=-3320..28990,z=2252..31777
on x=-49874..-21418,y=3494..29323,z=-69436..-64723
on x=73184..89417,y=-42741..-7654,z=2716..14770
on x=-19543..5754,y=-45523..-35685,z=-69929..-58853
on x=20033..44221,y=-84229..-57579,z=-8712..5719
on x=-91462..-67462,y=4054..26833,z=-39415..-13802
on x=27732..50763,y=-58005..-35512,z=-66011..-34072
on x=27133..51350,y=45426..71070,z=-8192..-4652
on x=32748..56378,y=-70321..-50194,z=26633..50320
on x=-79635..-59790,y=-1252..13376,z=19282..37497
on x=63307..93679,y=7073..20800,z=1161..28560
on x=-36145..-14630,y=-37537..-21452,z=56070..76078
on x=30686..50529,y=-67131..-36989,z=35265..66047
on x=-15752..-11751,y=59850..88935,z=18731..42395
on x=38283..60807,y=51015..57433,z=-40995..-25599
on x=-28800..-5978,y=73498..82844,z=-33104..-12502
on x=38063..67439,y=-35709..-20195,z=-53965..-32238
on x=-68345..-50452,y=8456..26579,z=30921..48065
on x=-32241..-19903,y=41696..65189,z=51000..65538
on x=36262..42472,y=-64295..-31497,z=-60784..-48215
on x=-19510..-110,y=31699..54917,z=-67629..-53476
on x=-62256..-40043,y=-35060..-34579,z=-70111..-50680
on x=-39707..-23353,y=-19810..6512,z=-87108..-53181
on x=-82176..-51976,y=-50348..-40880,z=-33910..-14246
on x=-83924..-70902,y=-19175..2985,z=-15384..15455
on x=49316..72497,y=425..6060,z=52206..70825
on x=-83699..-57057,y=-27150..-4795,z=22540..29041
on x=-3101..12001,y=68638..91778,z=-40657..-29719
on x=2252..24442,y=34848..55848,z=-75998..-48307
on x=-5069..16361,y=-20661..-2439,z=65914..86332
on x=-57402..-38222,y=-69446..-40489,z=-54314..-29224
on x=-13242..408,y=68201..84940,z=-45871..-38004
on x=56749..63913,y=-8638..3672,z=47720..62702
on x=54011..76285,y=-62270..-39823,z=-22993..-14872
on x=58382..77062,y=-20697..-7882,z=46625..52172
on x=-47219..-11653,y=26546..45116,z=-73892..-62298
on x=52120..73926,y=32675..54357,z=-45806..-32181
on x=-11456..-3541,y=-68839..-41789,z=45637..76793
on x=-45992..-25163,y=70590..94451,z=-3611..27080
on x=-77343..-54249,y=25725..46466,z=-7443..1553
on x=53624..60939,y=16322..19384,z=-60689..-54993
on x=-62023..-51180,y=-11378..-249,z=-60785..-36599
on x=51752..62523,y=-55025..-48761,z=-35067..-13224
on x=-79436..-62124,y=17736..25062,z=-33415..-15642
on x=58309..68890,y=-53920..-35770,z=-5858..12657
on x=-70319..-60470,y=13686..43339,z=-44612..-11192
on x=-14271..3865,y=-5940..16892,z=-89272..-77708
on x=56603..74277,y=-30330..-17500,z=-65513..-34252
on x=70395..81599,y=-8116..-4807,z=-47231..-23373
on x=26409..53159,y=37900..58813,z=-58362..-44114
on x=-6833..22656,y=49013..66204,z=-64722..-42138
on x=-79939..-47600,y=-54134..-42160,z=7100..29266
on x=-12387..1516,y=-93270..-73717,z=21246..31778
on x=-68856..-43032,y=-13298..19069,z=45157..61355
on x=-52372..-35450,y=7419..16683,z=-86081..-55547
on x=24953..45687,y=45007..63906,z=14094..39220
on x=-55616..-27396,y=62300..72738,z=-2200..9190
on x=50053..83913,y=-11119..-1995,z=-60574..-21845
on x=-34214..-11133,y=-11996..-4356,z=72157..82626
on x=-81300..-54391,y=-17887..-200,z=31179..50660
on x=-16117..18870,y=61218..84345,z=33172..58266
on x=-94022..-70920,y=422..21148,z=-40110..-4601
on x=7997..32024,y=-93325..-76394,z=-1522..5982
on x=-9500..16520,y=23350..46041,z=-88268..-58078
on x=-23747..-4542,y=-58091..-41118,z=62263..73989
on x=-17732..-2905,y=-95543..-64883,z=-1683..25695
on x=75498..83226,y=-6258..14464,z=2112..14733
on x=20265..41561,y=11946..41840,z=50936..79878
on x=53047..82535,y=-14468..1393,z=-43142..-21193
on x=27130..52544,y=57145..81711,z=-35213..-9752
on x=-45338..-15941,y=-19607..110,z=67448..89256
on x=-59996..-26746,y=2539..21005,z=53468..67082
on x=3402..28703,y=-93591..-66413,z=8528..10542
on x=-49409..-35285,y=32697..52202,z=48515..71687
on x=49025..53870,y=-9075..16495,z=-66082..-46321
on x=30601..51564,y=-69996..-47533,z=-25031..2209
on x=5635..35015,y=53724..79653,z=-26973..-16059
on x=55318..86926,y=-23333..-9355,z=7047..44226
on x=-30289..-12285,y=-68389..-57981,z=-48161..-40552
on x=58882..92805,y=23648..37563,z=5964..22967
on x=34496..42738,y=-72380..-48483,z=-34740..-955
on x=20317..32221,y=20101..38130,z=-86821..-68574
on x=-34120..-25879,y=-55894..-44842,z=-55903..-40976
on x=-45645..-28331,y=-74951..-59701,z=30291..41140
on x=-18717..-645,y=-49850..-25005,z=-85064..-56705
on x=-66069..-62114,y=-7151..16958,z=31325..61285
on x=-8768..2875,y=70141..79960,z=-16283..162
on x=48671..75660,y=34126..57253,z=25955..40686
on x=1592..40495,y=17266..42218,z=53722..79079
on x=-19745..6994,y=-93790..-75591,z=-28647..9949
on x=-33893..-12969,y=-90507..-60780,z=-42644..-10587
on x=60910..79183,y=-49087..-26806,z=-209..8359
on x=-35209..-832,y=18733..37433,z=-77554..-53413
off x=-24707..-6441,y=-41376..-10856,z=55331..90949
off x=6474..32653,y=-14454..17574,z=-88453..-71268
on x=-13493..-6403,y=47314..66556,z=-54874..-29147
on x=-9291..12608,y=53741..85000,z=-46306..-17017
off x=13983..32183,y=38353..59846,z=44630..60489
on x=-20250..12042,y=6499..35623,z=-81728..-71834
off x=-12034..26843,y=-13773..3,z=-84021..-75465
on x=-26797..-16552,y=-49960..-32197,z=-65821..-61668
on x=8368..23515,y=21417..44347,z=55621..84595
off x=49540..69051,y=31705..39693,z=-42453..-14061
on x=-69780..-50337,y=-64895..-31351,z=-1140..22240
on x=70874..82029,y=-4927..29616,z=-17097..7597
off x=-35974..-21133,y=-17861..70,z=66698..84031
off x=-47342..-11961,y=-672..21189,z=-74692..-65282
off x=24383..49319,y=48619..83833,z=15987..31130
off x=4559..23214,y=61581..86675,z=11178..41759
on x=61861..73539,y=-60405..-42686,z=5953..23802
off x=-59929..-28960,y=-56097..-28974,z=-52538..-46415
off x=-72615..-55995,y=-36832..-13278,z=19227..40885
on x=-12406..8284,y=-92734..-74910,z=-35203..-11978
off x=11249..35967,y=28322..57776,z=56548..84816
off x=44731..62241,y=35624..44662,z=-66511..-34520
off x=-87104..-74134,y=-13992..12953,z=-3294..10178
on x=-28985..-3937,y=-56788..-26115,z=63095..78456
off x=22993..41149,y=-72025..-38641,z=53155..65281
off x=-70263..-64986,y=10277..24698,z=17534..54469
on x=33137..54068,y=49394..60447,z=14589..36485
off x=1761..5646,y=-30207..-23218,z=67948..86068
off x=23532..51240,y=-68091..-30165,z=-66152..-47659
on x=63492..78630,y=26451..49621,z=-16485..2633
on x=61364..70239,y=-44857..-25262,z=-8792..15341
off x=-44240..-24659,y=40477..65486,z=46273..50810
on x=-82196..-65068,y=22741..26991,z=21666..26831
on x=19512..39779,y=51290..71942,z=33521..52593
off x=52818..66473,y=38215..68935,z=11423..29773
off x=19475..48035,y=50117..69010,z=-49063..-24987
on x=-14143..9865,y=-10817..8431,z=65536..80561
off x=-72733..-48163,y=-25291..-9724,z=-66757..-36479
off x=-43106..-20567,y=58626..65043,z=30453..56787
off x=13154..16214,y=5656..13752,z=66016..80418
off x=-11408..18735,y=39272..59415,z=60254..73108
on x=-77078..-61965,y=-17101..-10110,z=44955..62934
off x=40661..68779,y=45899..59382,z=-21792..-15201
off x=53315..78287,y=-31686..-15404,z=-41990..-23080
off x=-18699..12677,y=-34848..-11433,z=63732..95545
off x=-24502..-17077,y=-91563..-71124,z=15320..22882
on x=24300..44953,y=-8117..20940,z=-85817..-64192
off x=-57159..-39199,y=-29219..-23341,z=-68301..-54847
on x=34394..67095,y=-53551..-28864,z=43253..61926
off x=-50069..-30721,y=-14112..20450,z=-84644..-54725
on x=23629..36100,y=59625..71637,z=-42808..-14597
on x=-48311..-40298,y=-52473..-36850,z=-55879..-29005
on x=-12671..11981,y=-46219..-25335,z=68262..79543
on x=-4192..11450,y=-33767..-22561,z=62929..78589
on x=-72223..-46005,y=-407..27380,z=-64061..-33742
off x=41077..57062,y=-58884..-45405,z=19829..48890
off x=49487..69913,y=17640..41283,z=44735..66488
off x=-73528..-49377,y=-49007..-39363,z=9948..35961
off x=-71643..-56910,y=30988..61528,z=1455..7445
off x=-37842..-11285,y=64140..77407,z=-1880..26818
on x=-73578..-43035,y=9872..28002,z=44466..65647
off x=326..24287,y=68067..99200,z=-19343..11282
on x=55367..74607,y=22023..39362,z=-34371..-18588
off x=58603..79981,y=-22871..1116,z=22611..39894
off x=47930..73685,y=-6214..-2685,z=-60846..-31022
off x=22820..41562,y=-16265..-4928,z=58506..83229
off x=-88133..-62301,y=15247..30618,z=-10265..10510
off x=1253..22476,y=-60567..-30741,z=51569..81597
off x=63494..75187,y=-55856..-27033,z=-16423..-4091
off x=52204..70316,y=21707..45143,z=24511..43927
off x=27774..33872,y=30457..60549,z=52881..74012
off x=-67751..-48677,y=6535..14109,z=41406..63051
on x=62817..79049,y=4793..27715,z=-40593..-20781
on x=21141..51290,y=-74209..-55507,z=15792..30070
on x=-32225..-15877,y=21103..45553,z=-66267..-46475
off x=-53085..-35827,y=-36046..-19282,z=55940..62461
off x=17599..44204,y=13384..25615,z=-76042..-64772
on x=-23704..-3540,y=-20375..10502,z=59465..97525
off x=-82359..-68971,y=12420..30737,z=-38435..-11957
off x=-40061..-9787,y=-1989..10412,z=57295..74944
on x=-76144..-61483,y=-58373..-37868,z=-43080..-14295
on x=7696..27949,y=-72779..-56254,z=-54768..-32949
off x=39003..59670,y=-62963..-47662,z=1974..16893
off x=29968..35020,y=-22383..-11225,z=61966..80305
on x=50004..63242,y=-20016..6273,z=44941..69658
off x=-59279..-55566,y=-61178..-54387,z=-29065..-8057
off x=-61413..-26740,y=60749..79809,z=-21764..16450
off x=32196..66439,y=-60264..-26865,z=26941..60013
on x=-58520..-43376,y=37472..61676,z=23422..43293
off x=-56396..-25541,y=-68416..-55661,z=-19690..-9207
on x=18618..44778,y=-85629..-64714,z=-8305..17838
on x=-61504..-52282,y=-57912..-39990,z=-14780..6801
on x=11156..42237,y=11867..43976,z=-85896..-64810
on x=-55007..-28867,y=52919..63309,z=-40553..-23411
off x=59765..80865,y=35650..56453,z=-27643..-24090
off x=43182..81228,y=-34129..-7000,z=40063..52672
on x=-13505..20448,y=64022..91445,z=26743..48275
on x=27815..43279,y=-70617..-52124,z=24964..51972
off x=35675..49869,y=-62404..-56365,z=18269..35287
off x=35300..54594,y=35804..62612,z=-52851..-29341
off x=-71395..-53018,y=-19495..-4921,z=24089..52405
on x=-33332..-3755,y=-59570..-40365,z=56013..63939
on x=42324..60577,y=-49964..-34186,z=-52816..-27743
off x=48768..67360,y=-61320..-28892,z=-37831..-21312
on x=16338..40996,y=-53751..-18105,z=48116..68706
off x=-27168..-9712,y=-84533..-68775,z=4825..41138
off x=-60047..-36975,y=37870..61975,z=32191..46708
on x=26376..40244,y=-65020..-54338,z=43732..56693
off x=-91738..-68157,y=-24748..6980,z=-39819..-19451
on x=-5317..14596,y=-21035..-10563,z=71696..82823
off x=49847..64417,y=23298..37336,z=21615..52831
off x=-52432..-40255,y=-26836..-5279,z=-70876..-60890
off x=-20102..9857,y=-1721..20913,z=78025..98271
off x=-4990..6648,y=-21613..4090,z=-86165..-59847
on x=43038..56116,y=-63896..-49438,z=-26881..-4325
on x=-4380..2751,y=55174..85405,z=-46983..-21937
on x=70338..80320,y=-37100..-1120,z=-25918..-14953
on x=-54364..-27158,y=23057..50821,z=50502..69300
on x=1520..12529,y=-78320..-56572,z=38211..50552
off x=49738..66773,y=30561..59431,z=2951..29462
off x=16271..28523,y=-45270..-31343,z=63465..75526
on x=71234..85618,y=-41395..-7960,z=-4130..3364
on x=-69317..-40653,y=-67757..-43558,z=6142..24036
on x=25022..40901,y=-60207..-43245,z=29925..58586
off x=-81117..-47868,y=-43751..-16831,z=-35356..-29663
on x=-1180..17290,y=67627..89970,z=11528..29483
on x=-61937..-38595,y=-63471..-51265,z=-41226..-7643
off x=-79920..-67593,y=23081..43335,z=-27955..-4111
on x=52546..75163,y=49315..56898,z=-14675..7154
off x=3726..34564,y=-66091..-47518,z=-66664..-37455
on x=34949..60501,y=-28771..-11144,z=51352..61485
on x=-12954..14301,y=-93475..-65638,z=-10004..11614
on x=11713..39311,y=-13965..-4062,z=-81763..-73474
on x=51282..59807,y=-57951..-35734,z=5994..36901
off x=-7411..26099,y=32784..55370,z=51744..64477
off x=28307..41980,y=-60121..-44354,z=-62749..-36419
off x=67213..84298,y=-29046..-11454,z=21296..44275
off x=-63074..-36397,y=-44584..-33108,z=-62259..-41864
on x=-52919..-32901,y=-76109..-58400,z=-18640..-10098
off x=22269..46465,y=-75997..-51073,z=-46540..-31244
on x=-13358..1813,y=-48320..-19885,z=65575..90081
on x=57248..73703,y=50245..59021,z=-23752..-325
off x=-61356..-40218,y=-63746..-48236,z=-4162..13109
on x=-86721..-52575,y=18886..39871,z=-27525..-18940
off x=-32958..-9613,y=54585..89567,z=-25434..-6238
on x=-34933..-16868,y=35195..53598,z=53014..59010
on x=-50111..-41812,y=53666..72265,z=-43276..-17297
off x=-48541..-31980,y=-29629..-9928,z=-72149..-56249
off x=8404..34890,y=-91946..-64517,z=-36821..-5171
on x=-61476..-46150,y=34461..64440,z=-52672..-31719
on x=17053..48276,y=8196..30921,z=-90002..-67999
off x=30567..51548,y=48492..49629,z=-60064..-40577
off x=-11485..16121,y=49496..85403,z=-58551..-28464
off x=-71575..-66788,y=-28618..-14850,z=25881..53946
on x=-82870..-69951,y=-31733..-21150,z=2448..31565
off x=21102..31260,y=28479..55875,z=53439..84269
on x=-92343..-73224,y=-5440..30589,z=-11302..13705
off x=57846..67138,y=-51876..-19075,z=25743..40789
on x=-42146..-14334,y=-91427..-56913,z=11466..17841
on x=-8337..5046,y=-97914..-59588,z=-17297..-3854
on x=72959..77792,y=-7695..23596,z=16641..36941
off x=48708..70778,y=-52975..-24049,z=38893..49884
off x=-48001..-30155,y=-34640..-8100,z=-68127..-58824
on x=-23589..-642,y=-55673..-20006,z=53073..77106
on x=-33552..-8377,y=53425..81818,z=-47589..-31657
on x=-4435..19578,y=50903..85239,z=-52340..-31908
off x=-65297..-43991,y=45255..59229,z=-39945..-7463
off x=-27752..-7352,y=56826..62480,z=-59434..-52524
on x=-52395..-36890,y=-60404..-53667,z=-52971..-34646
on x=-17036..-10608,y=22073..34956,z=-87647..-59521
on x=-20406..2585,y=-75526..-51689,z=-53856..-28503
off x=57297..67915,y=40135..59210,z=-10318..20975
on x=54413..78003,y=2451..10064,z=24601..41429
off x=-30323..-21158,y=35905..68915,z=-71573..-39806
off x=-24500..-12434,y=-76402..-60478,z=-18069..-8858
off x=60931..77777,y=-41037..-25321,z=-7530..26700
off x=37607..47278,y=-15018..6458,z=67782..87778
off x=-32488..-5083,y=26413..40281,z=60169..76864
off x=7746..18062,y=45927..81504,z=29094..62804
off x=-60955..-54035,y=33191..54217,z=25181..37101
on x=52094..81032,y=-29343..-25525,z=-50030..-21747
off x=57932..85467,y=-4500..2029,z=-46429..-9720
on x=36386..64660,y=-73512..-44017,z=16903..32394
on x=-1492..33205,y=-82073..-69752,z=5149..23012
off x=-6314..2597,y=-82434..-52899,z=-54568..-42166
off x=47307..75857,y=-39178..-30672,z=23379..47503
on x=64489..84771,y=-20277..-8288,z=-10334..20346
off x=-40498..-13375,y=-21960..-1763,z=-89263..-65000
on x=19554..31662,y=55672..61731,z=-60358..-37905
on x=-39219..-7291,y=35227..63484,z=-72685..-36545
on x=43613..70012,y=-33475..-18062,z=33764..41733
on x=19674..39635,y=-73170..-53816,z=-59139..-34916
on x=-2303..14767,y=69085..89874,z=-44748..-25607
off x=-41923..-21656,y=-11475..12712,z=-92655..-63472
off x=-65609..-28677,y=49338..76417,z=-17143..20767
on x=-66708..-54445,y=-8844..3726,z=40665..69409
on x=57741..80306,y=-53751..-27969,z=-2005..11767
off x=-36833..-8071,y=11487..45001,z=-74496..-55088
on x=-33089..-16969,y=-41928..-15082,z=-82121..-64107
}
}

38
2021/src/common.rs Normal file
View File

@ -0,0 +1,38 @@
use std::env;
#[cfg(not(debug_assertions))]
use std::ops::{AddAssign, MulAssign};
#[cfg(debug_assertions)]
use std::{
fmt::{Debug, Display},
str::FromStr,
};
pub fn read_file(day: usize) -> String {
std::fs::read_to_string(env::var("AOC_INPUT").unwrap_or_else(|_| format!("inputs/day{:0>2}", day))).unwrap()
}
pub fn parse_nums(l: &str) -> Vec<usize> {
l.lines().map(parse_num).collect()
}
pub fn parse_nums_comma(l: &str) -> Vec<usize> {
l.trim().split(',').map(parse_num).collect()
}
#[cfg(debug_assertions)]
pub fn parse_num<T: FromStr<Err: Debug> + Display>(s: &str) -> T {
s.parse().unwrap_or_else(|e| panic!("Invalid number {s}: {e:?}"))
}
#[cfg(not(debug_assertions))]
pub fn parse_num<T: From<u8> + AddAssign<T> + MulAssign<T>>(s: &str) -> T {
let mut digits = s.bytes().map(|b| T::from(b - b'0'));
let mut n = digits.next().unwrap();
for digit in digits {
n *= T::from(10);
n += digit;
}
n
}

132
2021/src/grid.rs Normal file
View File

@ -0,0 +1,132 @@
pub mod cell;
pub mod direction;
pub mod position;
pub use direction::*;
use itertools::{join, Itertools, MinMaxResult};
pub use position::*;
use std::{collections::HashMap, fmt::Display, hash::BuildHasher};
#[allow(clippy::len_without_is_empty)] // I mainly have this for assertions in benchmarks
pub trait Grid<T, const D: usize> {
fn get(&self, pos: &PositionND<D>) -> Option<&T>;
fn insert<Pos: Into<PositionND<D>>>(&mut self, pos: Pos, element: T);
fn len(&self) -> usize;
}
#[derive(Debug, Clone, PartialEq)]
pub struct HashGrid<T: Default, const D: usize> {
pub fields: HashMap<PositionND<D>, T>,
}
impl<T: Default, const D: usize> Grid<T, D> for HashGrid<T, D> {
fn get(&self, pos: &PositionND<D>) -> Option<&T> {
self.fields.get(pos)
}
fn insert<Pos: Into<PositionND<D>>>(&mut self, pos: Pos, t: T) {
self.fields.insert(pos.into(), t);
}
fn len(&self) -> usize {
self.fields.len()
}
}
impl<T: Default + Copy> HashGrid<T, 2> {
pub fn from_bytes_2d<F: FnMut(u8) -> T + Copy>(raw: &str, mut f: F) -> HashGrid<T, 2> {
raw.lines()
.enumerate()
.flat_map(move |(y, l)| l.bytes().enumerate().map(move |(x, c)| (PositionND { points: [x as i64, y as i64] }, f(c))))
.collect()
}
}
impl<T: Default, const D: usize> std::iter::FromIterator<(PositionND<D>, T)> for HashGrid<T, D> {
fn from_iter<I: IntoIterator<Item = (PositionND<D>, T)>>(iter: I) -> Self {
HashGrid { fields: iter.into_iter().collect() }
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct VecGrid<T> {
pub fields: Vec<Vec<T>>,
}
impl<T> Grid<T, 2> for VecGrid<T> {
fn get(&self, pos: &PositionND<2>) -> Option<&T> {
self.fields.get(pos.points[0] as usize)?.get(pos.points[1] as usize)
}
fn insert<Pos: Into<PositionND<2>>>(&mut self, pos: Pos, element: T) {
let PositionND { points: [x, y] } = pos.into();
self.fields[x as usize][y as usize] = element;
}
fn len(&self) -> usize {
self.fields.len()
}
}
impl<T: Copy> VecGrid<T> {
pub fn from_bytes_2d<F: FnMut(u8) -> T + Copy>(raw: &str, f: F) -> VecGrid<T> {
VecGrid { fields: raw.lines().map(|l| l.bytes().map(f).collect()).collect() }
}
}
pub struct Boundaries {
pub x_min: i64,
pub x_max: i64,
pub y_min: i64,
pub y_max: i64,
}
pub fn get_boundaries(input: &[&PositionND<2>]) -> Boundaries {
let (x_min, x_max) = match input.iter().map(|p| p.points[0]).minmax() {
MinMaxResult::NoElements => (0, 0),
MinMaxResult::MinMax(min, max) => (min, max),
MinMaxResult::OneElement(x) => (x, x),
};
let (y_min, y_max) = match input.iter().map(|p| p.points[1]).minmax() {
MinMaxResult::NoElements => (0, 0),
MinMaxResult::MinMax(min, max) => (min, max),
MinMaxResult::OneElement(x) => (x, x),
};
Boundaries { x_min, x_max, y_min, y_max }
}
pub fn draw_ascii<T: Display + Default, S: BuildHasher>(coordinates: &HashMap<PositionND<2>, T, S>) -> String {
let b = get_boundaries(&coordinates.keys().collect::<Vec<_>>());
join(
(b.y_min..=b.y_max).rev().map(|y| {
(b.x_min..=b.x_max)
.map(|x| coordinates.get(&PositionND { points: [x, y] }).unwrap_or(&T::default()).to_string())
.collect::<String>()
}),
"\n",
)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_add() {
assert_eq!(PositionND::from([0, 2]) + PositionND::from([-1, 0]), [-1, 2].into());
assert_eq!(PositionND::from([0, -1]) + PositionND::from(Direction::Up), [0, 0].into());
}
#[test]
fn test_sub() {
assert_eq!(PositionND::from([0, 2]) - PositionND::from([-1, 0]), [1, 2].into());
assert_eq!(PositionND::from([0, -1]) - PositionND::from([0, -1]), [0, 0].into());
}
#[test]
fn test_mul() {
assert_eq!(PositionND::from([0, 2]) * 5, [0, 10].into());
assert_eq!(PositionND::from([0, -1]) * -2, [0, 2].into());
}
}

34
2021/src/grid/cell.rs Normal file
View File

@ -0,0 +1,34 @@
use std::{
fmt::{self, Display, Formatter}, hash::Hash
};
#[derive(Hash, PartialEq, Eq, Debug, Clone, Copy)]
pub enum Cell {
Alive,
Dead,
}
impl From<u8> for Cell {
fn from(b: u8) -> Self {
match b {
b'.' => Cell::Dead,
b'#' => Cell::Alive,
_ => unreachable!(),
}
}
}
impl Display for Cell {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
f.write_str(match self {
Cell::Alive => ".",
Cell::Dead => "#",
})
}
}
impl Default for Cell {
fn default() -> Self {
Cell::Dead
}
}

View File

@ -0,0 +1,49 @@
use impl_ops::*;
use std::{ops, ops::AddAssign};
pub const ALL_DIRECTIONS: [Direction; 4] = [Direction::Up, Direction::Down, Direction::Left, Direction::Right];
#[derive(Clone, Copy, Debug)]
pub enum Direction {
Up,
Down,
Left,
Right,
}
impl AddAssign<i8> for Direction {
fn add_assign(&mut self, rhs: i8) {
*self = *self + rhs;
}
}
impl_op!(+ |a: Direction, b: i8| -> Direction {
match b {
-1 | 3 => match a {
Direction::Up => Direction::Left,
Direction::Right => Direction::Up,
Direction::Down => Direction::Right,
Direction::Left => Direction::Down,
},
1 | -3 => match a {
Direction::Up => Direction::Right,
Direction::Right => Direction::Down,
Direction::Down => Direction::Left,
Direction::Left => Direction::Up,
},
0 | 4 | -4 => a,
2 | -2 => match a {
Direction::Up => Direction::Down,
Direction::Right => Direction::Left,
Direction::Down => Direction::Up,
Direction::Left => Direction::Right,
},
n => unreachable!(format!("Illegal turn value: {}", n)),
}
});
impl Direction {
pub fn turn(&mut self, turn_value: i64) {
*self += turn_value as i8;
}
}

259
2021/src/grid/position.rs Normal file
View File

@ -0,0 +1,259 @@
extern crate test;
use super::direction::*;
use std::{
convert::TryInto,
hash::Hash,
ops::{Add, Mul, Sub},
};
#[derive(Hash, PartialEq, Eq, Debug, Clone, Copy)]
pub struct PositionND<const DIMS: usize> {
pub points: [i64; DIMS],
}
pub type Position2D = PositionND<2>;
impl<I, const D: usize> From<[I; D]> for PositionND<D>
where I: TryInto<i64> + Copy
{
fn from(s: [I; D]) -> Self {
let mut points = [0; D];
for i in 0..D {
points[i] = s[i].try_into().unwrap_or_else(|_| panic!("number did not fit in target type"))
}
Self { points }
}
}
pub const fn num_neighbors(d: usize) -> usize {
3usize.pow(d as u32) - 1
}
impl<const DIMS: usize> PositionND<DIMS> {
pub const fn zero() -> Self {
PositionND { points: [0; DIMS] }
}
pub fn from_padded(slice: &[i64]) -> PositionND<DIMS> {
let mut points = [0; DIMS];
#[allow(clippy::manual_memcpy)]
for i in 0..(DIMS.min(slice.len())) {
points[i] = slice[i];
}
PositionND { points }
}
pub fn neighbors(&self) -> [PositionND<DIMS>; num_neighbors(DIMS)]
where [PositionND<DIMS>; num_neighbors(DIMS) + 1]: Sized {
let ns = neighbor_vectors::<DIMS>();
let mut out = [*self; num_neighbors(DIMS)];
for (out, dir) in out.iter_mut().zip(IntoIterator::into_iter(ns).filter(|n| n != &[0; DIMS])) {
*out = *out + PositionND::from(dir);
}
out
}
}
impl PositionND<2> {
pub fn neighbors_no_diagonals_only_positive(&self) -> [PositionND<2>; 2] {
let PositionND::<2> { points: [x, y] } = *self;
[[x + 1, y].into(), [x, y + 1].into()]
}
pub fn neighbors_no_diagonals(&self) -> [PositionND<2>; 4] {
let PositionND::<2> { points: [x, y] } = *self;
[[x + 1, y].into(), [x, y + 1].into(), [x - 1, y].into(), [x, y - 1].into()]
}
}
#[macro_export]
macro_rules! dim {
($d: expr) => {{
let mut out = [[0; D]; num_neighbors(D) + 1];
let mut i = 0;
for offset in -1..=1 {
for inner in neighbor_vectors::<$d>() {
out[i][0] = offset;
let mut j = 1;
for e in inner {
out[i][j] = e;
j += 1;
}
i += 1;
}
}
out
}};
}
fn neighbor_vectors<const D: usize>() -> [[i64; D]; num_neighbors(D) + 1]
where
{
// I would love to just call neighbor_vectors::<D-1>(), but it seems to be impossible to get the
// correct constraints for that.
match D {
0 => unreachable!(),
1 => {
let mut out = [[0; D]; num_neighbors(D) + 1];
out[0] = [-1; D];
out[1] = [0; D];
out[2] = [1; D];
out
}
2 => dim!(1),
3 => dim!(2),
4 => dim!(3),
5 => dim!(4),
6 => dim!(5),
7 => dim!(6),
// Adding more causes a stackoverflow. How curious.
_ => unimplemented!(),
}
}
impl<const D: usize> Mul<i64> for PositionND<D> {
type Output = PositionND<D>;
fn mul(mut self, rhs: i64) -> Self::Output {
for p in self.points.iter_mut() {
*p *= rhs;
}
self
}
}
impl<const D: usize> Add<PositionND<D>> for PositionND<D> {
type Output = PositionND<D>;
fn add(mut self, rhs: PositionND<D>) -> Self::Output {
for (x, y) in self.points.iter_mut().zip(rhs.points) {
*x += y;
}
self
}
}
impl<const D: usize> Sub<PositionND<D>> for PositionND<D> {
type Output = PositionND<D>;
fn sub(mut self, rhs: PositionND<D>) -> Self::Output {
for (x, y) in self.points.iter_mut().zip(rhs.points) {
*x -= y;
}
self
}
}
impl From<Direction> for PositionND<2> {
fn from(d: Direction) -> Self {
match d {
Direction::Up => PositionND::from([0, 1]),
Direction::Right => PositionND::from([1, 0]),
Direction::Left => PositionND::from([-1, 0]),
Direction::Down => PositionND::from([0, -1]),
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_neighbors_2d() {
let p = PositionND { points: [0, 0] };
let n = p.neighbors();
assert_eq!(
n,
[
PositionND { points: [-1, -1] },
PositionND { points: [-1, 0] },
PositionND { points: [-1, 1] },
PositionND { points: [0, -1] },
PositionND { points: [0, 1] },
PositionND { points: [1, -1] },
PositionND { points: [1, 0] },
PositionND { points: [1, 1] },
]
);
let p = PositionND { points: [1, 1] };
let n = p.neighbors();
assert_eq!(
n,
[
PositionND { points: [0, 0] },
PositionND { points: [0, 1] },
PositionND { points: [0, 2] },
PositionND { points: [1, 0] },
PositionND { points: [1, 2] },
PositionND { points: [2, 0] },
PositionND { points: [2, 1] },
PositionND { points: [2, 2] },
]
)
}
#[test]
fn test_neighbors_3d() {
let p = PositionND { points: [0, 0, 0] };
let n = p.neighbors();
assert_eq!(
n,
[
PositionND { points: [-1, -1, -1] },
PositionND { points: [-1, -1, 0] },
PositionND { points: [-1, -1, 1] },
PositionND { points: [-1, 0, -1] },
PositionND { points: [-1, 0, 0] },
PositionND { points: [-1, 0, 1] },
PositionND { points: [-1, 1, -1] },
PositionND { points: [-1, 1, 0] },
PositionND { points: [-1, 1, 1] },
PositionND { points: [0, -1, -1] },
PositionND { points: [0, -1, 0] },
PositionND { points: [0, -1, 1] },
PositionND { points: [0, 0, -1] },
PositionND { points: [0, 0, 1] },
PositionND { points: [0, 1, -1] },
PositionND { points: [0, 1, 0] },
PositionND { points: [0, 1, 1] },
PositionND { points: [1, -1, -1] },
PositionND { points: [1, -1, 0] },
PositionND { points: [1, -1, 1] },
PositionND { points: [1, 0, -1] },
PositionND { points: [1, 0, 0] },
PositionND { points: [1, 0, 1] },
PositionND { points: [1, 1, -1] },
PositionND { points: [1, 1, 0] },
PositionND { points: [1, 1, 1] },
]
);
}
#[test]
fn test_neighbor_vectors() {
let n = neighbor_vectors::<2>();
assert_eq!(n, [[-1, -1], [-1, 0], [-1, 1], [0, -1], [0, 0], [0, 1], [1, -1], [1, 0], [1, 1],]);
}
#[bench]
fn bench_neighbor_vectors_2d(b: &mut test::Bencher) {
b.iter(|| test::black_box(neighbor_vectors::<2>()))
}
#[bench]
fn bench_neighbor_vectors_3d(b: &mut test::Bencher) {
b.iter(|| test::black_box(neighbor_vectors::<3>()))
}
#[bench]
fn bench_neighbor_vectors_4d(b: &mut test::Bencher) {
b.iter(|| test::black_box(neighbor_vectors::<4>()))
}
#[bench]
fn bench_neighbor_vectors_5d(b: &mut test::Bencher) {
b.iter(|| test::black_box(neighbor_vectors::<5>()))
}
}

7
2021/src/lib.rs Normal file
View File

@ -0,0 +1,7 @@
#![allow(incomplete_features)]
#![feature(generic_const_exprs)]
#![feature(associated_type_bounds)]
#![feature(test)]
pub mod common;
pub mod teststuff;
pub mod grid;

46
2021/src/teststuff.rs Normal file
View File

@ -0,0 +1,46 @@
#[macro_export]
macro_rules! bench {
($part: ident $(<$gen: literal>)? ($($param: expr),*) == $expected:expr) => {
paste::paste! {
#[bench]
fn [<$part $($gen)? _bench>](b: &mut test::Bencher) {
let raw = &read_file(DAY);
let input = parse_input(&raw);
b.iter(|| assert_eq!($part $(::<$gen>)? (test::black_box(&input)$(, $param)*), $expected));
}
}
};
}
#[macro_export]
macro_rules! bench_input {
($fn:expr => $expected:expr) => {
#[bench]
fn bench_input_parsing(b: &mut test::Bencher) {
let raw = &read_file(DAY);
b.iter(|| assert_eq!($fn(&parse_input(test::black_box(&raw))), $expected));
}
};
}
#[macro_export]
macro_rules! test {
($part: ident $(<$gen: literal>)? ($($param: expr),*) == $expected:expr) => {
paste::paste! {
#[test]
fn [<$part $($gen)? _test>]() {
let input = parse_input(TEST_INPUT);
assert_eq!($part $(::<$gen>)? (&input$(, $param)*), $expected);
}
}
};
(with $input: ident: $part: ident $(<$gen: literal>)? ($($param: expr),*) == $expected:expr) => {
paste::paste! {
#[test]
fn [<$part $($gen)? $input:lower _test>]() {
let input = parse_input([<TEST_INPUT $input>]);
assert_eq!($part $(::<$gen>)? (&input$(, $param)*), $expected);
}
}
};
}

15
2022/Cargo.toml Normal file
View File

@ -0,0 +1,15 @@
[package]
name = "aoc2022"
version = "0.1.0"
edition = "2021"
[dependencies]
fnv = "1.0.7"
impl_ops = "0.1.1"
itertools = "0.10.5"
paste = "1.0"
rayon = "1.6.0"
scanf = "1.2.1"
[profile.bench]
lto = true

66
2022/day1_dc.sh Executable file
View File

@ -0,0 +1,66 @@
#!/bin/sh
echo '
[+zld!=r]sr
[ld1+sd0lrx]sg
[r]ss
[sasblalblalb>ssxz1!=f]sf' > day1.tmp
cat inputs/day01 | sed 's/^$/lgx/' >> day1.tmp
echo 'lgxlfxp' >> day1.tmp
dc -f day1.tmp
rm day1.tmp
_='
Commented version of the code above:
# Macro `r` which sums a group of values on the stack
[
# Add the top 2 values of the stack
+
# If the stack size (z) is not equal to `ld` (the number of elves processed so far +1), recurse.
# That means we’ll keep reducing the stack until all values of this batch are processed.
zld!=r
]sr
# Macro `g`, which prepares everything to process an elf
[
# Number of elves processed will be in `d`. Load that, add 1 to it, and store it again.
# (will load 0 on first iteration)
ld1+sd
# Push 0 to the stack.
# This makes stack reduction above easier because we can assume that every elf
# has at least two values (one of them will be this 0)
0
# Call `r` from above to sum all values in this group.
lrx
]sg
# Macro `s` which swaps the top 2 elements of the stack
[r]ss
# Macro `f` which reduces the stack until only the biggest value is left
[
# Duplicate the top two values on the stack.
# e.g. [1, 2, 3] would become [1, 2, 3, 2, 3]
# The comparison right after this pops the top two values,
# so we have to duplicate them to use them after.
sasblalblalb
# If the top value is greater than the one below, call `s` to switch them.
>s
# Pop the top value (now the smaller of the two) and store it in `x`
# (there’s no way to just pop, so we instead store
# to a register that is overwritten in each iteration)
sx
# If stack size is not 1, recurse.
z1!=f
]sf
# This puts the inputs into our dc file, replacing blank lines with `lgx`.
# Since blank lines are meaningless in dc,
# we have to insert something between the blocks that will separate them.
# `lgx` will load and execute the macro `x`,
# which increments the total number of elves and sums the calories of that elf.
cat inputs/day01 | sed "s/^$/lgx/" >> day1.tmp
# Add one last `lgx` to batch up the last elf, then execute macro `f` which finds the biggest value on the stack, then print that.
echo "lgxlfxp" >> day1.tmp
'

2238
2022/inputs/day01 Normal file

File diff suppressed because it is too large Load Diff

2500
2022/inputs/day02 Normal file

File diff suppressed because it is too large Load Diff

300
2022/inputs/day03 Normal file
View File

@ -0,0 +1,300 @@
TZZjzzZLfZbzgzZNNJZjwCVbwMmhwCbBpCMMBCbM
qRQPDqnWFQDtCCBQmQwmGGVG
FPllWPDPrncZsLVrgSZTSZ
RczPzRzvflVwfplrZQglmmJJDGQJ
nFbBWWFZbZtJDjmgmqqF
bnMNZWnWWHTLBBdwcCwcPCwpCSpPLc
CjpMtptpChnpMnCSGjSShMqpTVVWFFTVNVNLmHwmHLTcFnVT
fglsGJsJssBPszvddgTFVTFFFBwwTVVmHVFF
JgJrDgsPfMDhGhCRQC
PSMDSMhwmPwqDMmzrtttNQvNFmFFGFtLld
nRTCCQjcTVJJTVTbggTnFvtNdGdlFbFvbHtWFLNt
gjfTZZCRCnZJjJRRQBCBszDMPppfsPwMzfMqDsSs
LTmnZTgMmbWWGWZQZb
cHCCHH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ff suppressed because it is too large Load Diff

514
2022/inputs/day05 Normal file
View File

@ -0,0 +1,514 @@
[S] [C] [Z]
[F] [J] [P] [T] [N]
[G] [H] [G] [Q] [G] [D]
[V] [V] [D] [G] [F] [D] [V]
[R] [B] [F] [N] [N] [Q] [L] [S]
[J] [M] [M] [P] [H] [V] [B] [B] [D]
[L] [P] [H] [D] [L] [F] [D] [J] [L]
[D] [T] [V] [M] [J] [N] [F] [M] [G]
1 2 3 4 5 6 7 8 9
move 3 from 4 to 6
move 1 from 5 to 8
move 3 from 7 to 3
move 4 from 5 to 7
move 1 from 7 to 8
move 3 from 9 to 4
move 2 from 8 to 2
move 4 from 4 to 5
move 2 from 5 to 1
move 2 from 5 to 6
move 7 from 8 to 1
move 9 from 3 to 9
move 11 from 6 to 5
move 2 from 6 to 7
move 12 from 1 to 4
move 10 from 2 to 9
move 2 from 3 to 9
move 1 from 7 to 5
move 4 from 7 to 6
move 2 from 6 to 1
move 5 from 1 to 6
move 10 from 9 to 1
move 9 from 9 to 8
move 13 from 4 to 3
move 7 from 6 to 2
move 2 from 8 to 5
move 9 from 3 to 9
move 8 from 9 to 8
move 4 from 8 to 4
move 1 from 7 to 5
move 3 from 9 to 1
move 7 from 2 to 1
move 1 from 3 to 1
move 1 from 3 to 6
move 1 from 6 to 1
move 2 from 3 to 6
move 5 from 4 to 1
move 1 from 6 to 1
move 3 from 8 to 7
move 8 from 8 to 4
move 3 from 5 to 4
move 1 from 6 to 7
move 1 from 5 to 8
move 4 from 5 to 2
move 7 from 5 to 8
move 3 from 2 to 7
move 7 from 4 to 8
move 11 from 8 to 4
move 15 from 4 to 1
move 25 from 1 to 6
move 4 from 8 to 7
move 1 from 2 to 4
move 11 from 6 to 4
move 12 from 6 to 3
move 1 from 1 to 9
move 1 from 9 to 8
move 16 from 1 to 3
move 1 from 8 to 7
move 12 from 4 to 6
move 9 from 6 to 5
move 3 from 6 to 5
move 6 from 7 to 5
move 3 from 3 to 5
move 2 from 6 to 3
move 11 from 5 to 8
move 2 from 8 to 3
move 2 from 1 to 4
move 7 from 3 to 1
move 2 from 4 to 6
move 2 from 6 to 2
move 5 from 7 to 3
move 1 from 1 to 6
move 1 from 1 to 8
move 2 from 2 to 5
move 1 from 7 to 4
move 1 from 1 to 2
move 10 from 3 to 5
move 11 from 3 to 6
move 1 from 4 to 9
move 1 from 9 to 4
move 1 from 4 to 2
move 2 from 5 to 9
move 2 from 2 to 8
move 2 from 1 to 6
move 2 from 1 to 2
move 2 from 3 to 6
move 3 from 8 to 1
move 3 from 1 to 4
move 7 from 8 to 3
move 2 from 9 to 5
move 2 from 4 to 9
move 7 from 5 to 6
move 2 from 8 to 6
move 1 from 4 to 8
move 2 from 2 to 4
move 21 from 6 to 3
move 10 from 5 to 7
move 7 from 7 to 6
move 1 from 9 to 3
move 1 from 4 to 9
move 1 from 9 to 4
move 1 from 8 to 4
move 8 from 6 to 4
move 1 from 4 to 5
move 1 from 5 to 8
move 4 from 3 to 6
move 1 from 8 to 2
move 1 from 4 to 2
move 2 from 7 to 3
move 2 from 2 to 7
move 22 from 3 to 5
move 4 from 6 to 2
move 2 from 6 to 9
move 7 from 3 to 9
move 6 from 9 to 1
move 18 from 5 to 3
move 2 from 5 to 4
move 20 from 3 to 5
move 3 from 7 to 3
move 5 from 1 to 2
move 11 from 5 to 7
move 1 from 1 to 7
move 3 from 9 to 3
move 16 from 5 to 8
move 7 from 8 to 7
move 1 from 9 to 2
move 8 from 2 to 3
move 2 from 2 to 4
move 3 from 3 to 1
move 9 from 3 to 8
move 1 from 6 to 3
move 9 from 7 to 3
move 3 from 1 to 8
move 1 from 7 to 9
move 1 from 9 to 4
move 1 from 7 to 5
move 10 from 4 to 5
move 2 from 4 to 2
move 19 from 8 to 5
move 1 from 8 to 3
move 4 from 3 to 5
move 2 from 4 to 8
move 4 from 7 to 8
move 4 from 3 to 9
move 4 from 7 to 6
move 2 from 2 to 5
move 2 from 3 to 2
move 6 from 8 to 7
move 1 from 8 to 4
move 2 from 6 to 4
move 3 from 4 to 8
move 3 from 9 to 2
move 4 from 7 to 8
move 28 from 5 to 8
move 16 from 8 to 4
move 11 from 8 to 4
move 3 from 3 to 4
move 7 from 5 to 8
move 13 from 8 to 7
move 1 from 5 to 6
move 1 from 6 to 7
move 1 from 9 to 2
move 2 from 6 to 2
move 12 from 4 to 9
move 4 from 4 to 1
move 2 from 9 to 8
move 4 from 8 to 3
move 3 from 4 to 5
move 4 from 4 to 1
move 4 from 4 to 7
move 3 from 7 to 9
move 5 from 9 to 7
move 7 from 2 to 3
move 1 from 5 to 7
move 8 from 1 to 5
move 1 from 2 to 4
move 11 from 3 to 1
move 10 from 5 to 3
move 3 from 9 to 1
move 3 from 9 to 6
move 5 from 1 to 6
move 7 from 6 to 9
move 8 from 9 to 7
move 9 from 3 to 4
move 1 from 6 to 9
move 8 from 7 to 1
move 9 from 4 to 2
move 2 from 1 to 6
move 3 from 2 to 6
move 4 from 4 to 6
move 2 from 9 to 8
move 2 from 1 to 2
move 1 from 3 to 8
move 2 from 8 to 4
move 1 from 6 to 8
move 11 from 1 to 6
move 1 from 1 to 5
move 3 from 2 to 9
move 2 from 9 to 3
move 1 from 1 to 7
move 2 from 4 to 9
move 4 from 2 to 9
move 2 from 8 to 5
move 10 from 6 to 1
move 2 from 5 to 6
move 5 from 9 to 8
move 5 from 8 to 7
move 1 from 2 to 1
move 7 from 1 to 2
move 2 from 9 to 4
move 1 from 3 to 5
move 15 from 7 to 2
move 8 from 6 to 3
move 2 from 4 to 3
move 2 from 6 to 4
move 4 from 7 to 1
move 4 from 7 to 5
move 1 from 6 to 4
move 3 from 1 to 7
move 5 from 7 to 6
move 4 from 7 to 5
move 18 from 2 to 4
move 5 from 6 to 4
move 4 from 1 to 2
move 8 from 3 to 8
move 2 from 8 to 4
move 2 from 3 to 7
move 1 from 5 to 7
move 3 from 8 to 4
move 2 from 7 to 2
move 1 from 3 to 8
move 9 from 2 to 6
move 2 from 8 to 6
move 1 from 7 to 3
move 1 from 3 to 5
move 3 from 6 to 8
move 1 from 8 to 5
move 1 from 5 to 9
move 1 from 1 to 2
move 5 from 4 to 6
move 10 from 6 to 2
move 5 from 2 to 6
move 5 from 6 to 4
move 1 from 6 to 3
move 6 from 4 to 6
move 3 from 2 to 6
move 2 from 2 to 3
move 11 from 4 to 6
move 1 from 9 to 5
move 4 from 6 to 7
move 1 from 4 to 3
move 12 from 4 to 3
move 1 from 8 to 6
move 9 from 5 to 7
move 1 from 5 to 2
move 1 from 8 to 5
move 1 from 4 to 9
move 9 from 7 to 9
move 1 from 3 to 4
move 2 from 3 to 6
move 2 from 5 to 6
move 2 from 8 to 5
move 11 from 3 to 4
move 2 from 3 to 1
move 1 from 2 to 3
move 1 from 3 to 8
move 3 from 7 to 9
move 5 from 4 to 2
move 2 from 5 to 8
move 6 from 4 to 2
move 1 from 1 to 3
move 12 from 9 to 1
move 6 from 1 to 6
move 1 from 8 to 4
move 1 from 8 to 3
move 5 from 2 to 7
move 2 from 3 to 9
move 5 from 7 to 1
move 1 from 7 to 5
move 2 from 9 to 1
move 14 from 1 to 7
move 2 from 4 to 7
move 7 from 2 to 4
move 1 from 2 to 1
move 1 from 1 to 3
move 1 from 5 to 4
move 1 from 9 to 6
move 16 from 6 to 5
move 2 from 5 to 4
move 12 from 6 to 8
move 10 from 4 to 8
move 9 from 7 to 3
move 4 from 7 to 6
move 11 from 5 to 8
move 2 from 5 to 2
move 14 from 8 to 9
move 1 from 5 to 1
move 3 from 9 to 4
move 2 from 2 to 1
move 7 from 8 to 3
move 6 from 3 to 5
move 8 from 9 to 8
move 1 from 6 to 1
move 1 from 4 to 2
move 4 from 3 to 8
move 1 from 7 to 2
move 3 from 1 to 5
move 2 from 5 to 7
move 3 from 9 to 2
move 1 from 1 to 8
move 5 from 5 to 4
move 2 from 7 to 8
move 4 from 2 to 5
move 1 from 2 to 4
move 2 from 7 to 8
move 4 from 6 to 2
move 6 from 5 to 3
move 1 from 6 to 5
move 1 from 5 to 3
move 1 from 3 to 8
move 8 from 8 to 3
move 9 from 8 to 5
move 9 from 8 to 2
move 2 from 8 to 9
move 2 from 3 to 8
move 5 from 5 to 8
move 1 from 3 to 7
move 2 from 9 to 5
move 7 from 2 to 4
move 14 from 4 to 6
move 2 from 2 to 7
move 1 from 7 to 3
move 1 from 7 to 9
move 3 from 5 to 2
move 1 from 7 to 1
move 3 from 2 to 4
move 7 from 8 to 2
move 3 from 6 to 1
move 17 from 3 to 1
move 2 from 8 to 3
move 6 from 2 to 7
move 2 from 7 to 9
move 3 from 6 to 8
move 2 from 8 to 6
move 4 from 2 to 1
move 3 from 4 to 7
move 1 from 8 to 7
move 1 from 8 to 9
move 1 from 4 to 2
move 3 from 5 to 7
move 2 from 3 to 1
move 2 from 3 to 5
move 5 from 7 to 4
move 5 from 7 to 3
move 1 from 4 to 8
move 3 from 3 to 1
move 6 from 1 to 3
move 1 from 7 to 5
move 2 from 9 to 2
move 3 from 5 to 8
move 1 from 8 to 1
move 8 from 3 to 5
move 1 from 4 to 9
move 3 from 6 to 5
move 3 from 6 to 3
move 2 from 3 to 7
move 1 from 4 to 7
move 3 from 6 to 4
move 2 from 7 to 2
move 1 from 7 to 8
move 2 from 5 to 4
move 1 from 6 to 1
move 7 from 4 to 7
move 7 from 5 to 2
move 10 from 2 to 3
move 3 from 2 to 6
move 3 from 8 to 1
move 1 from 8 to 7
move 2 from 6 to 3
move 1 from 6 to 9
move 4 from 7 to 5
move 16 from 1 to 5
move 1 from 9 to 7
move 3 from 7 to 6
move 11 from 5 to 6
move 2 from 7 to 9
move 12 from 6 to 4
move 2 from 6 to 9
move 6 from 3 to 2
move 1 from 5 to 7
move 5 from 9 to 5
move 1 from 9 to 6
move 4 from 3 to 7
move 1 from 4 to 2
move 7 from 2 to 5
move 3 from 5 to 2
move 6 from 5 to 6
move 3 from 2 to 6
move 9 from 6 to 8
move 5 from 5 to 9
move 5 from 7 to 1
move 4 from 1 to 9
move 2 from 9 to 4
move 1 from 6 to 7
move 9 from 4 to 1
move 7 from 5 to 9
move 18 from 1 to 3
move 9 from 9 to 5
move 8 from 8 to 2
move 1 from 2 to 5
move 4 from 2 to 3
move 4 from 9 to 6
move 1 from 4 to 8
move 2 from 5 to 7
move 2 from 9 to 2
move 10 from 3 to 9
move 5 from 5 to 9
move 1 from 7 to 2
move 2 from 8 to 7
move 2 from 3 to 5
move 2 from 9 to 1
move 2 from 7 to 3
move 1 from 2 to 1
move 5 from 5 to 8
move 1 from 2 to 1
move 15 from 3 to 6
move 1 from 7 to 6
move 10 from 6 to 5
move 1 from 7 to 8
move 4 from 1 to 6
move 1 from 8 to 3
move 2 from 1 to 5
move 3 from 8 to 1
move 1 from 4 to 6
move 1 from 4 to 2
move 4 from 9 to 7
move 6 from 5 to 7
move 3 from 1 to 9
move 10 from 6 to 8
move 2 from 1 to 3
move 8 from 7 to 9
move 1 from 9 to 6
move 2 from 7 to 9
move 3 from 3 to 5
move 1 from 2 to 6
move 2 from 6 to 5
move 5 from 9 to 4
move 4 from 8 to 2
move 1 from 1 to 3
move 4 from 5 to 9
move 3 from 6 to 1
move 2 from 1 to 5
move 3 from 5 to 2
move 8 from 8 to 3
move 11 from 9 to 4
move 13 from 4 to 8
move 2 from 9 to 2
move 2 from 3 to 1
move 1 from 4 to 1
move 1 from 3 to 8
move 2 from 6 to 9
move 7 from 8 to 1
move 3 from 2 to 5
move 7 from 2 to 5
move 3 from 4 to 6
move 4 from 9 to 2
move 2 from 3 to 5
move 9 from 5 to 6
move 5 from 2 to 7
move 2 from 9 to 2
move 2 from 9 to 7
move 12 from 6 to 8
move 5 from 5 to 7
move 1 from 9 to 8
move 3 from 1 to 6
move 5 from 5 to 8
move 6 from 1 to 9
move 2 from 1 to 5
move 1 from 6 to 9
move 5 from 9 to 7
move 2 from 5 to 8
move 11 from 7 to 6
move 20 from 8 to 1
move 2 from 9 to 8
move 4 from 7 to 6
move 6 from 8 to 3
move 13 from 6 to 9
move 4 from 3 to 2
move 4 from 6 to 3
move 2 from 3 to 6
move 5 from 9 to 8
move 2 from 7 to 1
move 2 from 6 to 9
move 6 from 8 to 3
move 6 from 3 to 6
move 5 from 2 to 9
move 22 from 1 to 3
move 3 from 2 to 1
move 5 from 9 to 3
move 1 from 1 to 6
move 3 from 6 to 2
move 1 from 2 to 4
move 33 from 3 to 5
move 1 from 8 to 7

1
2022/inputs/day06 Normal file
View File

@ -0,0 +1 @@
plhlsssjsrscspsffmrffwvfvrvvmbbnjnrnrfnndlnlznlznlnccdbbhvbvgvmvzmzvmzmbbrcclsslzslzzsztzftzzhggnjgnjnhnmnqnqqfdfnnrwnwsnwwvgvqqgpptvtrvvfmmzjzmmjssmwsmmhzzvvwzwcwrcrllpbppdgdvvwqvvsnsrnsncnwntnggwqgqhqrqprqrddjvddqsqhshchfffzddswdsshhcnhnqqfjffvlvwvssdqqwrwvrvhrvrzzgwggcjcgclcwchhzvzmzrrjwjqwwvbwwrmmvmpmzpzgpgsghgrrtmmlfmmnzzmpzzvmvjjsqqshqshsqqgtqggpvvrtttwbbhnbnlbnlnhnthtjhjshhrmrjjlclpprmrnrsrwrbwrwwjnwnbwbhbmbggdbgghllcvlvddzbdbdvdwvdvjvqvcvczvcvclvvrggrngrrwcwbcczgghnhznhnttbcbvcvttrrpbrppndppvvvgvtgvvhfvhhttppjmjllznlnldnldlwlnwlnlttgzzcfcggwmgmqgmmshmhqqdfqfpfqppprzrhrnrhnrrtsrrgpgnpngnqnmmrtrvtrrfccszszffvlfvlvssvdvvpggvcvscvvpmpgpqpfqqhttrhhsbhbqhhzggzrgrqrfqffwllggrgqqjzqzzsgglvgllsgllptltblbggvrggctczzllvsvcscrrzjrzzjnnbvvtntpntnvtntcntcnnwsnnnvjnnsccsddcvvgzgwggbnbwnwbwmwttzzsgzzjpzztwztwwhhzggplgplggwwwphpmmhchsccmwmttvjtjftffzbfffjljbbqvvstsggbbqrbqrbrhbbrmbmppvrpphptpggqgddtmdtmdmbbbcdbbgssmzzthhtjjrgjrgrzzchzhttgddjnjrjmjllrcrqqsvsjjjhvvphhgjhgjhjccwmcmjcmjmhmzznmmcbcscddcsssnppsnpnmnqmmtztftqtjtqqgvgvjjfnjffqbqbfqqwfqfcfsfttvccnssjvvpfvpvttvpvccwhwfwlwlclljqqststllgqgzqqfpflpplpssnntstqqpnnsrnsrrsvrsvsrvsrrtztmtptpcpssgnnfvflffscsqszzsppfnftfptfpfnfbbwzbzfbbtggrzrnntztnznhnnlbnbrbdddjhjchhdshhnzhnnsrnrrqwrrdsdlsstdsslqsqdqvqzvqvwqqlmmwzmwzwztzlzczhqfrclvgvnlchrggsrjhntctdbpfdcffwjngdvdrjmgvwvptlvlhvhshqphmrdznqbtchcvrwfrpvwhzmrwlcjwnrsgrqcbsgpwjthstvqzlwjjmqbvhhdfdsmqnmnswmwjtpgjhdpgcnvmlcjwjzrjhmrqmqnrqrmgdnbdgznwhgzncmcbzpntcdflvrbfdzwgpnqjqmrcqpbrzwhwdgtgshhmrwvhnrwslvcswjvdgglfrdvmqdspppwmvfzvdbvpcnhmvgfqwnvjvvzrvttwvbjrbjlllmwtlcltvqmwshnqsdtjrptvqjvdjgzwgzzhcdbwjzhdgsptfrtmmqvhsnsnpgwbncbnnvwmmrrjgfccbzcpcjmqvqsbvjrstzblsrngphwndfdswjnnnfdgpcbslvbjglqqnbbtjljsmdgcslmwlvgwpsqthlmmqfgpgmcvrpvvtzcjdrwcjgrbwthblwpwpbzvjvhzsphmfhfwvsthlfnhhfcmpsnmgrvrntlzpdvqwtrghnslnfhcjwrsvrngqqtwvcsfhbjwmsnmsmgvdhnzjgljtchbtwlfppvbtdclbdjdmwzcntvgfjlcwdplnjwqnzqhnfgcnbrgftqpdmqzrrhglbzzvjcdnbtfnvmsrbjdzhbqmhnsmprgvjzzgvllhqnzgpstqzcnlgsrcwzlhwqvcjlwnnjslmdtwqcpbrntrmrmmtscjwwtzjhghtqvvpldzvhtmspzlnlfgrfhmsndbdgpgvphwwgqhrtlwztgqqsrwnrnqphqfsrtbztqbrgmfbtpjwhhrglhbzmmjptppnfdzlpb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bszvrhwsjrclcscgngwvblbbrqprgshwzhlqgwmpfsmqsvpjbdccdmtnnhqfwvlgjlszmmmdmtmpzwhplzsjztrnwngbvspqqbmghwzgvfjdrblfmtwcvnczsrflmsjmrsvzldmttjwcmnvwcbjfvznhgntnqfbfchcqqshhjldgltqhdlqldlpfjnjvtbvbntzdjzstcqbzdnmsvcdgvjmmvtdfvdplqfndqqlzlspmjgdfbgsvwzqzsvvbbldltbtzwzpqrzfmfzgdbpqnwtrfcgwmlbpzrgscbjvfdwnjzjdfzltsbppnljzrgggplmttpmgwnhdlwfhwzsrcflnrqqzwsbqllwjqlrgwbhvcvqdvjvpbzgnfbbbtccvplzggplbrsbldllwmttwtvltsfljfbbprtvlfshhwdhdgvzfzjttvnphpnjnzsbvfwflfpqwnhvwjdsrtbwsjzqhgfldnssfbbzzqqrwtjvwjschmndgqzjtpsbfhwtmqbtfstrbghgtnldjqtshdnrwzvwddchhvdbsfjnqzfjdpvhvwwjspftgbtgwzdfgzzhpvjpdlrrdfnpftshthwzjzmzdghnfdqcbmjhfdgzrcgrzbrjtmhwbjhcpgjdsmnqzncdlwhqqzqblgdbbdsmrqgbdbmdczvvpnbbjdwrlmrwgnnbbzpcnsjgcmshgzwnjzwjlrdmvmhvjrzphgpczppqvwjthcdphprhhrggjdpzmgtpjjfvpczzrvsssfrrptnzlstrhmbhvzmwjnddshrrtgspbllvqlsptrtvtldsgnjjbwtfmtbjdvmgbptjlzhpttjmvpgnjphswhtdq

1014
2022/inputs/day07 Normal file

File diff suppressed because it is too large Load Diff

99
2022/inputs/day08 Normal file
View File

@ -0,0 +1,99 @@
422411333315050450444501456006152604434030162031174034546313212413064150120521030152355534203000121
301324204451515335252342253126503010214314026675523135330307170405066545120014006214521335013332134
410011302103513543254453460342420630261341511764171765703774273674310415535166643155002215230224343
103430412453541534313620414103230457371320115213510406561165762764547335046351220043205123531400041
431144033221543442550410360065613506340166441027415155772664554705330520251311025141223233351402243
213325510034542655030015455216430162202777001070241326522045362063054665216550230550303504355415521
031003015553250105046213533102217162325175605337032637035520465564170167670025216131512201354221154
030330000340601011142444407606503050007242464673750253830211547340373634150160430415326661303301345
113235411552011354533102340044621316346565585288537455721315631122136343660406713562561324015543445
421534130161456141524700000065614361134772508484820078328071864806605600741146570103520403345131004
431241004342502250214157404224401110285530841182417600676558252223422442223365151650333543165203252
452101220316500255542412735272327722260015722028635734835275716771361655446401456052405004343011243
510255424045455150311274151010862261804521785221564236521111375341822506140673475322206046102212233
250520346622520024422030262010116484388222015082111251607306033683521336835777306621444155166611242
433206064536135011234461674868743670524642527870325812423070432203771174543614556340531611610445224
104304050515243266345751017067540578262354859268542392474984317132267883577334573566666046443043404
120366016651172515376331617627075653459978432445841625981779145828376061131304637264456350043251114
245335211105601220505753552031605587244146668517552893732622278232503141724815237352500511536112534
503260136226330722271854285880226688399827276142943371411161827875170805326646134522345504215246054
434103313404230466231011205644364118651793541288242178723975136991327713565142203452660105341534666
265003443216157541264728634538467892327437689936965182594796577713795231766328573007210200224360245
013401313366563527475143586336181641242173553831166124462364333977722825747254704732661505446014514
264400525420160443306870177033344396594417316646926939377669646938458559703035212677520172110600241
004630122623524228000154527973258366988398838593697858788987515525679258590033574627002376260641356
615050624000232108162524551784918391547943589622457235227665558596142724177061417140002420755446226
232132277261663164874453478613224434392624523238848929879932567693369681122434202850441520043105130
106600246232518043804832541367163449466666777243694336727824433593713984577357407706446256672222242
216651306035603741820376317692246562923557968749548628946329882728321739597491054131510201323271340
256453574656662727688428449553769484663479668443552259939628676786573458655844467861272411137137001
525111477730681530651181964248627565399568482937993345844562732994586938452539541370054642201502146
625201525347502735649595171573335756623388874968974895469635738296582533333754884230352250000634121
353242650575747164146962171132883683286764988545995433449686677544695263235395576447462801654256543
310070674340222278423219475579342937579576666463739678353647639733577473976444418812427631672156356
065331511311700736484493626584438539836743843577399983895986454894252453455876697427118378115704064
366342527222306426476168325353725486948395534666887383954445698463536485756315269598423836835735170
405527420251714201479366889366685398468373864896735988793799654367288298948978414820338058117203005
061665105755712245171518865522286565963535963797666689384344637587726448772824838497658476715554554
263322504423128408124286677334968674987696356948458876787477573893592447348757546417678212053633504
012514277861726424756631776535326547379449767746986568845554936444589579955272551369383423682221227
352771363437852562254483955355279899747588948784997755867544448389854595976978866519907544427237324
422600752164868649628292844685267733788995978699996898798965664966973538729967431687206051003013312
154546254656081182312989543542385638755779776594559447448584898563398557696972197457457128240310565
500601113658843326553513723924744899657465646955784747997946478949776444972939248393436074123512232
235452162613381698198419542987546946658674976458999796554587855399695356746896855265556157235772535
666443516432258968314559277555393535799749579785559869974557456768773446599637392231195015286675357
560646660026804333113549593984873843468849949768876555656996979583958374454353779291258128023046237
530530375152278819342974958844687464665868888579959657966545645465595335533559872396861673433061451
115616051148768438276132332658368743957949577969768685877555854985437975777438776848568122532654532
112107255171134197454432259325399464855586566586877879987756675586849459977899993583522656434060153
437300074171728726623629837783445555646756497759857768957589565579457675746866311515127711801336146
427010366265286521292127599927874573944645867978587889978584688873894568394592975168655421882303066
711135225265514697559568555944366875786846987856897989796865694858887457823848766747732002210717770
542252516663131832681433736589538475694497987996595875599478754659995765459783771663847561232114010
230340208177328792549235253437546666595595978995555996899667457466596866425458772811326181702200116
272253537002546476819879698767959744778864486695797968896997686564843684256648359656578627613314622
032035377567104668716548545963339678455564646558587558766546574597756986386259258689475748308362227
423010731455185114359843667596454379577948687695985696959644966943745482822357537733597106181057404
621116676437302476442563593922358956657549647574699788489958549659757356397893982677915315742124640
354460540684745138189763234487858369565978479898866479778564785687384634628655249135395838206373763
472665706485721235298236392727967666593469684666448898476577667768536599563468413441463765252125545
400202770668748585723472583577456647539988599547479769546868944889599863962845468135164478163032272
452004753172577837829367353256949837587534685969458857464549593536456492658849888579441858023544267
307106335765173231917552537579728737647845666854874676947658788448375572755878282344847802815067767
263413150215476469482888275992779656753643847986745678699939485978467265252291315413664212526203360
442165010658623652564138593356488677439474649546495945893849463876793423896332291616280811734254136
243163267244734815979238272235266336343358699584764383764334555788587498544533996110126661277746506
456445206587151712744636539564345987853479474693774987657798876459758427794187491762847882751754515
035333260418848020092279916694879377835997734973388649555776677479522886284372218804361203442367301
402150177356205134769894175656866956543698378668365888475747465977248888764471111744655651717544356
322227633321833817473851247172293667659483698864374948487588893466347842732255393233057431233226652
220401747157676706006925878573877757652645753966765345568886778333756365629751324537365002624517423
656540752501165702738885714157463925335869549476334355966745862279547391777139653630260814457002525
160456117462163286230615654246747588466544295365576266322558234756563243941616283407720171553644356
025543134750640355668573191143246992939239773874989488889633959399832617222425627172210112046361432
023032002104706510283687857142569194687449899397269946782639254496554989353957504186850423000171606
552135233535715864671035592481178399825356644833529596263624746771246595159777114384422050506066104
604326307556552675658862139498712279284288674843723595288759969437368271924672604405211233552236632
466630103722066741367586708396513964124297394949355268764349529568152598482661861510265352710655366
425632154707051726502341134661919748136447776333497274223618594858144315316430705836503516230550201
432235603225433177631012637437916321653491758784152779972624444451648117446837184766066704536365110
541460013113674546210203782035617816692666689547565947794331166255665614154155856531106034740454310
550062365064176240658150551425321429643581692595534982348894946249725043175851364606262653042666033
324552402103237344211541478210503582935957227413435671879756259591605733820138573605644501560351101
033420532136721343204327650307884736586826275376892846129897116414757745320745250602706723165626331
213112346233516037452276606556815154086426533567662746775491781024667031868741773563623612151134220
040050334232133010736112340504617420744582864572276718923868000186150482840521722314206246011056240
311211546330604022404075645423046356874374712344518216782201525854717570648366531644625644526223554
512500221202230263764023410372308234576384103268046457074782442547774240200721713524231522254025424
003135563462204130753427546654647375830727262146328777453873815516821555134530116272000232165005102
034222520650060041405115642337577245014526275226176727605026853575348603071313502632544115252552001
434001410151104023367305301162455746126381624636332837244756548257666232310714704633343515001450504
500145305234025310110425552477312712570255016022350087642563505406037213447552470361344304541112525
011311542045202624341436677760452665060105354005528300464213350624322264777473513116064444441443041
123020050334444104436635210512431667424203407162118353422573656406433137113024104455516323422200105
304032110515430043562441664751116765706554132121573167535270035465171662347354021021312030154252342
432104214000502220335210425065146005665654103051026263133225256657056240121322550016364521150122103
332404122054310030151030160563463316530321605552450671743053414206243570221133250300024131523313231
110134030400213335406643022100613224612700424360067652140374413333643266103445350022401501023352131
231424301543353234613653325560166326262063626431047044000133041410622363320013444135310231215142114

2000
2022/inputs/day09 Normal file

File diff suppressed because it is too large Load Diff

140
2022/inputs/day10 Normal file
View File

@ -0,0 +1,140 @@
noop
addx 5
noop
noop
noop
addx 1
addx 2
addx 5
addx 2
addx 5
noop
noop
noop
noop
noop
addx -12
addx 18
addx -1
noop
addx 3
addx 5
addx -5
addx 7
noop
addx -36
addx 18
addx -16
noop
noop
noop
addx 5
addx 2
addx 5
addx 2
addx 13
addx -6
addx -4
addx 5
addx 2
addx 4
addx -3
addx 2
noop
addx 3
addx 2
addx 5
addx -40
addx 25
addx -22
addx 25
addx -21
addx 5
addx 3
noop
addx 2
addx 19
addx -10
addx -4
noop
addx -4
addx 7
noop
addx 3
addx 2
addx 5
addx 2
addx -26
addx 27
addx -36
noop
noop
noop
noop
addx 4
addx 6
noop
addx 12
addx -11
addx 2
noop
noop
noop
addx 5
addx 5
addx 2
noop
noop
addx 1
addx 2
addx 5
addx 2
addx 1
noop
noop
addx -38
noop
addx 9
addx -4
noop
noop
addx 7
addx 10
addx -9
addx 2
noop
addx -9
addx 14
addx 5
addx 2
addx -24
addx 25
addx 2
addx 5
addx 2
addx -30
addx 31
addx -38
addx 7
noop
noop
noop
addx 1
addx 21
addx -16
addx 8
addx -4
addx 2
addx 3
noop
noop
addx 5
addx -2
addx 5
addx 3
addx -1
addx -1
addx 4
addx 5
addx -38
noop

55
2022/inputs/day11 Normal file
View File

@ -0,0 +1,55 @@
Monkey 0:
Starting items: 96, 60, 68, 91, 83, 57, 85
Operation: new = old * 2
Test: divisible by 17
If true: throw to monkey 2
If false: throw to monkey 5
Monkey 1:
Starting items: 75, 78, 68, 81, 73, 99
Operation: new = old + 3
Test: divisible by 13
If true: throw to monkey 7
If false: throw to monkey 4
Monkey 2:
Starting items: 69, 86, 67, 55, 96, 69, 94, 85
Operation: new = old + 6
Test: divisible by 19
If true: throw to monkey 6
If false: throw to monkey 5
Monkey 3:
Starting items: 88, 75, 74, 98, 80
Operation: new = old + 5
Test: divisible by 7
If true: throw to monkey 7
If false: throw to monkey 1
Monkey 4:
Starting items: 82
Operation: new = old + 8
Test: divisible by 11
If true: throw to monkey 0
If false: throw to monkey 2
Monkey 5:
Starting items: 72, 92, 92
Operation: new = old * 5
Test: divisible by 3
If true: throw to monkey 6
If false: throw to monkey 3
Monkey 6:
Starting items: 74, 61
Operation: new = old * old
Test: divisible by 2
If true: throw to monkey 3
If false: throw to monkey 1
Monkey 7:
Starting items: 76, 86, 83, 55
Operation: new = old + 4
Test: divisible by 5
If true: throw to monkey 4
If false: throw to monkey 0

41
2022/inputs/day12 Normal file
View File

@ -0,0 +1,41 @@
abcccaaaaacccacccccccccccccccccccccccccccccccccccccccccccccccccccccccaaaaaacaccccccaaacccccccccccccccccccccccccccccccccccaaaaaaaaccccccccccccccccccccccccccccccccaaaaaa
abcccaaaaacccaaacaaacccccccccccccccccaaccccccacccaacccccccccccaacccccaaaaaaaaaaaccaaaaaaccccccccccccccccccccccccccccccccccaaaaaccccccccccccccccccccccccccccccccccaaaaaa
abccccaaaaaccaaaaaaaccccccccccccccaaaacccccccaacaaacccccccccaaaaaacccaaaaaaaaaaaccaaaaaacccccccccccccccccccccccccccccccccccaaaaaccccccccccccccaaacccccccccccccccccaaaaa
abccccaacccccaaaaaacccccccccccccccaaaaaacccccaaaaaccccccccccaaaaaacaaaaaaaaaaaaaccaaaaaacccccccccccccccccccccccccccccccccccaacaaccccccccccccccaaaaccccccccccccccccccaaa
abccccccccccaaaaaaaacccccccccccaaccaaaaaccccccaaaaaacccccccccaaaaacaaaaaaaaccccccccaaaaacccccccccccccccccccccccccccccccccccaacccccccccccccccccaaaaccaaacccccccccccccaac
abaaaaaccccaaaaaaaaaaccccccaaccaacaaaaacccccaaaaaaaaaaacccccaaaaacaaaacaaaaacccccccaacaacccccccccccccccccccccccccccccccccccccccccccccccccccccccaaaaaaaaacccccccccccaaac
abaaaaaccccaaaaaaaaaacaacccaaaaaacaccaacccccaaaaaaaaaaacccccaaaaaccccccaaaaaccccccccccaacccccccccccccccccccccccccccccccccccccccccccccccccccccccaaaakkkllccccccccccccccc
abaaaaacccccccaaacaaaaaaccccaaaaaaaccccccaaacccaacccaaaaaaacccccccccccccaaaaacccccccccaaaaaaccccccccccccccccccccccccccaaccccccccccccccccccccccackkkkkklllccccaaaccccccc
abaaaaacccccccaaacaaaaaaacccaaaaaaaccccccaaaacaaacaaaaaaaacccccccccccccaaaaaacccccccccaaaaaaccaacaacccccccccccccccaaaaaacccccccccccccccccccaaakkkkkkkkllllcccaaacaccccc
abaaaaaccccccccaacaaaaaaaacaaaaaaccccccccaaaaaaacaaaaaaaaacccccccccccccaaaacccccccccaaaaaaacccaaaaacccccccccccccccaaaaaaccccccccccccccccjjjjjkkkkkkpppplllcccaaaaaacccc
abaaaccccccccccccccaaaaaaacaaaaaacccccccccaaaaaaccaaaaaaaccccccccccccccccaaaccccccccaaaaaaaccccaaaaacccccccccccccccaaaaaaaccccaaccccccjjjjjjjkkkkppppppplllcccaaaaacccc
abccccccccccccccccaaaaaacccccccaaccccccaaaaaaaacccccaaaaaaccccccccccccccccccccccccccccaaaaaaccaaaaaacccccccccccccccaaaaaaaaaacaacccccjjjjjjjjjkooppppppplllcccaaacccccc
abccccccccccccccccaaaaaacccccccccccccccaaaaaaaaacccaaacaaacccccccccccccccccccccccaaaccaaccaaccaaaaccccccccccccccccaaaaaaaccaaaaaccccjjjjooooooooopuuuupppllccccaaaccccc
abccccccccccccccccccccaaccccccccccccccccaaaaaaaacccaaaccaacccccccccccccccccccccccaaaaaaacccccccaaaccccccccccccccccaaaaaaccccaaaaaaccjjjoooooooooouuuuuupplllccccaaccccc
abccaaaaccccaaacccccccccccccccccccccccccccaaaaaaaccaaccccccccccccaacccccccccccccccaaaaacccaaccaaaccccccccccccccccccccaaacccaaaaaaaccjjjoootuuuuuuuuuuuuppllllccccaccccc
abccaaaaaccaaaacccccccccccccccccccccccccccaacccacccccccccccccccacaaaacccccccccccaaaaaaacccaaaaaaacccccccccccccccccccccccccaaaaaacccciijnoottuuuuuuxxyuvpqqlmmcccccccccc
abcaaaaaaccaaaacccccccaaaaccccccccccacccccaaccccaaaccccccccccccaaaaaacccccccccccaaaaaaaaccaaaaaacccccccccccccccccaacccccccaacaaacccciiinntttxxxxuxxyyvvqqqqmmmmddddcccc
abcaaaaaacccaaacccccccaaaaccccaaaaaaaaccaaaaccccaacaacccccccccccaaaaccccccccccccaaaaaaaacccaaaaaaaacccccccccccccaaaaccccccccccaacccciiinntttxxxxxxxyyvvqqqqqmmmmdddcccc
abcaaaaaacccccccccccccaaaacccccaaaaaacccaaaaaaaaaaaaacccccccccccaaaaccccccccccccccaaacacccaaaaaaaaacccccccccccccaaaacccccccccccccccciiinnnttxxxxxxxyyvvvvqqqqmmmdddcccc
abcccaaccccccccccccccccaaccccccaaaaaacccaaaaaaaaaaaaaaccccccccccaacaccccccccccccccaaaccccaaaaaaaaaacccccccccccccaaaacccccccccccccccciiinnntttxxxxxyyyyyvvvqqqqmmmdddccc
SbccccccccccccccccccccccccccccaaaaaaaaccaaaccaaaaaaaaacccccccccccccccccccccccccccccccccccaaaaaaacccccccccaacccccccccccccccccccccccccciiinntttxxxxEzyyyyyvvvqqqmmmdddccc
abcccccccccccccccccccccccccccaaaaaaaaaacccccccaaaaaacccccccccccccaaacccccaacaacccccccccccccccaaaaaaccccccaacaaacccccccccccccccccccccciiinntttxxxyyyyyyyvvvvqqqmmmdddccc
abcccccccccccccccccccccccccccaaaaaaaaaaccccccaaaaaaaaccccccccccccaaaccccccaaaacccccccccccccccaaaaaaccccccaaaaacccccccccccccccccccccciiinnnttxxyyyyyyyvvvvvqqqqmmmdddccc
abcccccccccccccccccccccccccccacacaaacccccccccaaaaaaacccccccccccaaaaaaaacccaaaaacccccccccccccccaaaaaaaacaaaaaaccccccccccccccccccccccciiinntttxxwyyyyywwvvrrrqqmmmdddcccc
abaccccccccccccccccccccccccccccccaaacccccccccaaacaaaaacccccccccaaaaaaaaccaaaaaacccccccccccccccaaaaaaaacaaaaaaacccccccccccccccccccccchhnnnttwwwwwwwyyywvrrrrnnnnmdddcccc
abaccccccccccccccccccccccccccccccaaccccccccccccccaaaaaacccccccccaaaaaccccaaaacaccccccccccccccccaaaaacccccaaaaaaccccccaaaccccccaaaccchhnmmttswwwwwwywwwrrrrnnnnneeeccccc
abaccccccccccccccccccccccccccccccccccccccccccccccaaaaaacccccaaccaaaaaacccccaaccccccccccccccccccaaaaaaccccaaccaaccccaaaaaacccccaaacahhhmmmsssssssswwwwwrrrnnnneeeecccccc
abaaaccccccccccccccccccccccccccccaaaccccccccccccccaaaaaccccaaaccaaaaaacccccccccccccccccccccccccaaaaaaccccaaccccccccaaaaaacccaaaaaaahhhmmmmsssssssswwwwrrnnnneeeeacccccc
abaaaccccccccccccccccccccccccccccaaaaaaccccccccccaaaaacaaaaaaaccaaaccaccccccccaaaaaccccccccccccaaaacacccccccccccccccaaaaacccaaaaaaahhhhmmmmssssssswwwwrrnnneeeeaacccccc
abaaacccccccccccccccccccccccccccaaaaaaaccccccccccaaaaacaaaaaaaaaacccaaaaacccccaaaaacccccccccacaaaaaccacccccccccccccaaaaacccccaaaaaachhhmmmmmmmmmsssrrrrrnnneeeaaaaacccc
abaccccccccccccccaaaaccccccccccaaaaaaaacccccccccccccccccaaaaaaaaacccaaaaaccccaaaaaacccccccccaaaaaaaaaacccccccccccccaaaaaccccccaaaaachhhhmmmmmmmooossrrronneeeaaaaaacccc
abaccccccccccccccaaaaccccccccccaaaaaaacccccccccccccccccccaaaaaaaccccaaaaaacccaaaaaaccccaaaccaaaaaaaaaacccccccccccaaccccccccccaaaaaacchhhhhggggooooorrroonnfeeaaaaaccccc
abcccccccccccccccaaaaccccccccccccaaaaaacccccccccccccccccaaaaaaccccccaaaaaacccaaaaaaccccaaaaaacaaaaaacccccccccaaccaacccccccccccaacccccchhhhggggggoooooooooffeaaaaacccccc
abccccccccccccccccaacccccccccccccaaaaaacccccccaaccacccccaaaaaaacccccaaaaaaccccaaaccccccaaaaaacaaaaaacccccccccaaaaacccccccccccccccccccccccgggggggggooooooffffaaaaaaccccc
abccccccccccccccccccccccccccaaaccaacccccccccccaaaaacccccaaccaaacccccccaaacccccccccccccaaaaaaacaaaaaacccccccccaaaaaaaaccccccccccccccccccccccaaaggggfooooffffccccaacccccc
abaaccccccccccccccccccccccccaaacaccccccccccccaaaaacccccccccccaacccccccaaaacccaacccccccaaaaaaaaaaaaaaaccccccccccaaaaacccccccccccccaaaccccccccccccggfffffffffcccccccccccc
abaaccccccccccccccccccccccaacaaaaacccccccccccaaaaaacccccccccccccccccccaaaacaaaacccccccaaaaaaaaaccccaccccccccccaaaaaccccccccccccccaaaccccccccccccagfffffffccccccccccccca
abaacccccccaacccccccccccccaaaaaaaaccccccaacccccaaaacccccccccccccccccccaaaaaaaaacccccccccaaacaacaaacccccccccccaaacaaccccaaccaaccaaaaaaaaccccccccaaaccffffcccccccccccccaa
abaaaaaaaccaaccccccccccccccaaaaacccccccaaaacccaaccccccccccccccccccacaaaaaaaaaaccccccccccaaacaaaaaacccccccccccccccaaccccaaaaaaccaaaaaaaacccccccccaacccccccccccccccaaacaa
abaaaaaaaaaaccccccccccccccccaaaaaccccccaaaacccccccccccccccccccccccaaaaaaaaaaaaccccccccccccccaaaaaacccccccccccccccccccccaaaaaacccaaaaaacccccccccaaacccccccccccccccaaaaaa
abaaaacaaaaaaaacccccccccccccaacaaccccccaaaaccccccccccccccccccccccccaaaaaaaaaaacccccccccccccaaaaaaaacccccccccccccccccccaaaaaaaaccaaaaaaccccccccccccccccccccccccccccaaaaa

138
2022/inputs/day14 Normal file
View File

@ -0,0 +1,138 @@
508,146 -> 513,146
514,142 -> 519,142
483,88 -> 487,88
522,146 -> 527,146
492,90 -> 496,90
525,161 -> 525,156 -> 525,161 -> 527,161 -> 527,156 -> 527,161 -> 529,161 -> 529,154 -> 529,161 -> 531,161 -> 531,154 -> 531,161 -> 533,161 -> 533,157 -> 533,161 -> 535,161 -> 535,152 -> 535,161 -> 537,161 -> 537,160 -> 537,161
508,93 -> 508,97 -> 507,97 -> 507,101 -> 517,101 -> 517,97 -> 510,97 -> 510,93
525,161 -> 525,156 -> 525,161 -> 527,161 -> 527,156 -> 527,161 -> 529,161 -> 529,154 -> 529,161 -> 531,161 -> 531,154 -> 531,161 -> 533,161 -> 533,157 -> 533,161 -> 535,161 -> 535,152 -> 535,161 -> 537,161 -> 537,160 -> 537,161
486,86 -> 490,86
489,84 -> 493,84
507,79 -> 511,79
486,90 -> 490,90
497,23 -> 497,15 -> 497,23 -> 499,23 -> 499,21 -> 499,23 -> 501,23 -> 501,15 -> 501,23
494,26 -> 494,27 -> 505,27
485,113 -> 489,113
525,161 -> 525,156 -> 525,161 -> 527,161 -> 527,156 -> 527,161 -> 529,161 -> 529,154 -> 529,161 -> 531,161 -> 531,154 -> 531,161 -> 533,161 -> 533,157 -> 533,161 -> 535,161 -> 535,152 -> 535,161 -> 537,161 -> 537,160 -> 537,161
507,67 -> 507,63 -> 507,67 -> 509,67 -> 509,61 -> 509,67 -> 511,67 -> 511,66 -> 511,67 -> 513,67 -> 513,60 -> 513,67 -> 515,67 -> 515,62 -> 515,67 -> 517,67 -> 517,62 -> 517,67 -> 519,67 -> 519,59 -> 519,67
517,116 -> 517,119 -> 516,119 -> 516,126 -> 527,126 -> 527,119 -> 520,119 -> 520,116
517,116 -> 517,119 -> 516,119 -> 516,126 -> 527,126 -> 527,119 -> 520,119 -> 520,116
515,53 -> 515,54 -> 524,54
498,76 -> 502,76
515,53 -> 515,54 -> 524,54
512,139 -> 512,132 -> 512,139 -> 514,139 -> 514,136 -> 514,139 -> 516,139 -> 516,135 -> 516,139
525,161 -> 525,156 -> 525,161 -> 527,161 -> 527,156 -> 527,161 -> 529,161 -> 529,154 -> 529,161 -> 531,161 -> 531,154 -> 531,161 -> 533,161 -> 533,157 -> 533,161 -> 535,161 -> 535,152 -> 535,161 -> 537,161 -> 537,160 -> 537,161
508,93 -> 508,97 -> 507,97 -> 507,101 -> 517,101 -> 517,97 -> 510,97 -> 510,93
497,23 -> 497,15 -> 497,23 -> 499,23 -> 499,21 -> 499,23 -> 501,23 -> 501,15 -> 501,23
495,88 -> 499,88
511,43 -> 511,46 -> 510,46 -> 510,50 -> 516,50 -> 516,46 -> 515,46 -> 515,43
497,103 -> 497,104 -> 513,104 -> 513,103
505,31 -> 513,31 -> 513,30
507,67 -> 507,63 -> 507,67 -> 509,67 -> 509,61 -> 509,67 -> 511,67 -> 511,66 -> 511,67 -> 513,67 -> 513,60 -> 513,67 -> 515,67 -> 515,62 -> 515,67 -> 517,67 -> 517,62 -> 517,67 -> 519,67 -> 519,59 -> 519,67
497,109 -> 501,109
507,67 -> 507,63 -> 507,67 -> 509,67 -> 509,61 -> 509,67 -> 511,67 -> 511,66 -> 511,67 -> 513,67 -> 513,60 -> 513,67 -> 515,67 -> 515,62 -> 515,67 -> 517,67 -> 517,62 -> 517,67 -> 519,67 -> 519,59 -> 519,67
511,43 -> 511,46 -> 510,46 -> 510,50 -> 516,50 -> 516,46 -> 515,46 -> 515,43
501,79 -> 505,79
497,23 -> 497,15 -> 497,23 -> 499,23 -> 499,21 -> 499,23 -> 501,23 -> 501,15 -> 501,23
503,34 -> 503,37 -> 495,37 -> 495,40 -> 512,40 -> 512,37 -> 505,37 -> 505,34
510,76 -> 514,76
525,161 -> 525,156 -> 525,161 -> 527,161 -> 527,156 -> 527,161 -> 529,161 -> 529,154 -> 529,161 -> 531,161 -> 531,154 -> 531,161 -> 533,161 -> 533,157 -> 533,161 -> 535,161 -> 535,152 -> 535,161 -> 537,161 -> 537,160 -> 537,161
525,161 -> 525,156 -> 525,161 -> 527,161 -> 527,156 -> 527,161 -> 529,161 -> 529,154 -> 529,161 -> 531,161 -> 531,154 -> 531,161 -> 533,161 -> 533,157 -> 533,161 -> 535,161 -> 535,152 -> 535,161 -> 537,161 -> 537,160 -> 537,161
525,161 -> 525,156 -> 525,161 -> 527,161 -> 527,156 -> 527,161 -> 529,161 -> 529,154 -> 529,161 -> 531,161 -> 531,154 -> 531,161 -> 533,161 -> 533,157 -> 533,161 -> 535,161 -> 535,152 -> 535,161 -> 537,161 -> 537,160 -> 537,161
512,139 -> 512,132 -> 512,139 -> 514,139 -> 514,136 -> 514,139 -> 516,139 -> 516,135 -> 516,139
525,161 -> 525,156 -> 525,161 -> 527,161 -> 527,156 -> 527,161 -> 529,161 -> 529,154 -> 529,161 -> 531,161 -> 531,154 -> 531,161 -> 533,161 -> 533,157 -> 533,161 -> 535,161 -> 535,152 -> 535,161 -> 537,161 -> 537,160 -> 537,161
517,116 -> 517,119 -> 516,119 -> 516,126 -> 527,126 -> 527,119 -> 520,119 -> 520,116
507,67 -> 507,63 -> 507,67 -> 509,67 -> 509,61 -> 509,67 -> 511,67 -> 511,66 -> 511,67 -> 513,67 -> 513,60 -> 513,67 -> 515,67 -> 515,62 -> 515,67 -> 517,67 -> 517,62 -> 517,67 -> 519,67 -> 519,59 -> 519,67
525,161 -> 525,156 -> 525,161 -> 527,161 -> 527,156 -> 527,161 -> 529,161 -> 529,154 -> 529,161 -> 531,161 -> 531,154 -> 531,161 -> 533,161 -> 533,157 -> 533,161 -> 535,161 -> 535,152 -> 535,161 -> 537,161 -> 537,160 -> 537,161
525,161 -> 525,156 -> 525,161 -> 527,161 -> 527,156 -> 527,161 -> 529,161 -> 529,154 -> 529,161 -> 531,161 -> 531,154 -> 531,161 -> 533,161 -> 533,157 -> 533,161 -> 535,161 -> 535,152 -> 535,161 -> 537,161 -> 537,160 -> 537,161
513,79 -> 517,79
507,67 -> 507,63 -> 507,67 -> 509,67 -> 509,61 -> 509,67 -> 511,67 -> 511,66 -> 511,67 -> 513,67 -> 513,60 -> 513,67 -> 515,67 -> 515,62 -> 515,67 -> 517,67 -> 517,62 -> 517,67 -> 519,67 -> 519,59 -> 519,67
512,139 -> 512,132 -> 512,139 -> 514,139 -> 514,136 -> 514,139 -> 516,139 -> 516,135 -> 516,139
507,67 -> 507,63 -> 507,67 -> 509,67 -> 509,61 -> 509,67 -> 511,67 -> 511,66 -> 511,67 -> 513,67 -> 513,60 -> 513,67 -> 515,67 -> 515,62 -> 515,67 -> 517,67 -> 517,62 -> 517,67 -> 519,67 -> 519,59 -> 519,67
511,43 -> 511,46 -> 510,46 -> 510,50 -> 516,50 -> 516,46 -> 515,46 -> 515,43
491,109 -> 495,109
525,161 -> 525,156 -> 525,161 -> 527,161 -> 527,156 -> 527,161 -> 529,161 -> 529,154 -> 529,161 -> 531,161 -> 531,154 -> 531,161 -> 533,161 -> 533,157 -> 533,161 -> 535,161 -> 535,152 -> 535,161 -> 537,161 -> 537,160 -> 537,161
511,43 -> 511,46 -> 510,46 -> 510,50 -> 516,50 -> 516,46 -> 515,46 -> 515,43
507,67 -> 507,63 -> 507,67 -> 509,67 -> 509,61 -> 509,67 -> 511,67 -> 511,66 -> 511,67 -> 513,67 -> 513,60 -> 513,67 -> 515,67 -> 515,62 -> 515,67 -> 517,67 -> 517,62 -> 517,67 -> 519,67 -> 519,59 -> 519,67
497,23 -> 497,15 -> 497,23 -> 499,23 -> 499,21 -> 499,23 -> 501,23 -> 501,15 -> 501,23
525,161 -> 525,156 -> 525,161 -> 527,161 -> 527,156 -> 527,161 -> 529,161 -> 529,154 -> 529,161 -> 531,161 -> 531,154 -> 531,161 -> 533,161 -> 533,157 -> 533,161 -> 535,161 -> 535,152 -> 535,161 -> 537,161 -> 537,160 -> 537,161
512,139 -> 512,132 -> 512,139 -> 514,139 -> 514,136 -> 514,139 -> 516,139 -> 516,135 -> 516,139
512,139 -> 512,132 -> 512,139 -> 514,139 -> 514,136 -> 514,139 -> 516,139 -> 516,135 -> 516,139
492,82 -> 496,82
515,146 -> 520,146
498,90 -> 502,90
517,116 -> 517,119 -> 516,119 -> 516,126 -> 527,126 -> 527,119 -> 520,119 -> 520,116
512,139 -> 512,132 -> 512,139 -> 514,139 -> 514,136 -> 514,139 -> 516,139 -> 516,135 -> 516,139
498,86 -> 502,86
491,113 -> 495,113
512,148 -> 517,148
511,144 -> 516,144
507,67 -> 507,63 -> 507,67 -> 509,67 -> 509,61 -> 509,67 -> 511,67 -> 511,66 -> 511,67 -> 513,67 -> 513,60 -> 513,67 -> 515,67 -> 515,62 -> 515,67 -> 517,67 -> 517,62 -> 517,67 -> 519,67 -> 519,59 -> 519,67
507,67 -> 507,63 -> 507,67 -> 509,67 -> 509,61 -> 509,67 -> 511,67 -> 511,66 -> 511,67 -> 513,67 -> 513,60 -> 513,67 -> 515,67 -> 515,62 -> 515,67 -> 517,67 -> 517,62 -> 517,67 -> 519,67 -> 519,59 -> 519,67
503,34 -> 503,37 -> 495,37 -> 495,40 -> 512,40 -> 512,37 -> 505,37 -> 505,34
508,93 -> 508,97 -> 507,97 -> 507,101 -> 517,101 -> 517,97 -> 510,97 -> 510,93
512,139 -> 512,132 -> 512,139 -> 514,139 -> 514,136 -> 514,139 -> 516,139 -> 516,135 -> 516,139
503,113 -> 507,113
503,34 -> 503,37 -> 495,37 -> 495,40 -> 512,40 -> 512,37 -> 505,37 -> 505,34
525,161 -> 525,156 -> 525,161 -> 527,161 -> 527,156 -> 527,161 -> 529,161 -> 529,154 -> 529,161 -> 531,161 -> 531,154 -> 531,161 -> 533,161 -> 533,157 -> 533,161 -> 535,161 -> 535,152 -> 535,161 -> 537,161 -> 537,160 -> 537,161
497,23 -> 497,15 -> 497,23 -> 499,23 -> 499,21 -> 499,23 -> 501,23 -> 501,15 -> 501,23
503,34 -> 503,37 -> 495,37 -> 495,40 -> 512,40 -> 512,37 -> 505,37 -> 505,34
497,23 -> 497,15 -> 497,23 -> 499,23 -> 499,21 -> 499,23 -> 501,23 -> 501,15 -> 501,23
505,148 -> 510,148
525,161 -> 525,156 -> 525,161 -> 527,161 -> 527,156 -> 527,161 -> 529,161 -> 529,154 -> 529,161 -> 531,161 -> 531,154 -> 531,161 -> 533,161 -> 533,157 -> 533,161 -> 535,161 -> 535,152 -> 535,161 -> 537,161 -> 537,160 -> 537,161
507,67 -> 507,63 -> 507,67 -> 509,67 -> 509,61 -> 509,67 -> 511,67 -> 511,66 -> 511,67 -> 513,67 -> 513,60 -> 513,67 -> 515,67 -> 515,62 -> 515,67 -> 517,67 -> 517,62 -> 517,67 -> 519,67 -> 519,59 -> 519,67
501,88 -> 505,88
504,70 -> 508,70
508,93 -> 508,97 -> 507,97 -> 507,101 -> 517,101 -> 517,97 -> 510,97 -> 510,93
507,67 -> 507,63 -> 507,67 -> 509,67 -> 509,61 -> 509,67 -> 511,67 -> 511,66 -> 511,67 -> 513,67 -> 513,60 -> 513,67 -> 515,67 -> 515,62 -> 515,67 -> 517,67 -> 517,62 -> 517,67 -> 519,67 -> 519,59 -> 519,67
489,88 -> 493,88
517,116 -> 517,119 -> 516,119 -> 516,126 -> 527,126 -> 527,119 -> 520,119 -> 520,116
507,67 -> 507,63 -> 507,67 -> 509,67 -> 509,61 -> 509,67 -> 511,67 -> 511,66 -> 511,67 -> 513,67 -> 513,60 -> 513,67 -> 515,67 -> 515,62 -> 515,67 -> 517,67 -> 517,62 -> 517,67 -> 519,67 -> 519,59 -> 519,67
508,93 -> 508,97 -> 507,97 -> 507,101 -> 517,101 -> 517,97 -> 510,97 -> 510,93
494,107 -> 498,107
497,23 -> 497,15 -> 497,23 -> 499,23 -> 499,21 -> 499,23 -> 501,23 -> 501,15 -> 501,23
495,79 -> 499,79
517,116 -> 517,119 -> 516,119 -> 516,126 -> 527,126 -> 527,119 -> 520,119 -> 520,116
501,73 -> 505,73
503,34 -> 503,37 -> 495,37 -> 495,40 -> 512,40 -> 512,37 -> 505,37 -> 505,34
494,111 -> 498,111
508,93 -> 508,97 -> 507,97 -> 507,101 -> 517,101 -> 517,97 -> 510,97 -> 510,93
507,67 -> 507,63 -> 507,67 -> 509,67 -> 509,61 -> 509,67 -> 511,67 -> 511,66 -> 511,67 -> 513,67 -> 513,60 -> 513,67 -> 515,67 -> 515,62 -> 515,67 -> 517,67 -> 517,62 -> 517,67 -> 519,67 -> 519,59 -> 519,67
497,113 -> 501,113
511,43 -> 511,46 -> 510,46 -> 510,50 -> 516,50 -> 516,46 -> 515,46 -> 515,43
507,67 -> 507,63 -> 507,67 -> 509,67 -> 509,61 -> 509,67 -> 511,67 -> 511,66 -> 511,67 -> 513,67 -> 513,60 -> 513,67 -> 515,67 -> 515,62 -> 515,67 -> 517,67 -> 517,62 -> 517,67 -> 519,67 -> 519,59 -> 519,67
507,67 -> 507,63 -> 507,67 -> 509,67 -> 509,61 -> 509,67 -> 511,67 -> 511,66 -> 511,67 -> 513,67 -> 513,60 -> 513,67 -> 515,67 -> 515,62 -> 515,67 -> 517,67 -> 517,62 -> 517,67 -> 519,67 -> 519,59 -> 519,67
507,73 -> 511,73
525,161 -> 525,156 -> 525,161 -> 527,161 -> 527,156 -> 527,161 -> 529,161 -> 529,154 -> 529,161 -> 531,161 -> 531,154 -> 531,161 -> 533,161 -> 533,157 -> 533,161 -> 535,161 -> 535,152 -> 535,161 -> 537,161 -> 537,160 -> 537,161
503,34 -> 503,37 -> 495,37 -> 495,40 -> 512,40 -> 512,37 -> 505,37 -> 505,34
526,148 -> 531,148
507,67 -> 507,63 -> 507,67 -> 509,67 -> 509,61 -> 509,67 -> 511,67 -> 511,66 -> 511,67 -> 513,67 -> 513,60 -> 513,67 -> 515,67 -> 515,62 -> 515,67 -> 517,67 -> 517,62 -> 517,67 -> 519,67 -> 519,59 -> 519,67
488,111 -> 492,111
508,93 -> 508,97 -> 507,97 -> 507,101 -> 517,101 -> 517,97 -> 510,97 -> 510,93
497,103 -> 497,104 -> 513,104 -> 513,103
497,103 -> 497,104 -> 513,104 -> 513,103
497,23 -> 497,15 -> 497,23 -> 499,23 -> 499,21 -> 499,23 -> 501,23 -> 501,15 -> 501,23
519,148 -> 524,148
505,31 -> 513,31 -> 513,30
495,84 -> 499,84
480,90 -> 484,90
525,161 -> 525,156 -> 525,161 -> 527,161 -> 527,156 -> 527,161 -> 529,161 -> 529,154 -> 529,161 -> 531,161 -> 531,154 -> 531,161 -> 533,161 -> 533,157 -> 533,161 -> 535,161 -> 535,152 -> 535,161 -> 537,161 -> 537,160 -> 537,161
518,144 -> 523,144
525,161 -> 525,156 -> 525,161 -> 527,161 -> 527,156 -> 527,161 -> 529,161 -> 529,154 -> 529,161 -> 531,161 -> 531,154 -> 531,161 -> 533,161 -> 533,157 -> 533,161 -> 535,161 -> 535,152 -> 535,161 -> 537,161 -> 537,160 -> 537,161
494,26 -> 494,27 -> 505,27
503,34 -> 503,37 -> 495,37 -> 495,40 -> 512,40 -> 512,37 -> 505,37 -> 505,34
500,111 -> 504,111
504,76 -> 508,76
517,116 -> 517,119 -> 516,119 -> 516,126 -> 527,126 -> 527,119 -> 520,119 -> 520,116
512,139 -> 512,132 -> 512,139 -> 514,139 -> 514,136 -> 514,139 -> 516,139 -> 516,135 -> 516,139
507,67 -> 507,63 -> 507,67 -> 509,67 -> 509,61 -> 509,67 -> 511,67 -> 511,66 -> 511,67 -> 513,67 -> 513,60 -> 513,67 -> 515,67 -> 515,62 -> 515,67 -> 517,67 -> 517,62 -> 517,67 -> 519,67 -> 519,59 -> 519,67
504,90 -> 508,90
511,43 -> 511,46 -> 510,46 -> 510,50 -> 516,50 -> 516,46 -> 515,46 -> 515,43
511,43 -> 511,46 -> 510,46 -> 510,50 -> 516,50 -> 516,46 -> 515,46 -> 515,43
525,161 -> 525,156 -> 525,161 -> 527,161 -> 527,156 -> 527,161 -> 529,161 -> 529,154 -> 529,161 -> 531,161 -> 531,154 -> 531,161 -> 533,161 -> 533,157 -> 533,161 -> 535,161 -> 535,152 -> 535,161 -> 537,161 -> 537,160 -> 537,161
525,161 -> 525,156 -> 525,161 -> 527,161 -> 527,156 -> 527,161 -> 529,161 -> 529,154 -> 529,161 -> 531,161 -> 531,154 -> 531,161 -> 533,161 -> 533,157 -> 533,161 -> 535,161 -> 535,152 -> 535,161 -> 537,161 -> 537,160 -> 537,161
507,67 -> 507,63 -> 507,67 -> 509,67 -> 509,61 -> 509,67 -> 511,67 -> 511,66 -> 511,67 -> 513,67 -> 513,60 -> 513,67 -> 515,67 -> 515,62 -> 515,67 -> 517,67 -> 517,62 -> 517,67 -> 519,67 -> 519,59 -> 519,67
507,67 -> 507,63 -> 507,67 -> 509,67 -> 509,61 -> 509,67 -> 511,67 -> 511,66 -> 511,67 -> 513,67 -> 513,60 -> 513,67 -> 515,67 -> 515,62 -> 515,67 -> 517,67 -> 517,62 -> 517,67 -> 519,67 -> 519,59 -> 519,67
507,67 -> 507,63 -> 507,67 -> 509,67 -> 509,61 -> 509,67 -> 511,67 -> 511,66 -> 511,67 -> 513,67 -> 513,60 -> 513,67 -> 515,67 -> 515,62 -> 515,67 -> 517,67 -> 517,62 -> 517,67 -> 519,67 -> 519,59 -> 519,67
525,161 -> 525,156 -> 525,161 -> 527,161 -> 527,156 -> 527,161 -> 529,161 -> 529,154 -> 529,161 -> 531,161 -> 531,154 -> 531,161 -> 533,161 -> 533,157 -> 533,161 -> 535,161 -> 535,152 -> 535,161 -> 537,161 -> 537,160 -> 537,161
492,86 -> 496,86

25
2022/inputs/day15 Normal file
View File

@ -0,0 +1,25 @@
Sensor at x=3729579, y=1453415: closest beacon is at x=4078883, y=2522671
Sensor at x=3662668, y=2749205: closest beacon is at x=4078883, y=2522671
Sensor at x=257356, y=175834: closest beacon is at x=1207332, y=429175
Sensor at x=2502777, y=3970934: closest beacon is at x=3102959, y=3443573
Sensor at x=24076, y=2510696: closest beacon is at x=274522, y=2000000
Sensor at x=3163363, y=3448163: closest beacon is at x=3102959, y=3443573
Sensor at x=1011369, y=447686: closest beacon is at x=1207332, y=429175
Sensor at x=3954188, y=3117617: closest beacon is at x=4078883, y=2522671
Sensor at x=3480746, y=3150039: closest beacon is at x=3301559, y=3383795
Sensor at x=2999116, y=3137910: closest beacon is at x=3102959, y=3443573
Sensor at x=3546198, y=462510: closest beacon is at x=3283798, y=-405749
Sensor at x=650838, y=1255586: closest beacon is at x=274522, y=2000000
Sensor at x=3231242, y=3342921: closest beacon is at x=3301559, y=3383795
Sensor at x=1337998, y=31701: closest beacon is at x=1207332, y=429175
Sensor at x=1184009, y=3259703: closest beacon is at x=2677313, y=2951659
Sensor at x=212559, y=1737114: closest beacon is at x=274522, y=2000000
Sensor at x=161020, y=2251470: closest beacon is at x=274522, y=2000000
Sensor at x=3744187, y=3722432: closest beacon is at x=3301559, y=3383795
Sensor at x=2318112, y=2254019: closest beacon is at x=2677313, y=2951659
Sensor at x=2554810, y=56579: closest beacon is at x=3283798, y=-405749
Sensor at x=1240184, y=897870: closest beacon is at x=1207332, y=429175
Sensor at x=2971747, y=2662873: closest beacon is at x=2677313, y=2951659
Sensor at x=3213584, y=3463821: closest beacon is at x=3102959, y=3443573
Sensor at x=37652, y=3969055: closest beacon is at x=-615866, y=3091738
Sensor at x=1804153, y=1170987: closest beacon is at x=1207332, y=429175

30
2022/inputs/day19 Normal file
View File

@ -0,0 +1,30 @@
Blueprint 1: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 14 clay. Each geode robot costs 2 ore and 16 obsidian.
Blueprint 2: Each ore robot costs 2 ore. Each clay robot costs 2 ore. Each obsidian robot costs 2 ore and 15 clay. Each geode robot costs 2 ore and 7 obsidian.
Blueprint 3: Each ore robot costs 4 ore. Each clay robot costs 3 ore. Each obsidian robot costs 2 ore and 14 clay. Each geode robot costs 2 ore and 7 obsidian.
Blueprint 4: Each ore robot costs 4 ore. Each clay robot costs 3 ore. Each obsidian robot costs 2 ore and 17 clay. Each geode robot costs 3 ore and 16 obsidian.
Blueprint 5: Each ore robot costs 2 ore. Each clay robot costs 2 ore. Each obsidian robot costs 2 ore and 17 clay. Each geode robot costs 2 ore and 10 obsidian.
Blueprint 6: Each ore robot costs 3 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 17 clay. Each geode robot costs 4 ore and 8 obsidian.
Blueprint 7: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 9 clay. Each geode robot costs 2 ore and 20 obsidian.
Blueprint 8: Each ore robot costs 3 ore. Each clay robot costs 4 ore. Each obsidian robot costs 3 ore and 20 clay. Each geode robot costs 3 ore and 14 obsidian.
Blueprint 9: Each ore robot costs 3 ore. Each clay robot costs 3 ore. Each obsidian robot costs 2 ore and 20 clay. Each geode robot costs 3 ore and 18 obsidian.
Blueprint 10: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 2 ore and 16 clay. Each geode robot costs 4 ore and 16 obsidian.
Blueprint 11: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 5 clay. Each geode robot costs 3 ore and 15 obsidian.
Blueprint 12: Each ore robot costs 2 ore. Each clay robot costs 3 ore. Each obsidian robot costs 2 ore and 14 clay. Each geode robot costs 3 ore and 8 obsidian.
Blueprint 13: Each ore robot costs 2 ore. Each clay robot costs 4 ore. Each obsidian robot costs 2 ore and 20 clay. Each geode robot costs 2 ore and 17 obsidian.
Blueprint 14: Each ore robot costs 4 ore. Each clay robot costs 3 ore. Each obsidian robot costs 2 ore and 19 clay. Each geode robot costs 3 ore and 10 obsidian.
Blueprint 15: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 17 clay. Each geode robot costs 4 ore and 20 obsidian.
Blueprint 16: Each ore robot costs 2 ore. Each clay robot costs 3 ore. Each obsidian robot costs 2 ore and 14 clay. Each geode robot costs 3 ore and 20 obsidian.
Blueprint 17: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 2 ore and 12 clay. Each geode robot costs 3 ore and 15 obsidian.
Blueprint 18: Each ore robot costs 4 ore. Each clay robot costs 3 ore. Each obsidian robot costs 2 ore and 19 clay. Each geode robot costs 3 ore and 13 obsidian.
Blueprint 19: Each ore robot costs 2 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 18 clay. Each geode robot costs 2 ore and 19 obsidian.
Blueprint 20: Each ore robot costs 2 ore. Each clay robot costs 4 ore. Each obsidian robot costs 2 ore and 16 clay. Each geode robot costs 2 ore and 9 obsidian.
Blueprint 21: Each ore robot costs 3 ore. Each clay robot costs 3 ore. Each obsidian robot costs 2 ore and 20 clay. Each geode robot costs 2 ore and 20 obsidian.
Blueprint 22: Each ore robot costs 3 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 6 clay. Each geode robot costs 2 ore and 16 obsidian.
Blueprint 23: Each ore robot costs 3 ore. Each clay robot costs 4 ore. Each obsidian robot costs 3 ore and 6 clay. Each geode robot costs 4 ore and 11 obsidian.
Blueprint 24: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 5 clay. Each geode robot costs 2 ore and 10 obsidian.
Blueprint 25: Each ore robot costs 3 ore. Each clay robot costs 4 ore. Each obsidian robot costs 2 ore and 14 clay. Each geode robot costs 3 ore and 14 obsidian.
Blueprint 26: Each ore robot costs 3 ore. Each clay robot costs 4 ore. Each obsidian robot costs 3 ore and 15 clay. Each geode robot costs 4 ore and 16 obsidian.
Blueprint 27: Each ore robot costs 4 ore. Each clay robot costs 3 ore. Each obsidian robot costs 4 ore and 18 clay. Each geode robot costs 4 ore and 11 obsidian.
Blueprint 28: Each ore robot costs 4 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 14 clay. Each geode robot costs 4 ore and 17 obsidian.
Blueprint 29: Each ore robot costs 2 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 11 clay. Each geode robot costs 3 ore and 14 obsidian.
Blueprint 30: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 8 clay. Each geode robot costs 4 ore and 14 obsidian.

5000
2022/inputs/day20 Normal file

File diff suppressed because it is too large Load Diff

1901
2022/inputs/day21 Normal file

File diff suppressed because it is too large Load Diff

202
2022/inputs/day22 Normal file

File diff suppressed because one or more lines are too long

7
2022/rustfmt.toml Normal file
View File

@ -0,0 +1,7 @@
newline_style = "Unix"
max_width = 140
imports_granularity = "Crate"
struct_field_align_threshold = 25
where_single_line = true
edition = "2021"
use_small_heuristics = "Max"

34
2022/setup_day.sh Executable file
View File

@ -0,0 +1,34 @@
#!/bin/sh
today=$(date +%d)
aocd > inputs/day$today
echo '#![feature(test)]
extern crate test;
use aoc2022::{boilerplate, common::*};
const DAY: usize = '$today';
type Parsed = Vec<usize>;
fn parse_input(raw: &str) -> Parsed {
parse_nums(raw)
}
fn part1(parsed: &Parsed) -> usize {
unimplemented!()
}
fn part2(parsed: &Parsed) -> usize {
unimplemented!()
}
boilerplate! {
TEST_INPUT == "",
tests: {
part1: { TEST_INPUT => 0 },
part2: { TEST_INPUT => 0 },
},
bench1 == 0,
bench2 == 0,
bench_parse: Vec::len => 0,
}' > src/bin/day$today.rs

45
2022/src/bin/day01.rs Normal file
View File

@ -0,0 +1,45 @@
#![feature(binary_heap_into_iter_sorted, test)]
extern crate test;
use std::collections::BinaryHeap;
use aoc2022::{boilerplate, common::*};
const DAY: usize = 1;
type Parsed = BinaryHeap<usize>;
fn parse_input(raw: &str) -> Parsed {
raw.split("\n\n").map(|elf| elf.lines().map(parse_num::<usize>).sum()).collect()
}
fn part1(parsed: &Parsed) -> usize {
*parsed.peek().unwrap()
}
fn part2(parsed: &Parsed) -> usize {
parsed.clone().into_iter_sorted().take(3).sum()
}
boilerplate! {
TEST_INPUT == "\
1000
2000
3000
4000
5000
6000
7000
8000
9000
10000",
tests: {
part1: { TEST_INPUT => 24000 },
part2: { TEST_INPUT => 45000 },
},
bench1 == 72017,
bench2 == 212520,
bench_parse: BinaryHeap::len => 242,
}

56
2022/src/bin/day02.rs Normal file
View File

@ -0,0 +1,56 @@
#![feature(iter_array_chunks, test)]
extern crate test;
use aoc2022::{boilerplate, common::*};
const DAY: usize = 2;
fn round([other, _, own, _]: [u8; 4]) -> usize {
(match other.wrapping_sub(own - b'X' + b'A') {
0 => 3 + own - b'W',
1 | 254 => own - b'W',
_ => 6 + own - b'W',
}) as usize
}
fn round_p2([other, _, own, _]: [u8; 4]) -> usize {
(match (own, other) {
(b'Y', _) => other - b'A' + 4,
(b'X', b'A') => 3,
(b'X', _) => other - b'A',
(_, b'C') => 7,
_ => other - b'A' + 8,
}) as usize
}
fn parse_input(raw: &str) -> &str {
raw
}
fn part1(parsed: &str) -> usize {
parsed.bytes().array_chunks().map(round).sum()
}
fn part2(parsed: &str) -> usize {
parsed.bytes().array_chunks().map(round_p2).sum()
}
boilerplate! {
TEST_INPUT == "\
A Y\n\
B X\n\
C Z\n\
",
tests: {
part1: { TEST_INPUT => 15 },
part2: {
TEST_INPUT => 12,
"A X\n" => 3,
"C X\n" => 2,
"A Y\n" => 4,
"A Z\n" => 8,
},
},
bench1 == 13268,
bench2 == 15508,
bench_parse: str::len => 10000,
}

58
2022/src/bin/day03.rs Normal file
View File

@ -0,0 +1,58 @@
#![feature(test, iter_array_chunks)]
extern crate test;
use std::collections::HashSet;
use aoc2022::{boilerplate, common::*};
const DAY: usize = 3;
type Parsed = Vec<(HashSet<u8>, HashSet<u8>)>;
fn parse_input(raw: &str) -> Parsed {
raw.lines()
.map(|line| {
let bytes = line.as_bytes();
let (a, b) = bytes.split_at(bytes.len() / 2);
(a.iter().copied().collect(), b.iter().copied().collect())
})
.collect()
}
fn part1(parsed: &Parsed) -> usize {
parsed.iter().map(|(a, b)| a.intersection(b).next().unwrap()).map(priority).sum()
}
fn priority(n: &u8) -> usize {
(match n {
b'a'..=b'z' => n - b'a' + 1,
b'A'..=b'Z' => n - b'A' + 27,
_ => unreachable!(),
}) as usize
}
fn part2(parsed: &Parsed) -> usize {
parsed
.iter()
.map(|(a, b)| a.union(b).collect::<HashSet<_>>())
.array_chunks()
.map(|[a, b, c]| *a.intersection(&b).copied().collect::<HashSet<_>>().intersection(&c).next().unwrap())
.map(priority)
.sum()
}
boilerplate! {
TEST_INPUT == "\
vJrwpWtwJgWrhcsFMMfFFhFp\n\
jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL\n\
PmmdzqPrVvPwwTWBwg\n\
wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn\n\
ttgJtRGJQctTZtZT\n\
CrZsJsPPZsGzwwsLwLmpwMDw\
",
tests: {
part1: { TEST_INPUT => 157 },
part2: { TEST_INPUT => 70 },
},
bench1 == 8202,
bench2 == 2864,
bench_parse: Vec::len => 300,
}

48
2022/src/bin/day04.rs Normal file
View File

@ -0,0 +1,48 @@
#![feature(test)]
extern crate test;
use std::ops::RangeInclusive;
use aoc2022::{boilerplate, common::*};
const DAY: usize = 4;
type Parsed = Vec<(RangeInclusive<usize>, RangeInclusive<usize>)>;
fn parse_range(r: &str) -> RangeInclusive<usize> {
let (a, b) = r.split_once('-').unwrap();
parse_num(a)..=parse_num(b)
}
fn parse_input(raw: &str) -> Parsed {
raw.lines()
.map(|line| {
let (a, b) = line.split_once(',').unwrap();
(parse_range(a), parse_range(b))
})
.collect()
}
fn part1(parsed: &Parsed) -> usize {
parsed.iter().filter(|(a, b)| (a.start() <= b.start() && a.end() >= b.end()) || (b.start() <= a.start() && b.end() >= a.end())).count()
}
fn part2(parsed: &Parsed) -> usize {
parsed.iter().filter(|(a, b)| a.contains(b.start()) || a.contains(b.end()) || b.contains(a.start()) || b.contains(a.end())).count()
}
boilerplate! {
TEST_INPUT == "\
2-4,6-8\n\
2-3,4-5\n\
5-7,7-9\n\
2-8,3-7\n\
6-6,4-6\n\
2-6,4-8\
",
tests: {
part1: { TEST_INPUT => 2 },
part2: { TEST_INPUT => 4 },
},
bench1 == 494,
bench2 == 833,
bench_parse: Vec::len => 1000,
}

Some files were not shown because too many files have changed in this diff Show More