Compare commits
13 Commits
33871a7f64
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0a6181ccc0 | ||
|
|
26e6851eec | ||
|
|
714980da64 | ||
|
|
17e4d9d0ab | ||
|
|
08306ed57d | ||
|
|
dc5a757eb6 | ||
|
|
9bd3d62eec | ||
|
|
e50555fe8b | ||
|
|
ce3466f746 | ||
|
|
b9df0aa858 | ||
|
|
435a06fd59 | ||
|
|
7f4a4329b0 | ||
|
|
c115484544 |
@@ -27,6 +27,11 @@ library
|
||||
exposed-modules:
|
||||
Day1
|
||||
Day1.Internal
|
||||
Day10
|
||||
Day11
|
||||
Day11.Parser
|
||||
Day12
|
||||
Day13
|
||||
Day2
|
||||
Day2.Part1
|
||||
Day2.Part2
|
||||
@@ -45,8 +50,12 @@ library
|
||||
Day5.Shared
|
||||
Day6
|
||||
Day7
|
||||
Day7.Interpreter
|
||||
Day7.Parser
|
||||
Day8
|
||||
Day9
|
||||
Lib
|
||||
Shared
|
||||
other-modules:
|
||||
Paths_aoc2022
|
||||
hs-source-dirs:
|
||||
@@ -58,10 +67,19 @@ library
|
||||
, containers
|
||||
, heredoc
|
||||
, hspec
|
||||
, hspec-megaparsec
|
||||
, lens
|
||||
, linear
|
||||
, matrix
|
||||
, megaparsec
|
||||
, mtl
|
||||
, parsec
|
||||
, search-algorithms
|
||||
, sort
|
||||
, split
|
||||
, text
|
||||
, transformers
|
||||
, vector
|
||||
default-language: Haskell2010
|
||||
|
||||
executable aoc2022-exe
|
||||
@@ -78,16 +96,29 @@ executable aoc2022-exe
|
||||
, containers
|
||||
, heredoc
|
||||
, hspec
|
||||
, hspec-megaparsec
|
||||
, lens
|
||||
, linear
|
||||
, matrix
|
||||
, megaparsec
|
||||
, mtl
|
||||
, parsec
|
||||
, search-algorithms
|
||||
, sort
|
||||
, split
|
||||
, text
|
||||
, transformers
|
||||
, vector
|
||||
default-language: Haskell2010
|
||||
|
||||
test-suite aoc2022-test
|
||||
type: exitcode-stdio-1.0
|
||||
main-is: Spec.hs
|
||||
other-modules:
|
||||
Day10Spec
|
||||
Day11Spec
|
||||
Day12Spec
|
||||
Day13Spec
|
||||
Day1Spec
|
||||
Day2Spec
|
||||
Day3Spec
|
||||
@@ -95,6 +126,8 @@ test-suite aoc2022-test
|
||||
Day5Spec
|
||||
Day6Spec
|
||||
Day7Spec
|
||||
Day8Spec
|
||||
Day9Spec
|
||||
Paths_aoc2022
|
||||
hs-source-dirs:
|
||||
test
|
||||
@@ -106,8 +139,17 @@ test-suite aoc2022-test
|
||||
, containers
|
||||
, heredoc
|
||||
, hspec
|
||||
, hspec-megaparsec
|
||||
, lens
|
||||
, linear
|
||||
, matrix
|
||||
, megaparsec
|
||||
, mtl
|
||||
, parsec
|
||||
, search-algorithms
|
||||
, sort
|
||||
, split
|
||||
, text
|
||||
, transformers
|
||||
, vector
|
||||
default-language: Haskell2010
|
||||
|
||||
@@ -30,6 +30,15 @@ dependencies:
|
||||
- lens
|
||||
- Ranged-sets
|
||||
- parsec
|
||||
- matrix
|
||||
- vector
|
||||
- megaparsec
|
||||
- transformers
|
||||
- hspec-megaparsec
|
||||
- mtl
|
||||
- sort
|
||||
- search-algorithms
|
||||
- linear
|
||||
|
||||
ghc-options:
|
||||
- -Wall
|
||||
|
||||
99
ressources/day08-input
Normal file
99
ressources/day08-input
Normal file
@@ -0,0 +1,99 @@
|
||||
002100030222341303232115221524311502200403234452204125251345024423544443305142410110142101223120110
|
||||
102030322341143330244233013052025453422005415304655426206452251310214055314024034341233110302320003
|
||||
003012203404011430120134554314552441635001641050211406204621114102021543144514102510421243314102033
|
||||
330313423002034140035001210441156554545625042262651356556544202500446121455112434243313013430141203
|
||||
331203121131230002055113430244610062654034520106363462155201210355601153542301323442223310134324300
|
||||
232201231021003254355411402310326206625011564114125202263504451451212600155351424154310240411213431
|
||||
033033333301011523544023206136145505304224325606020360006206455564513553512054354124523232201230441
|
||||
132201032234334044251334220345360402456541662253556375754662323265201641514121105025300453041111234
|
||||
314322341322104402235020206565044225363527617767574524475421763504341061551154250344125514014234344
|
||||
101323043023430543342440532324326413655657527215661116623455613664321005134300223542510253102211310
|
||||
320404242514122111525043444530625417656773117247512712444315767422412130351505513231104322032421303
|
||||
221204123205133142044056245654205231734371546616753217321556472223654044043612554152141554333102034
|
||||
340310155225452152216635634352712541366312326272262143522347111166646736001360102010220214000133002
|
||||
012404003515002416422500163244271366252711531615333437352461454777311142132000140205630042305222013
|
||||
332434552302203445503543424523327464362526657251687634745536521746523154717531643250132300541053000
|
||||
020130312425316362611130462217125425435545265467725256332777233137141524314631100051153314314343032
|
||||
112115124512002346011342433146124542356845483862756322785545283652723747276776403131622540014001524
|
||||
332354013101003031053022245431274627654677343638672643442563448782737464337546541546630431125021330
|
||||
220315320142064161406534365262377268373743527784575246325564676238816733767331345114363612344051535
|
||||
102041153526000601402325625766534543527882476653366727573448727775677146365732431425225562043130034
|
||||
350054114310533002426654125166575285757827422257872378766383267543484865317252532765440216543555512
|
||||
222440404353016144747347457368562668586285847553578732435887584463446862116134751240360645225435344
|
||||
554234546163262630313431762248876668663352436888374587856263343842526635237314231451062036605442520
|
||||
525531324662660356256614344438373575732699988366775989976447384338336827686445577222030363631240512
|
||||
055541261042533424177375756738443482846986979788978997559377679255463858237757327464422026230510130
|
||||
514123221240250442457744728347386637684953574546455344754548333793233865436751231314653541223102202
|
||||
355454250661114645144551785724753237378345375493453967559796675839837444334776625552412552302431302
|
||||
202445234333206767744653874724276586973668878949653473947686567565487325864733735677672241416513452
|
||||
445415223211061633767433865252483574744685974593334963668983745643354885658423263536531213102544202
|
||||
201405464251164654177385783224666473975674643767946648464678958969336335638578275154116223152222102
|
||||
401423140356441654745572266848965593553995667644648964747884544439493545472454437715336645303346422
|
||||
154440323240741427732867467564957336394985859766644495658985963583496399736552632162756445212536404
|
||||
441663663062661372122867364584655388977474857585778686889578799644949733463423826715534215154065204
|
||||
422036122016243651174663588693898583374968974778579585977478599643389537573534354622377452555411315
|
||||
430412403362272513348763673566578945645997454758694486758844958569786758359475575577532661126532300
|
||||
503653020441267422765353469867998339764449596776968996449777464644846938866332635583727771665263026
|
||||
006252631541331635768754753357384754988659585857956567666645975599653466655333342485345762600032403
|
||||
215205542775713732868842389885585646884858449858579777975997584997463698339932263363162431251615251
|
||||
342224450731115175762626546538955447796468885776778879697695699945446388444478355347827635732006646
|
||||
045011110226211633623658548365544498466468766878699597655897586488555435934935526883851537736604133
|
||||
440352212243431376382869634434568447654566895897796875679759667598898849334873844583742271767024403
|
||||
566632367121414762272448784755746799985759966559657989697977677955455754549393784586875275341562621
|
||||
004131167135757426882464486773699786789959957795985595559587775554479945637849747667752242212324244
|
||||
022411031432724262533554794664597446479869568767598899669969588984864457535986725263473577457413134
|
||||
036415005331162527346577487593798458668976888776888766856699598847776567686579476836656723623111342
|
||||
504001302331545267684439554776894957999788577876688969865558955547965687556849786463457244355044511
|
||||
464266074264126575276833864784546697885788878967966988678696686685576789843676844576623242451411411
|
||||
660130573642326366362654785549676574587876888769689696798799988678648554635745724364273772474666502
|
||||
413511521313437652422664948645649566979966676679778669968777776786958464356797545247763267365643645
|
||||
455033174473274564484285387995879595555686569997977698868769855686564847593489668858847744131410225
|
||||
560316675532344635443349663994499869866598568889798868967976679655597494679336978524332246567265361
|
||||
121053163342234352453837754569968465557968697766766888969966667796479457384444468264837376474515455
|
||||
604062313527642634768255846899648545559665886668966887999959659769978495794795825775373713613231451
|
||||
041031112622754332842439776736966994677888699898679988967779696758849589365579766676242256227420364
|
||||
630161363126476778455475799658545955598576568877768698668579988799596866465635488284555252726211044
|
||||
455563641427127283364758796475975894658677688789777769876667978747955677573575525588444241765111511
|
||||
256420063532645225542863884958844496596759999769769687678888788875449888945958948378756476127155054
|
||||
523256165217547362636325547686549767698957967985968987897777685866576744344388256886854362647342110
|
||||
205224606764556763544234874676659474468968576879668558856675855668779847849738247387744421321145610
|
||||
022651355615653552468486676459694744747575877656886776677858584988944678787576556747724125467333305
|
||||
526313424324717126486746644643397589664468865599858886996669788566489473798387676766873216657521426
|
||||
426530404522411762572567697375959747975669667958685679878659587764977658398697353283563215312244014
|
||||
023510245741131775436864579684699874979976567776557765866775469587757498544476554753722641656303654
|
||||
211341433442225414565332887899363678699495567888998675657659688744458493387343842346747477252626250
|
||||
406543152154335614758277748595836896786654948759999978569588555764838686653647362854723163226456101
|
||||
333640633617315535456525364849458558744656899855554897897568844446533866457545654847562377442214226
|
||||
040003053246534354438748723933365934878485997458955574785966996653353969666867276761661111124104550
|
||||
405602516206264365157378627495546935658594587869579958969686766986836687348285865231616336232000100
|
||||
304131030254233641578272475868953446545577766644956989679964489688554398956223433417637732661500540
|
||||
131164662225325441733366324345477954639475997658684766465487974699579665344326248136151472051130445
|
||||
452312154206174654138684277376889449945746954689646875777596486949365968888456226732332263263420000
|
||||
003010154551246223274282454345355673349967689986885795449989359633496728553885221437611730454554455
|
||||
131435126460017635544785754344874379695379366384573934357795398633967475353836864461424146264354142
|
||||
350154544045013352533173566257757787385448697484997454578735937499665628425542376452563635450224022
|
||||
302420224365163651765264446875287359533637498445639443969586466433384346337722662774436566624454214
|
||||
415242456321105173655733744886343826548944666338683876383973497998744488687446541256724244661531431
|
||||
155303206134314124372553618623857237346567857564464797593393675563536467777317174625640132203003240
|
||||
335521544652523624641575451785635352333587957647598535633948867838652636686573137515062356442045153
|
||||
235314500244636615342325346277256685653838226755493858683465683736283367654226655456541546644313125
|
||||
252520511531061305614364671212856473625642477732845278766573642425286572562373137446456005011330433
|
||||
241525455120116046543737642325543677623243884242534423327827446383376441727657314343125403632434002
|
||||
301045223551220356167117621755325772252845222546246588464784874685774676163655131632622146412415515
|
||||
011150133311336614251435416453632383454327534367288242328746537673543714263674263262001132354544412
|
||||
314104033000306256531666256433553535833538337463847277453476563227672715617272601302551120422305504
|
||||
104211442013141664402363645617163435245556228235337864656673626354151416721375243323635625100210424
|
||||
413422313502535362615054171511431775335574748526574728747453724472157632635263350024552502052340024
|
||||
131225301023304456424150404525765416565572272321835377167235317312551645334432406536160545434122120
|
||||
342131052232413325301451041516716541737346252413667115612642227312572433104525003114240240141232002
|
||||
244421101354005430232434420344323273421374225635551363463245561271743411452116466311034334101231020
|
||||
232404402304311415164151401553463731147111147752141732625152553615361046133341313265525232544143442
|
||||
201321033520133414312301326330253041267251614477322566645472656414545035321106361434351501123314104
|
||||
211232034442524242313453325046331353174352335422752364775746537513333534355120322320404054014303124
|
||||
224032233240430510135541652065052415154147565656231651653327511443424113100543020223335130010141400
|
||||
004110101133543440511523265424013341433043655022512172622140322434116104552043413352211021312421433
|
||||
000304433232402410151205333526613043463556021413402141634154404530112303306244402221312522221004042
|
||||
200204441020135232033032541516232550445221141520665016336536052063115335040344025054213324400312303
|
||||
300211022440310123055510053251505226452265556365100101014044645236505213550201425252404100302413231
|
||||
310312413210032422053242024243343060135340422313312403505631104430120233112324204414021331012401232
|
||||
132020341330304022053503522313342026211133610000020554213662244142551253124302245242110111033101203
|
||||
2000
ressources/day09-input
Normal file
2000
ressources/day09-input
Normal file
File diff suppressed because it is too large
Load Diff
139
ressources/day10-input
Normal file
139
ressources/day10-input
Normal file
@@ -0,0 +1,139 @@
|
||||
addx 1
|
||||
noop
|
||||
noop
|
||||
noop
|
||||
addx 5
|
||||
addx 5
|
||||
noop
|
||||
noop
|
||||
addx 9
|
||||
addx -5
|
||||
addx 1
|
||||
addx 4
|
||||
noop
|
||||
noop
|
||||
noop
|
||||
addx 6
|
||||
addx -1
|
||||
noop
|
||||
addx 5
|
||||
addx -2
|
||||
addx 7
|
||||
noop
|
||||
addx 3
|
||||
addx -2
|
||||
addx -38
|
||||
noop
|
||||
noop
|
||||
addx 32
|
||||
addx -22
|
||||
noop
|
||||
addx 2
|
||||
addx 3
|
||||
noop
|
||||
addx 2
|
||||
addx -2
|
||||
addx 7
|
||||
addx -2
|
||||
noop
|
||||
addx 3
|
||||
addx 2
|
||||
addx 5
|
||||
addx 2
|
||||
addx -5
|
||||
addx 10
|
||||
noop
|
||||
addx 3
|
||||
noop
|
||||
addx -38
|
||||
addx 1
|
||||
addx 27
|
||||
noop
|
||||
addx -20
|
||||
noop
|
||||
addx 2
|
||||
addx 27
|
||||
noop
|
||||
addx -22
|
||||
noop
|
||||
noop
|
||||
noop
|
||||
noop
|
||||
addx 3
|
||||
addx 5
|
||||
addx 2
|
||||
addx -11
|
||||
addx 16
|
||||
addx -2
|
||||
addx -17
|
||||
addx 24
|
||||
noop
|
||||
noop
|
||||
addx 1
|
||||
addx -38
|
||||
addx 15
|
||||
addx 10
|
||||
addx -15
|
||||
noop
|
||||
addx 2
|
||||
addx 26
|
||||
noop
|
||||
addx -21
|
||||
addx 19
|
||||
addx -33
|
||||
addx 19
|
||||
noop
|
||||
addx -6
|
||||
addx 9
|
||||
addx 3
|
||||
addx 4
|
||||
addx -21
|
||||
addx 4
|
||||
addx 20
|
||||
noop
|
||||
addx 3
|
||||
addx -38
|
||||
addx 28
|
||||
addx -21
|
||||
addx 9
|
||||
addx -8
|
||||
addx 2
|
||||
addx 5
|
||||
addx 2
|
||||
addx -9
|
||||
addx 14
|
||||
addx -2
|
||||
addx -5
|
||||
addx 12
|
||||
addx 3
|
||||
addx -2
|
||||
addx 2
|
||||
addx 7
|
||||
noop
|
||||
noop
|
||||
addx -27
|
||||
addx 28
|
||||
addx -36
|
||||
noop
|
||||
addx 1
|
||||
addx 5
|
||||
addx -1
|
||||
noop
|
||||
addx 6
|
||||
addx -1
|
||||
addx 5
|
||||
addx 5
|
||||
noop
|
||||
noop
|
||||
addx -2
|
||||
addx 20
|
||||
addx -10
|
||||
addx -3
|
||||
addx 1
|
||||
addx 3
|
||||
addx 2
|
||||
addx 4
|
||||
addx 3
|
||||
noop
|
||||
addx -30
|
||||
noop
|
||||
55
ressources/day11-input
Normal file
55
ressources/day11-input
Normal file
@@ -0,0 +1,55 @@
|
||||
Monkey 0:
|
||||
Starting items: 52, 78, 79, 63, 51, 94
|
||||
Operation: new = old * 13
|
||||
Test: divisible by 5
|
||||
If true: throw to monkey 1
|
||||
If false: throw to monkey 6
|
||||
|
||||
Monkey 1:
|
||||
Starting items: 77, 94, 70, 83, 53
|
||||
Operation: new = old + 3
|
||||
Test: divisible by 7
|
||||
If true: throw to monkey 5
|
||||
If false: throw to monkey 3
|
||||
|
||||
Monkey 2:
|
||||
Starting items: 98, 50, 76
|
||||
Operation: new = old * old
|
||||
Test: divisible by 13
|
||||
If true: throw to monkey 0
|
||||
If false: throw to monkey 6
|
||||
|
||||
Monkey 3:
|
||||
Starting items: 92, 91, 61, 75, 99, 63, 84, 69
|
||||
Operation: new = old + 5
|
||||
Test: divisible by 11
|
||||
If true: throw to monkey 5
|
||||
If false: throw to monkey 7
|
||||
|
||||
Monkey 4:
|
||||
Starting items: 51, 53, 83, 52
|
||||
Operation: new = old + 7
|
||||
Test: divisible by 3
|
||||
If true: throw to monkey 2
|
||||
If false: throw to monkey 0
|
||||
|
||||
Monkey 5:
|
||||
Starting items: 76, 76
|
||||
Operation: new = old + 4
|
||||
Test: divisible by 2
|
||||
If true: throw to monkey 4
|
||||
If false: throw to monkey 7
|
||||
|
||||
Monkey 6:
|
||||
Starting items: 75, 59, 93, 69, 76, 96, 65
|
||||
Operation: new = old * 19
|
||||
Test: divisible by 17
|
||||
If true: throw to monkey 1
|
||||
If false: throw to monkey 3
|
||||
|
||||
Monkey 7:
|
||||
Starting items: 89
|
||||
Operation: new = old + 2
|
||||
Test: divisible by 19
|
||||
If true: throw to monkey 2
|
||||
If false: throw to monkey 4
|
||||
82
ressources/day12-input
Normal file
82
ressources/day12-input
Normal file
@@ -0,0 +1,82 @@
|
||||
abaaacccccccccaaaaaaccccccccccccccccaacccccccccccaacaaaaaaaaaaaaaaaaaccaaaaacccaaaaccccccccccccccccccccccccccccccccccccccccccccccccccccccccaaaaa
|
||||
abaaacccccccccaaaaaacccccccccccccccaaaaccccccccccaaaaaaaacaaaaaaaaaaaccaaaaaaccaaaacccccccccccccccccccccccccccccccccccccccccccccccccccccccaaaaaa
|
||||
abaaaccccccccccaaaaacccccccccccccccaaaacccccccccccaaaaacccaaaaaaaaaacccaaaaaacccaaccccccccccccccaaaaacccccccccccccccccccccccccccccccccccccaaaaaa
|
||||
abccccaaccccccaaaaacccccccccaaaaaccaaaaccccccccccccaaaaacaaaaaaaaacccccaaaaaccccccccccccccccccccaaaaacccccccccccccccccaaaccccaaaccccccccccaaacaa
|
||||
abcccaaaacccccaaaaacccccccccaaaaacccccccccccccccccaaacaaaaaaaaaacccccccaaaaacccccccccccccccccccaaaaaacccccccccccccccccaaaaccaaaaccccccccccccccaa
|
||||
abcccaaaaacacccccccccccccccaaaaaaccccccccccccccccccaaccaaaaacaaaaccccccccccccccccccccccccccccccaaaaaaccccccccccccccccccaaaaaaaacccccccccccccccaa
|
||||
abaaaaaaaaaacccccccccccccccaaaaaaccccccccccccccccccccccaaaacccaaaccccccccccccccccccccccccccccccaaaaaacccccccccccccccciiiiijaaaaccccccccccccccccc
|
||||
abaaaaaaaaaacccccccccccccccaaaaaacccccccccccccccccccccccccccccaaacccccccccccccccccccccccccccccccaaaccccccccccccccccciiiiiijjjaccccccccaaaccccccc
|
||||
abccaaaaaaccccccccccccccccccaaaccccccccccccccccccccccccccccccccacccccccccccaacccccccccccccccccccccccccccccccccccccciiiiioijjjjaaccccccaaaaaacccc
|
||||
abccaaaaaacccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccaaaaaacccccccccccccccccccccccccccccccccccciiinnooojjjjjaaccaaaaaaaacccc
|
||||
abccaaaaaacccccccccccccccccccccccccccccccccccccaacccccaacccccccccccccccccaaaaaacccccccccccccccccccccccccccaaaccccciiinnnoooojjjjjjkkkaaaaaaacccc
|
||||
abcaaaaaaaaccccccccccccccccccccccccccccccccccccaaaccaaaaaaccccaaacccccccccaaaacccccccccccccccccccccccccccccaaaaccciiinnnouooojjjjkkkkkaaaaaccccc
|
||||
abccaccccccccccccccccccaaccccccaccccccccccccaaaaaaaaaaaaaacccaaaacccccccccaaaacccccccccccccccccccccccccccaaaaaacchhinnnttuuooooookkkkkkkaaaccccc
|
||||
abccccccccccccccccccaacaaaccccaaaaaaaaccccccaaaaaaaacaaaaacccaaaacccccccccaccacccccccccccccccccccccccccccaaaaacchhhhnntttuuuooooppppkkkkcaaacccc
|
||||
abccccccccaaacccccccaaaaaccccccaaaaaaccccccccaaaaaacaaaaaccccaaaaccccccccccccccccccccccccccccaccccccccccccaaaaahhhhnnntttxuuuooppppppkkkcccccccc
|
||||
abccccccccaaaacccccccaaaaaaccccaaaaaaccaaacccaaaaaacaaaaaccccccccccccccaaccccccccccccccaaaaaaaacccccccccccaachhhhhnnnntttxxuuuuuuuupppkkkccccccc
|
||||
abccccccccaaaacccccaaaaaaaacccaaaaaaaacaaacacaaaaaaccccccccccccccccccccaacccccccccccccccaaaaaacccccccccccccchhhhmnnnntttxxxxuuuuuuupppkkcccccccc
|
||||
abacccccccaaaacccccaaaaacaaccaaaaaaaaaaaaaaaaaaccaacccccccccccccccccaaaaaaaaccccccccccccaaaaaaccccccccccccchhhhmmmntttttxxxxuyyyuvvpppklcccccccc
|
||||
abacccccccccccccccccacaaaccaaaaaaaaaaaaaaaaaaaccccccccccccccccccccccaaaaaaaacccccccccccaaaaaaaaccccccccccccgghmmmtttttxxxxxxyyyyvvvpplllcccccccc
|
||||
abaccccccccaacccccccccaaaccaaaaaaaacaaaaaaaaaaccccccccccccccccccccccccaaaaccccccccccccaaaaaaaaaaccccccaccccgggmmmtttxxxxxxxyyyyyvvppplllcccccccc
|
||||
SbaaaccccccaaacaaaccccccccaaaaaaaaacaaaaaaaaacccccccccccccccccccccccccaaaaacccccccccccaaaaaaaaaaaaacaaaccaagggmmmtttxxxEzzzzyyyvvppplllccccccccc
|
||||
abaacccccccaaaaaaacccccccaaaaaaacaaccaaaaaaaccccccccccccccaaaccccccccaaaaaacccccccccccacacaaacccaaaaaaacaaagggmmmsssxxxxxyyyyyvvvqqqlllccccccccc
|
||||
abaccccccccaaaaaaccacccaaaaaaaaacccccccaaaaaaccccccccccccaaaaccccccccaaccaacccccccccccccccaaaccccaaaaaaccaagggmmmssssxxwwyyyyyyvvqqqlllccccccccc
|
||||
abaccccccaaaaaaaaccaacaaaccaaaaaacccccaaaaaaaccccccccccccaaaaccccccccccaacccccccccccccccccaacccccaaaaaaaaaaggggmmmssssswwyywyyyyvvqqlllccccccccc
|
||||
abaccccccaaaaaaaaacaaaaacccaaaaaacccccaaacaaaccccccccccccaaaaccccccccaaaaaaccccccccccccaacccccccaaaaaaaaaaaaggggmmmossswwyywwyyvvvqqqllccccccccc
|
||||
abcccccccaaaaaaaaaacaaaaaacaaccccccccaaacccccccccccccccccccccccccccccaaaaaaccccccccccccaaaaacccaaaaaaaaaaaaaaggggoooosswwywwwwvvvvqqqmlccccccccc
|
||||
abccccccccccaaacaaaaaaaaaacccccccccccaaacaccccccccccccccccccccccccccccaaaaccccccccccccaaaaaccccaaacaaacccaaacagggfooosswwwwwrvvvvqqqqmmccccccccc
|
||||
abccccccccccaaacccaaaaaaaacccccccccaacaaaaacccccccccccccccccccccccccccaaaaccccccccccccaaaaaacccccccaaacccaaccccfffooosswwwwrrrrrqqqqqmmccccccccc
|
||||
abccccccccccaacccccccaaccccccccccccaaaaaaaacccccccccccccaaccccccccccccaccaccccccccccccccaaaacccccccaacccccccccccfffoossrwrrrrrrrqqqqmmmccccccccc
|
||||
abccaaaccccccccccccccaacccccccccccccaaaaaccccccccccccaacaacccccccaaaaacccccccccccccccccaacccccccccccccccccccccccfffoossrrrrrnnnmqqmmmmmccccccccc
|
||||
abcaaaaccccccccccccccccccccccccccccccaaaaacccccccccccaaaaacccccccaaaaacccaaaccccccccccccccccccccccccccccccccccccfffooorrrrrnnnnmmmmmmmccccaacccc
|
||||
abcaaaacccccccccccccccccccccccccccccaaacaaccccacccccccaaaaaaccccaaaaaaccccaaaccacccccccccccccccccccccccccccccccccffoooonnnnnnnnmmmmmmccccaaacccc
|
||||
abccaaacccccccccccccccccccccaaaaaccccaaccccaaaacccccaaaaaaaaccccaaaaaaccccaaaaaaaccccccccccccccccaccaccccccccccccfffooonnnnnnddddddddcccaaaccccc
|
||||
abccccccccccccccccccccccccccaaaaaccccccccccaaaaaacccaaaaacaacccaaaaaaaccaaaaaaaacccccccccccccccccaaaaccccccccccccfffeonnnnneddddddddddcaaacccccc
|
||||
abccccccccccaaaccccccccccccaaaaaacccccccccccaaaacccccacaaacccccaacaacccaaaaaaaaacccccccccccccccccaaaacccccccccccccffeeeeeeeeddddddddcccaaacccccc
|
||||
abcccccccccaaaaccccacccccccaaaaaaccccccccccaaaaacccccccaaaacccaaacaccccaaaaaaaaaccccccccccccccccaaaaaaccccccccccccceeeeeeeeedacccccccccccccccccc
|
||||
abaccccccccaaaaccccaaacaaacaaaaaaccccccccccaacaaccccccccaaaacaaaacaaacaaaaaaaaaacccccccccccccaacaaaaaacccccccccccccceeeeeeeaaacccccccccccccccaaa
|
||||
abaaacccccccaaaccccaaaaaaaccaaaccccccccaaacccccccccccccccaaaaaaaacaaaaaaaaaaaaaaacacaaccaaacaaacccaacccccccccccccccccaacccaaaacccccccccccccccaaa
|
||||
abaaaccccccccccccccaaaaaaccccccccccccccaaacccccccccccccccaaaaaaaccaaaaaaccaacccaccaaaaccaaaaaaaccccccccaaccccccccccccccccccaaacccccccccccccccaaa
|
||||
abaaccccccccccccccaaaaaaacccccccccccaaaaaaaaccccccccccccccaaaaaaaaaaaaaacaaaccccccaaaaaccaaaaaaccccccaaaaccccccccccccccccccaaaccccccccccccaaaaaa
|
||||
abaaaccccccccccccaaaaaaaaaacccccccccaaaaaaaacccccccccccaaaaaaaaaaaaaaaaaaacccccccaaaaaacaaaaaaaaaccccaaaaaacccccccccccccccccccccccccccccccaaaaaa
|
||||
abaaacccccccccaaaaaaccccccccccccccccaacccccccccccaacaaaaaaaaaaaaaaaaaccaaaaacccaaaaccccccccccccccccccccccccccccccccccccccccccccccccccccccccaaaaa
|
||||
abaaacccccccccaaaaaacccccccccccccccaaaaccccccccccaaaaaaaacaaaaaaaaaaaccaaaaaaccaaaacccccccccccccccccccccccccccccccccccccccccccccccccccccccaaaaaa
|
||||
abaaaccccccccccaaaaacccccccccccccccaaaacccccccccccaaaaacccaaaaaaaaaacccaaaaaacccaaccccccccccccccaaaaacccccccccccccccccccccccccccccccccccccaaaaaa
|
||||
abccccaaccccccaaaaacccccccccaaaaaccaaaaccccccccccccaaaaacaaaaaaaaacccccaaaaaccccccccccccccccccccaaaaacccccccccccccccccaaaccccaaaccccccccccaaacaa
|
||||
abcccaaaacccccaaaaacccccccccaaaaacccccccccccccccccaaacaaaaaaaaaacccccccaaaaacccccccccccccccccccaaaaaacccccccccccccccccaaaaccaaaaccccccccccccccaa
|
||||
abcccaaaaacacccccccccccccccaaaaaaccccccccccccccccccaaccaaaaacaaaaccccccccccccccccccccccccccccccaaaaaaccccccccccccccccccaaaaaaaacccccccccccccccaa
|
||||
abaaaaaaaaaacccccccccccccccaaaaaaccccccccccccccccccccccaaaacccaaaccccccccccccccccccccccccccccccaaaaaacccccccccccccccciiiiijaaaaccccccccccccccccc
|
||||
abaaaaaaaaaacccccccccccccccaaaaaacccccccccccccccccccccccccccccaaacccccccccccccccccccccccccccccccaaaccccccccccccccccciiiiiijjjaccccccccaaaccccccc
|
||||
abccaaaaaaccccccccccccccccccaaaccccccccccccccccccccccccccccccccacccccccccccaacccccccccccccccccccccccccccccccccccccciiiiioijjjjaaccccccaaaaaacccc
|
||||
abccaaaaaacccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccaaaaaacccccccccccccccccccccccccccccccccccciiinnooojjjjjaaccaaaaaaaacccc
|
||||
abccaaaaaacccccccccccccccccccccccccccccccccccccaacccccaacccccccccccccccccaaaaaacccccccccccccccccccccccccccaaaccccciiinnnoooojjjjjjkkkaaaaaaacccc
|
||||
abcaaaaaaaaccccccccccccccccccccccccccccccccccccaaaccaaaaaaccccaaacccccccccaaaacccccccccccccccccccccccccccccaaaaccciiinnnouooojjjjkkkkkaaaaaccccc
|
||||
abccaccccccccccccccccccaaccccccaccccccccccccaaaaaaaaaaaaaacccaaaacccccccccaaaacccccccccccccccccccccccccccaaaaaacchhinnnttuuooooookkkkkkkaaaccccc
|
||||
abccccccccccccccccccaacaaaccccaaaaaaaaccccccaaaaaaaacaaaaacccaaaacccccccccaccacccccccccccccccccccccccccccaaaaacchhhhnntttuuuooooppppkkkkcaaacccc
|
||||
abccccccccaaacccccccaaaaaccccccaaaaaaccccccccaaaaaacaaaaaccccaaaaccccccccccccccccccccccccccccaccccccccccccaaaaahhhhnnntttxuuuooppppppkkkcccccccc
|
||||
abccccccccaaaacccccccaaaaaaccccaaaaaaccaaacccaaaaaacaaaaaccccccccccccccaaccccccccccccccaaaaaaaacccccccccccaachhhhhnnnntttxxuuuuuuuupppkkkccccccc
|
||||
abccccccccaaaacccccaaaaaaaacccaaaaaaaacaaacacaaaaaaccccccccccccccccccccaacccccccccccccccaaaaaacccccccccccccchhhhmnnnntttxxxxuuuuuuupppkkcccccccc
|
||||
abacccccccaaaacccccaaaaacaaccaaaaaaaaaaaaaaaaaaccaacccccccccccccccccaaaaaaaaccccccccccccaaaaaaccccccccccccchhhhmmmntttttxxxxuyyyuvvpppklcccccccc
|
||||
abacccccccccccccccccacaaaccaaaaaaaaaaaaaaaaaaaccccccccccccccccccccccaaaaaaaacccccccccccaaaaaaaaccccccccccccgghmmmtttttxxxxxxyyyyvvvpplllcccccccc
|
||||
abaccccccccaacccccccccaaaccaaaaaaaacaaaaaaaaaaccccccccccccccccccccccccaaaaccccccccccccaaaaaaaaaaccccccaccccgggmmmtttxxxxxxxyyyyyvvppplllcccccccc
|
||||
SbaaaccccccaaacaaaccccccccaaaaaaaaacaaaaaaaaacccccccccccccccccccccccccaaaaacccccccccccaaaaaaaaaaaaacaaaccaagggmmmtttxxxEzzzzyyyvvppplllccccccccc
|
||||
abaacccccccaaaaaaacccccccaaaaaaacaaccaaaaaaaccccccccccccccaaaccccccccaaaaaacccccccccccacacaaacccaaaaaaacaaagggmmmsssxxxxxyyyyyvvvqqqlllccccccccc
|
||||
abaccccccccaaaaaaccacccaaaaaaaaacccccccaaaaaaccccccccccccaaaaccccccccaaccaacccccccccccccccaaaccccaaaaaaccaagggmmmssssxxwwyyyyyyvvqqqlllccccccccc
|
||||
abaccccccaaaaaaaaccaacaaaccaaaaaacccccaaaaaaaccccccccccccaaaaccccccccccaacccccccccccccccccaacccccaaaaaaaaaaggggmmmssssswwyywyyyyvvqqlllccccccccc
|
||||
abaccccccaaaaaaaaacaaaaacccaaaaaacccccaaacaaaccccccccccccaaaaccccccccaaaaaaccccccccccccaacccccccaaaaaaaaaaaaggggmmmossswwyywwyyvvvqqqllccccccccc
|
||||
abcccccccaaaaaaaaaacaaaaaacaaccccccccaaacccccccccccccccccccccccccccccaaaaaaccccccccccccaaaaacccaaaaaaaaaaaaaaggggoooosswwywwwwvvvvqqqmlccccccccc
|
||||
abccccccccccaaacaaaaaaaaaacccccccccccaaacaccccccccccccccccccccccccccccaaaaccccccccccccaaaaaccccaaacaaacccaaacagggfooosswwwwwrvvvvqqqqmmccccccccc
|
||||
abccccccccccaaacccaaaaaaaacccccccccaacaaaaacccccccccccccccccccccccccccaaaaccccccccccccaaaaaacccccccaaacccaaccccfffooosswwwwrrrrrqqqqqmmccccccccc
|
||||
abccccccccccaacccccccaaccccccccccccaaaaaaaacccccccccccccaaccccccccccccaccaccccccccccccccaaaacccccccaacccccccccccfffoossrwrrrrrrrqqqqmmmccccccccc
|
||||
abccaaaccccccccccccccaacccccccccccccaaaaaccccccccccccaacaacccccccaaaaacccccccccccccccccaacccccccccccccccccccccccfffoossrrrrrnnnmqqmmmmmccccccccc
|
||||
abcaaaaccccccccccccccccccccccccccccccaaaaacccccccccccaaaaacccccccaaaaacccaaaccccccccccccccccccccccccccccccccccccfffooorrrrrnnnnmmmmmmmccccaacccc
|
||||
abcaaaacccccccccccccccccccccccccccccaaacaaccccacccccccaaaaaaccccaaaaaaccccaaaccacccccccccccccccccccccccccccccccccffoooonnnnnnnnmmmmmmccccaaacccc
|
||||
abccaaacccccccccccccccccccccaaaaaccccaaccccaaaacccccaaaaaaaaccccaaaaaaccccaaaaaaaccccccccccccccccaccaccccccccccccfffooonnnnnnddddddddcccaaaccccc
|
||||
abccccccccccccccccccccccccccaaaaaccccccccccaaaaaacccaaaaacaacccaaaaaaaccaaaaaaaacccccccccccccccccaaaaccccccccccccfffeonnnnneddddddddddcaaacccccc
|
||||
abccccccccccaaaccccccccccccaaaaaacccccccccccaaaacccccacaaacccccaacaacccaaaaaaaaacccccccccccccccccaaaacccccccccccccffeeeeeeeeddddddddcccaaacccccc
|
||||
abcccccccccaaaaccccacccccccaaaaaaccccccccccaaaaacccccccaaaacccaaacaccccaaaaaaaaaccccccccccccccccaaaaaaccccccccccccceeeeeeeeedacccccccccccccccccc
|
||||
abaccccccccaaaaccccaaacaaacaaaaaaccccccccccaacaaccccccccaaaacaaaacaaacaaaaaaaaaacccccccccccccaacaaaaaacccccccccccccceeeeeeeaaacccccccccccccccaaa
|
||||
abaaacccccccaaaccccaaaaaaaccaaaccccccccaaacccccccccccccccaaaaaaaacaaaaaaaaaaaaaaacacaaccaaacaaacccaacccccccccccccccccaacccaaaacccccccccccccccaaa
|
||||
abaaaccccccccccccccaaaaaaccccccccccccccaaacccccccccccccccaaaaaaaccaaaaaaccaacccaccaaaaccaaaaaaaccccccccaaccccccccccccccccccaaacccccccccccccccaaa
|
||||
abaaccccccccccccccaaaaaaacccccccccccaaaaaaaaccccccccccccccaaaaaaaaaaaaaacaaaccccccaaaaaccaaaaaaccccccaaaaccccccccccccccccccaaaccccccccccccaaaaaa
|
||||
abaaaccccccccccccaaaaaaaaaacccccccccaaaaaaaacccccccccccaaaaaaaaaaaaaaaaaaacccccccaaaaaacaaaaaaaaaccccaaaaaacccccccccccccccccccccccccccccccaaaaaa
|
||||
449
ressources/day13-input
Normal file
449
ressources/day13-input
Normal file
@@ -0,0 +1,449 @@
|
||||
[[4,[1,[]]],[8,3,[[0,2],[5,2,6],[7,0,10,0],2,[5,7,10,2]],[[5,9],5,10,[9,7,7]]]]
|
||||
[[[],9],[[[3,2,6,3],[7,8]],10],[1]]
|
||||
|
||||
[[],[0,4,[[2,9,0,1,2],[1,1,1,1],9,[2]]],[[],5]]
|
||||
[[[[4,6],[9,4,9,5],7,[1,3,6],[]]],[1,[]],[8,[6,[8],0,5],[],[[7,4,9],[4,2,8,2,2],[10,5,5,4],4]],[8,[7,[7,3],[4],10],[10],[[10,1]]],[]]
|
||||
|
||||
[[0],[[[1],0,[],2,[4,5,6,3,2]],5,[],3],[[0,[8,8,5,2],10,[7,6,4,8],[4,9,3,9,5]],9,[4,6]],[[10,6,[10,2],8,[]],[10,[10,8,10,1,4],[0,6],4],8,[6,[5,3,3],6,[3,9,4,0],7]],[[4,8],[1,3,9],[[2],6],5,[0,[5,0],0,5]]]
|
||||
[[[[10,8],[3,6,7],3,[4]],[[8,10,8,4,0],[7,2],7,[2],[1,3]],3,[[0,7,9,1,10],[8,1,6]]]]
|
||||
|
||||
[[[1,[5,2,6,6,0]],[[7,7],[]],[[4,5],[],[],[3,7,1,8],1]],[9,[[],[8,7,8,9]],[2,4,0,[7,4,4]],[1],[]],[[[],[4,7,0,4],[1,0]],5,4],[],[[9,[],[7]]]]
|
||||
[[[3],[[5,2,1]],2]]
|
||||
|
||||
[[[[5,8,8,6],0]]]
|
||||
[[[[3,0,10,1,5],10,[7,0]],8,[0,9,4,[8,10]],[[6],[4,4,8],7,9,[9]]],[[7,[],0,2],[[]],5,6,[]],[0,[[1,10,8,8,1],2,[2,6],[10,9],[7]]],[2],[[[],2,5,[2,9,6,0],8],9]]
|
||||
|
||||
[[],[6],[[0,[2],8,[]],[[0],9,5,[7,6,6,6,9],[3,1]],4,10],[[4,[5,1,9,4],2]]]
|
||||
[[[],[[3,7,5,4,1],[9,0,2,5,6],[4,3],2,[0,1,2,7,2]],[]],[[],2,5,3],[[2,9],1,10,0,1],[[4,9],[],[6,[],7,10,[10,9,1,10,9]],1,7]]
|
||||
|
||||
[[10],[],[6,[],[]],[],[2,0,5]]
|
||||
[[6,1,[8,6,9]]]
|
||||
|
||||
[[8,[[0,0],[],1,[8],8],4,[7,8,1,10],10],[]]
|
||||
[[[0],6],[[],3]]
|
||||
|
||||
[[[8,[5],[4],[2,0]],[[1],1,[4,2,10,6]]],[[],[6,5,[6],[9,2,3]],[[6]]]]
|
||||
[[[6,2,4,[4,9],[2,4,10]]],[[3,[5,5,10,9,9],10,[6,2,8,7,9]],[],4],[[[3,2],[]]],[[[10,9],[3,10]],[0,1]]]
|
||||
|
||||
[[[[8,10,1],10]],[7],[[9,[7],[0,9,8,4]]],[[4],4,0]]
|
||||
[[1,[],[[9,9,2],[10],[]]],[[[7],[],[],[],4],[[3],0,[5,7,1],6],3,10],[2]]
|
||||
|
||||
[[10],[],[]]
|
||||
[[2,4,2,[[6],[1,10],4,9],3],[7,8,5],[[],0],[[5,[],[]],7]]
|
||||
|
||||
[[5,3,[[7,6,10],10,7,[6,5,7,9],8],[],4],[0,[[6],[2,2,1,5,7],[1],[2],1],[2],[1,[7,1,3,0,3],[9],7,[1,9,6]]]]
|
||||
[[[4,[5,9,6,5,6],1,[6,4,4,4,9]],[[],6,[8,3],[2,1],9]],[6,[[10,1]],[7,[6,1]],[[6,3,8,2],8]],[2,7,[],7],[0,7,[[6],9,[4,10,6,6,4]],[]],[7,4,[8,[1,6,8,7]],9]]
|
||||
|
||||
[[8],[[1,0,2,10,3],5],[],[9,[[1],[3,6,6,6,8],2,5,8],10,9,[3]],[4,6,1,[8]]]
|
||||
[[3,4],[[],[7,[1,10],[9,9,7,5,2],5]],[],[[0,[4,7],[2,7,3,8],3],[3],[[],[],9,[2,7,9]],[8,2,6]],[9,[]]]
|
||||
|
||||
[[[[2,0,1],6,[1],7]],[7,10,2],[],[[]],[2,1,[[],9],[[6,9,9,6,0],[],[10,2]]]]
|
||||
[[4,[],6,5],[[],[[],[5,2]],[1,4],0,[[5],[9,9,4,1,5]]],[[],10,10,[8],[1,[8],2,9,2]],[7,3,[[0,8,5,2],[4,2,10],0]],[1,[[1,9,5],3,10,[10,8]],9,[[]]]]
|
||||
|
||||
[[5,7,8,9],[6,9,[5],0,[7,[4],[9,7,1,1],7,6]],[[[8,2,9,6]],[8,5,[4,1,0]],[[2,6,3],[2],[4,0],[2,0,5]],6,[[9,6,7,4],[4],4,8,[9]]]]
|
||||
[[[8,3,[3],[7,5,10]],3,[5],9,0],[3],[[[9,6,0]],1],[3,10,[[9,8,6,10],4,[10,10],[10],[2,7]],2,10],[5]]
|
||||
|
||||
[[],[4,[[7]],[[3,10],[5]]]]
|
||||
[[[[0,5,7],0,10],[[],2,8,3],1,[5,8]],[]]
|
||||
|
||||
[[[],[[4,5],9,8,[4,2,7],[1,6]],[[]],1,[[1,10,9,10,4],2,4]],[8,[0,7,2,[3,8,4,9]],[[5,9,3],1]],[[[4],10,[5]],4],[5,[4,9,[]],1,1,8]]
|
||||
[[4],[1],[],[[[3,2,1,5,6]],[[4],[2,1,3]],[10,5]]]
|
||||
|
||||
[[0,6],[],[[],7,9,5],[]]
|
||||
[[[5,[2,5,0,8,10],5,[10,8,10,7]],5,6],[[7,[]],10]]
|
||||
|
||||
[[[[7,0,7],[8,4,10,2,6],[10,8,9],[10,3]],[[1,9,5,0],2,[1,8,1,8,2]]],[[[],[9,3],10,[1],9],[[9,9,6]],1,[0],9]]
|
||||
[[[[5,1,9,10,6],7]],[10,[4],[7],0],[1,8,[[],4,[10]],[[6,8,4,2],6,[],[10,8]]]]
|
||||
|
||||
[[10,[[6,7,7],[5,5,1,4]],[1,0,0,7,[1,8,2]]],[4],[9],[[5],[10,[2,5,10]],5,[]]]
|
||||
[[8],[4,5],[6,[[9,1,5],[2,10,3,7,7],9]],[9,0,0,[],[0,[7,3],3]]]
|
||||
|
||||
[[],[[[4,7,9,6]],2,10,[6]],[[[3,3,10,5],[2,6,1,5,2],[3],[],8],2,7],[6,9,[0,8,9,10,8]]]
|
||||
[[[4,0,[5]],0,[[],[1,6,5,5,5],[5,2,7,5],2],3,[9,[9,3,9,7,4]]],[8,[],[[1,1]],[[4,8,1],[7,6,8,8],[],10]],[4,[[6,6,3,10,2],[8,1,1,1,7]],[[3],9,[4,3,9,1,7]]],[[1,[8,6,3,1],[2,10,9]]]]
|
||||
|
||||
[[[[1,4,10,6],10,[5,6,10,3]],8,[[]],[],6],[],[[9,[5,6],8],10],[2,[9,[5,3,10,4],10,[],[7,4,1,9]]]]
|
||||
[[4,[[]],[1,[10,8],7,[4],[0,3,2]]],[[[6,4,7,0]]],[10,7,[6,[1,2,8,4]],[9,[3,8,4,7,2]]],[4,[8,[6,10,10,9],[],9],6,[[4,8,3],10,1,2],8],[[7,7,[8,8,7,1,1],6],[[8,8,10,2,4],0]]]
|
||||
|
||||
[[],[8],[8,10,0],[7,[[4,1,0],5]],[[[6,9,4],[9,1],[6,4,6,6,10],[]],3,7]]
|
||||
[[9],[3,6,[[1,7],[],9,[8]],[7,[9],3,[]],9],[0,[0,2]],[3]]
|
||||
|
||||
[[7,[10,[3,0,10],5,[5,3,2],4]],[]]
|
||||
[[[5,8,3,[0,2,2,7,0],7],[[10,2,0,10,7],[0,3,10,10,5]],3,[8],[10,4,7,0]],[]]
|
||||
|
||||
[[[0,[0,8,1],2],4,[],[9],10]]
|
||||
[[[3,6,[2,0]],5,[[7,2],[],3,5,4]],[[9]],[7,[6,[1,5],[9,6]],[[],9,[1],3],[10,[],0]],[[1,[5,6],9,[10,7,4,7,4]],[5,[0,7,0,0],6,[0,0]],[],[[10,1,9,9,6],[1,3],[8],3]],[[[],[]]]]
|
||||
|
||||
[[9,[[4,3,0]]]]
|
||||
[[10,9],[[],[[0,8,0,8],[0,10,4,2]],[10,[0,0],[5,10,0,5],5],5]]
|
||||
|
||||
[[[[8,5,4,6]]],[8,[2,0,[3,6,7,8],10,[3,8]]],[0,2,[[3,6,10,4],[8,7,6,6,2],9,[7,3,9,7]],[3,9],[9,[3,8,0],2,9,[4]]]]
|
||||
[[6,[6],4,[[10],[0,1,3,3,8],1,2],9],[[[0,5,7,6,7],[3,3,10,9,2],4],[[],5,1,4],[[8,10,1,4,1],3,5,1,2],[[1,6,6,0],[9,7,6,7]]],[]]
|
||||
|
||||
[]
|
||||
[[8,0,[7,[10,10,8,6],5],6],[],[]]
|
||||
|
||||
[[[[9,10,3],10,5,4],[[7,2]],1,6],[9,[5,[7,3,3,5,2]]],[6,[[1],[],[8,4,6,3,2]]]]
|
||||
[[[[2,8,2],[4,9],2,10,[3,6]],6],[1,8,2],[2,8],[[1,[5],6,[]],1,[1]]]
|
||||
|
||||
[[[[0,2,1],9,1,[6,2]],8,1],[10,[],6,8,[1,0]],[1,2,[3,9,[3,6],[9,0,10],7]]]
|
||||
[[[[1,7,3,9,6],[],[],4],[],1,1],[[],10,10],[],[[3,5],[[10,3,10,9],3,9]],[0,[[],4,[6,2,3,9,7],[4,10,4,4]],[7,10,3,[1,0,4],[10,9,4]],4]]
|
||||
|
||||
[[],[],[],[7],[0]]
|
||||
[[1,[]],[],[5,6]]
|
||||
|
||||
[[6,2,0],[]]
|
||||
[[5,7,5,[[2],[3]],[[1],[2,9]]],[1],[[[5,1,1,9],[]],2,1,[9]],[[9,[],[9,4],0],3,2]]
|
||||
|
||||
[[[2,10,0,2],[],5,[[7],[],[],[5,3],[7,9]],7],[],[],[]]
|
||||
[[1,8,[4,[],[],[5],[6]]]]
|
||||
|
||||
[[2,[3,[],10]],[[],5,[],[[8,8,7]]],[4,[4,[2],[6,0,0,10,3]],[[1,4]],2]]
|
||||
[[8],[[[]],7],[10,9,2,[[8],6,6,[8,1,4,5]]]]
|
||||
|
||||
[[8],[[8,[10,10,9]],3],[4,[],[1]]]
|
||||
[[4,[6],[5]],[],[[10,0,3],10,5,3]]
|
||||
|
||||
[[],[[[10,2,6],[1,4,9,2,5]],[],[5,2],[1,3,5]],[[[7,2,2,0],[0,1],10],10,[9,[4,8],[8,2,10],[1,4,2]],7,[[2]]]]
|
||||
[[],[[[],[],[9,10,5,6],2,[0]],10],[[],[[4,9,3,7],7,4],[],2,2],[8,[6,8,[7,5,5],[2,4,8,0,7],[3,1,7,3,9]],[[9,1,5,1],[5,1,1],[],[2,1,2,1]],[[0,9,1,10],5,[],10,[5,0,10,2]],[10,[3,4,8,8,4],5]]]
|
||||
|
||||
[[[[8,6,7,6,1],[4,2,7,1,3],[]],[]],[[7,[3,10,6],[3,6,5,8,0]],0,[],0],[6,[6,8,[5],4,2],7,[[0],5]]]
|
||||
[[6,5,6,10],[[[1,3,3]],1,2,[[5,0,10,2,10],[4,7,7,0],2,[2]],7],[[2,4,6,6],9,[[0,1,9],[10],9,[2,7,6,5,2],3],3,7],[[[8,4,6,1,1],[9],2]]]
|
||||
|
||||
[[6,1,[],1],[[],[[],3,8,[6,1,10,9,2],[7,0,1,10,2]],[]],[9,[6,9,[4,10],7],1,9]]
|
||||
[[[],[[]],5,[[7,8],[3,0,9,2,0],7]]]
|
||||
|
||||
[[[],[[2,6],6],[],10],[],[[[6,6,10,2,8],[7,4,2]],[8,4,7,5],[5,[6,10],[]],[3],8]]
|
||||
[[[],6,3,[[3,4,8]]],[1,3,[5,4],[[4]],2]]
|
||||
|
||||
[[],[[[5,10],6],2]]
|
||||
[[[7,[3,9,2],[],1],[3,7,[2,9,0,0],[3]],9],[[],[[4,10],4,[],[10,3,7,3],[10,0,7]]]]
|
||||
|
||||
[[9,7,5],[3,4]]
|
||||
[[],[],[5,8,[[8,3,2],[6,1,0,7],[],[9,0,9],[8]],2]]
|
||||
|
||||
[[[4,4,0,6,[8]],[1,[2,0],[4],[5,6,0,4,9]],3,[[6,1,7,7,4],[],[6,9,9,10,10],[4,3,9,3,4],[1,2,1,3]],1],[5,6,8,[],3],[[[9,3,10,3,3],9,[3,8,9,10,10]]],[[[5],6]]]
|
||||
[[],[[5,1,5,5],0,[7,3,[6,6,9],[10,5,6],[0,7,4,2]],1],[4,1,[[6,2,8,1,0],[8],[5,4]],2,6],[[[8],7],[1,1,7],[[5]]]]
|
||||
|
||||
[[[[],4,[]],[[3,3,7],[3,4,10,1,9],2],[[5,8,9,5,7],[4,3,4,9],9,1],5],[[[6,7,6,10],[2,4,0,3],5,[0,0,8,6,8],8],[2,8],10]]
|
||||
[[[4,[2,0,6,6,7],[8,4,8,5,2]]],[[],2,[5,[],3,[8,10]],[],2],[],[],[[0,[4,9,2],[5,5,1,5],10,6],8,[10,[1,8,4,7]],[[0,1,5,5,2]],[]]]
|
||||
|
||||
[[[2],[[3,10,0,5],[10,3,10,8],0,[]],8,[10,6,[5,2,4,5],[1]]],[],[[],[7,[0,10,4],[6,2,7],1,[1,4]]],[7,[],[[7,9],3,3]],[8,[[],[1],8],3]]
|
||||
[[[]]]
|
||||
|
||||
[[[[0,1]]],[2,[10,[3,8,3],[3],[]],4,[[10,5,9,0],[5,2,8],[8,7,7,0,6],9],3],[10,[3,9,9,[7,4,0,9]],3]]
|
||||
[[],[[[5,8,0,4,8]],10,[5,[]],9],[[[8,1,6,4],5,4,[8,9,0,5]],1],[],[[[],7]]]
|
||||
|
||||
[[[8],6,[3,[0,10,2],5,7,[2]],[10,9,7],3],[[[7,0,10,8,4],[6],7,8],[[7,4,7,6]],[[1],[4],2],[],[3,[4]]],[10,[]],[0,[[2,3,10,5],10,[10,10,0],[5,0],[8]],8,[[8,2,2],4,[],[0,3,10,4]]],[0,[10,[4,2,4,2,2]],8,[[9,1,2],5,[9,0,8,3,4],6,[10,3,4,5,2]],1]]
|
||||
[[[],[9,8]],[],[[[8],3,[0,1,6],[1,3],[9,8,9,8]],7,[[3,1],[2,0,1,6,10],4],5,[0,[0,6,1,5],[8,8,2,8,6],6,7]],[[8,6],9,8],[]]
|
||||
|
||||
[[[10,[3,4,1,1]]],[[],9,8]]
|
||||
[[1,8,8,4,[6]],[]]
|
||||
|
||||
[[0,0,6],[2,6,[[],[0,2],10,[10,9],2]]]
|
||||
[[1],[[[3,4,1,10,4],[7,10,3],[],[3,10,10,0]],[],4,[[0,5,0,0,9],6,[7,4,8,10,3]]]]
|
||||
|
||||
[[[],[0,[9,9,5],[4,6],[1,7],[1,3,6,10,1]]]]
|
||||
[[],[],[0,[9,6],[2,7,[4,6]],[[2,5],10,[3,0,10]],0]]
|
||||
|
||||
[[],[8,[2,3,[0,6],7]],[]]
|
||||
[[2,7,2,[0,[2,6],[],3,[9,3,9,6]],8]]
|
||||
|
||||
[[[[5,8,8,10],1,[10,8,10,5],[5,2,0],[0,7,0]],[]],[[[10]],[],10],[[],[],6]]
|
||||
[[[3,[2,1],[],[],[]],0,3],[[],8,[],1,[7,0,[2,3,1,9],[9,0,4,6,2]]],[[[0,9],7,9,2,[4,3]],5,[3,[5,3,6],[],[]],[[7,10,0],[9,5,6],[0,8,4,1],[5,4,8],1]],[],[[[9,4,6],[9,4,3,8,5],4],[7,[6,2,7,3]],4,[]]]
|
||||
|
||||
[[7,[[7,10],[0,1,3],[2,7,4,10],7,[1,2]],9],[[[],[10,6,3,4],[10,7,1]],[[],[10,8,10,6],[7,7,3,6,0],[7,5],[1,8]],1,0],[[],1]]
|
||||
[[],[[8,5],7,10,[10]],[[[],[4,0],[10,0,0,2,1]],[[9,7,9,9,0],9,9,[6,5],[4,9,7,3,10]],1,[[8,2,8,9]],0],[0,[[],10,0,3,3],5,[]]]
|
||||
|
||||
[[],[7,[0]],[9,[3,[7,3,9],1,[8,1,5,3,6],[]]],[10],[2,5,7,6]]
|
||||
[[],[4,[],10,8,[9,7]],[8,10,9,[0,10]]]
|
||||
|
||||
[[[],[],[2,[7,8],10]],[[],[2,[8,6,2],3,[7,3,9]],8],[5,[[1,7,2,6,6],0,6,[8,0],[6,10,0]],7],[]]
|
||||
[[4,3,[[6,6]],0,7],[[[4,0,2,9]],[4,[1,10,9,5],1,[],[4,4,2]],[1,[],[4,5,5,0,8],[9,5,10,7],7],8,2],[[[7,0],7,2],8,[],[[5],1,0,[0,2,6,7],[5,6,5,5,2]],8],[8,1,[6,4,[5]],0,[4,9,[],[4,3,0,3,8],[]]]]
|
||||
|
||||
[[9,[[5,10,9,4],4],7],[[9,[],2,3,[2]],5,0,[[4,10,1,7,6],4,7,9],[4,[6,4,3],[6,4],[5],8]],[[[0,10,1,4,9],6,[9,2,1],[5,2,3]],[],[9,0,[1,0,9,6],[2]],[3,[9,2]],[10,[5,7,5,2,1],10,9,3]]]
|
||||
[[0,[[4,2,5,8],[8,7,9]],[6,0,10],9,[[2,9,1,9,3]]],[3,[2,[0,0],[4,3,0]],[1]],[],[3,[[5,1,3,2],7,2]]]
|
||||
|
||||
[[[[9,5,5,1,1],10,7],[[3,9],9,[8,6,3,6,1]],[],[[2]]],[[1,[8],4],[10,10,3,3]]]
|
||||
[[[[3,5,8,1],9,[6,6,3,3,2]]],[3],[7]]
|
||||
|
||||
[[[[0,10,1,4],4,[3,8],7],0,2,[[5,2,4,0,6],[7,5,9],[],[2,2,2,6,8],[6,9,9,3]]],[5,4],[],[[0,5],7,7,7]]
|
||||
[[10,[[5],[10],6,10,3],[[4,10,2],0,[10]],8],[[[],4,[7,6,6]],5,[3,3,[0,7],8],2,9],[]]
|
||||
|
||||
[[3],[[]],[10,[1,1,[2,10,1]],[[1],2,[0,10,4],4,6]],[],[8,[3,5],[10,0,10,4,[]],[[0,4,6],3,3]]]
|
||||
[[[],[[0,7],7,4,[0,6,1],[8,3,7]],5,3,0],[],[[5,7,10,2,4],[],7,6,[]],[4],[]]
|
||||
|
||||
[[0,1,9,[[8,0],[9],[4,0,4,5,1],[4,10,0,6,2],[9,0,0,8]],9],[9,[0,[8,10,7],10,1,8],[7],[0,5,[10,4],8,[]]]]
|
||||
[[0,9,8],[5,8],[0,[2,8],6,[],[[8]]],[[[1,8,4,4]]],[]]
|
||||
|
||||
[[[[0,7],10],[[1,10,4],[2,9,2],[9,9,3,6]],5,4,6],[[7],9],[[],[],[[0]],2]]
|
||||
[[[[],5,10,3],[0,7,2,1,[9,1]]],[],[[[8,5]],[[1,5,1,7,2],[8,6,1,7,9]],2,7],[]]
|
||||
|
||||
[[[6,[9,5],[3,8,5,2],1],[[9,0,6,0,4],10],[[6,8],[6,6,6,8],6,[],0],0,7],[0,5,2,[[6,10,2,4]]],[[7]]]
|
||||
[[2,[2,[]],[[3,9,1,4,3],4,9,[5,0,6]]],[9,[[6,10,6]]],[10,[10],[0,5,[6,9,2,4,6],[8,6,6],[4,4,7,0,10]]],[5,[]]]
|
||||
|
||||
[[[[]],[],[[8,9,9,10,7]]],[9,[4,[0],[2,2,7,6,7],5,[1,2]],8],[[[7,6],[4,5,6],[5,4,9,2,2]],2,2,2,[[4,3,8,6],[0,10,4,0,0],[7,1,4]]],[[],[9,10,9,[2,6,1,2,5],[5,9,5]]],[[[5,10,10],0]]]
|
||||
[[[]],[],[]]
|
||||
|
||||
[[[5],5,1,6,[[10,0,5],[6],[5,0,10]]],[],[[8],[[9,0,3,4],0,[4,6,1],[1,1,2,2],7]],[3,7,3,7,0]]
|
||||
[[[6,5,[2,7,3],3,[]],[[4,1,10,1,10],[]],2],[[[4,5,7,8],7,[6],7,4],[[4,2,3,2]],9,[[9],[],6,7],1]]
|
||||
|
||||
[[[4,[2,4,10],[],10,[10,0,7]],[5,[],10,6,2],[[0,6,7],3,0,9,[5]]],[4],[3,7,2],[[9,0,[2],[4,10,9,4]]]]
|
||||
[[[6,10,8,[],[3,0,9,3,0]],1,[[],[8],7,[8],[]],[10,1]],[[[2,9],[10]]],[2],[9,[]]]
|
||||
|
||||
[[],[[]],[7,4,8]]
|
||||
[[[9,[7,6,5,0,4],8,3]]]
|
||||
|
||||
[[[4,3],7,9,4,10],[[9,[3]],5,[6],[[],[4]]],[[9,1,5,[7,0,4],9],[3,8,0,0],[8,3,2,7],3,[6,3]],[]]
|
||||
[[[[10,3,4],5,4]],[[[1,1,3],[1,4],6],[[8,7,9,6],[4,10],6,[9,6,3],[]],[[8,2],1,8,10,8],6],[[8,[6],5],[[5,3]]],[[1,[9,5],0,[9,7]]]]
|
||||
|
||||
[[[5],2,7,[[],[10,10,0,5]],[]],[[[6,8,5],[1,6,0],6,[10]]],[[[0],[6,8,7,0],[4,8,9,10,8]],[[],[10,6,1,0],3,[4,1],3]],[9,[[],[],3,1],7,[[8,1,10,10,9],[3,8],[2,4,8]],0]]
|
||||
[[]]
|
||||
|
||||
[[[7,[]],[3,[1,9,1,9,0]],[3]],[]]
|
||||
[[2,6,[[],3,6]],[7,2,2,[[0,9,5,9],[7],9,6,6],10],[],[8,2,[4,[4,3]],1]]
|
||||
|
||||
[[9,[10,[8,1,0,9],[2,4,6,4,6],[4,4,1]]]]
|
||||
[[5,3,[[2,0,3],[1,1],[7],7],[[],0],[[0,4,8,3,9],4]]]
|
||||
|
||||
[[[[4],8,3,6,6],[[],6,[6,8,4,7]]],[0,9],[],[[[],4,[8,4],[2,7],[7,1,10]]]]
|
||||
[[7,8,[[1,5]]],[6,1,7,[8,10,9,[]]],[],[[[2,7,0,8,10]]]]
|
||||
|
||||
[[9,[1,[7,6],10,10],3,[],[[]]],[]]
|
||||
[[[[0,0],3,[0]],10,6,6],[],[[[2,0,3,8],4,0,3,[8,6,6,5,3]],[7],2,[[9,7],[],2,[0,6]]]]
|
||||
|
||||
[[[5,[0,0,3,7,6]],7,10,5,[[5,4,4,3,10],[4,5,2,0,0],0]],[],[[1,0,4]]]
|
||||
[[8,[[5],[],5,8,[9,10,4,1,8]],6],[8],[[],9],[],[7,[],[]]]
|
||||
|
||||
[[[8,[8,6,7]],[5,0,9],4,[7,10,6,[1,4,1,1],3],[6,[3,2,8],10,[9,4],[4,3,3,8]]],[],[1,[[9],0,2],9,[6,0,0,4,[1,3,7]],[3]],[]]
|
||||
[[0,[],6,[8,[0,2],[0,6],[7,4,1]],10],[8,[4,3,[9,10,0,4,7]],0],[[],0,7]]
|
||||
|
||||
[[2,[[],[4],4]]]
|
||||
[[6,[8,[0,7,0,3],2]],[6]]
|
||||
|
||||
[[[0,0,[0,8,5],[4,2,4]],[7,[2],[0,4,9,5]],7,[[1,1,4,3]]],[],[],[]]
|
||||
[[[4,[]],6]]
|
||||
|
||||
[[],[[0,10,1]],[[]],[4,[[6,7,6,1]],[3,3,[],7],[[5,6,8,6,8],[8,7],[1]],0]]
|
||||
[[[5,4,[8,3,7],[2,6]],[]],[],[0],[1,6]]
|
||||
|
||||
[[2,[7],[9,0,1],1],[10,[5,[10,9,2,8],8,[8,0,0,10,3]],3,[[7,5,9]],9]]
|
||||
[[6,8],[5],[[[3,0],[],1,6],[[3,0]],3,8,[[6,5,1,8,8],1]],[1,8,2,[[]],4]]
|
||||
|
||||
[[[[9,7,2,6,7],6,3],4,[[6,4,9,7,3],4],[10,0,4,[5,2,4,6,3],[6,6,4]],2],[[9,[3,9],[4,2],[5,0]]],[[0,[6,10,7,2],[7,7,3]],5],[0]]
|
||||
[[[[9,10,9,0],8,[2]]],[9],[1,10,[3,[]],[8,[8,2,6,6],[3,8,4],0]]]
|
||||
|
||||
[[8,3]]
|
||||
[[6],[3,[5,6,0,10,4],7,[[7,2,2],[]]],[],[3,[1],[2,[]],[9],3],[7]]
|
||||
|
||||
[9,1,9,8,2]
|
||||
[9,1,9,8]
|
||||
|
||||
[[[10],[8,0,[]],10,[[6,3,8,8]],[9,5]],[0,9],[[10,[2,3,5,4,10],3,[],[0,8,2,4]],[[7,9,4,7],[8,6,0]]]]
|
||||
[[2,[8,[5,0],2,9,[9,6,4,2,7]],2,[[]]]]
|
||||
|
||||
[[],[7,[9,2,[3,9,2,4],[1,3],[0,10,4,3]],6],[],[[],2,9]]
|
||||
[[8,10],[1,[[10,8]],[],0,2]]
|
||||
|
||||
[[9,[[],[1,2,2],0,1,[5,4,5]],[0,3,[0,8,4,6,3],[2,5,6,2],[9,5,9,0]]],[2,[6,[],4,9],8,[7]],[5]]
|
||||
[[[[2,4,6,4,0],[2,9,4]],5,10],[2,[6,10],6,[],[3,2,[6,6],[1,5,10],[]]],[[6],1,5,9],[[7,7,6],[6,[]]],[[7,9,10,[9,3,2],5],[[5,8,1],[4,1,6],[1,5,3,0,9]],2,8,5]]
|
||||
|
||||
[[[[3,0],[10,8,0]],1],[7,[4,[0,5],0,[],[1,0,7,2,8]],[[],[7,5,1,1],[0,8],[7,6],[10]]]]
|
||||
[[[],8,2]]
|
||||
|
||||
[[7,[[1],[],6,[2]],[[4,5,4,8]],[]],[0,[[1,8,4],10,[2,3,2,3,4]]],[[10,[1,5],[9,3,1,1,6],4,[]],4,9,[[5,9,2,10,10]]],[7,4,[[1,3,9],0,[7]]],[4]]
|
||||
[[0,7,4,[6],[]],[[0,[0,2],3,[4],[1,1,10,3]],[1,5,9,6,2],10],[[6],[8],[[1,10,3],[7,5,7],1,[5]],[]],[]]
|
||||
|
||||
[[1],[6,[2,0,10],[[8,7],7,[3,9]],[1,[0,8,10,8],9]],[5],[6,[3,1,[10,10,10,9,5],[9],0],0,[[9],[]]]]
|
||||
[[5]]
|
||||
|
||||
[[10],[]]
|
||||
[[[1,3,7,6]],[9,9,[0,[10,2],2,9,4],6],[],[[[7,10],[5],4,8,[5]],8,2]]
|
||||
|
||||
[[2,[],2,6],[10,9],[2,8,2]]
|
||||
[[[[9],3,3],2],[[0,[]],2,3,[[3]],[5,6,3,[4,2,7]]],[10,[8,8],8,5]]
|
||||
|
||||
[[[[8,1,8],[5,8],6,9],7,2,6],[[2],5,[[],[8,8,0,0],4,[1,4,10,10,4]]],[1,10,[9,4,[]],[],9],[6,8,[[10,2,0,10,10],5,4,[2,6],3]],[[6,0,[6,4],3],[[0,4,6],7],2,[6,[]]]]
|
||||
[[4,[[5,5,0,1],[8,9]],0,[2,[]]],[6,9,[[9,10,6,7]]],[[],8,[],0],[[],[[1]],[],5,[[6,6,0,2,2],[9],9,[7,3,4]]],[[[3,10,4,4],1],[10,[2]],[1,[6],5,8,4],[]]]
|
||||
|
||||
[[],[1,9,[[],6]]]
|
||||
[[1,[[9,1],[6,3,1],[1,10,9,2],[4]]],[2,3,[2,8,7],3,8],[8,[3,1,[],9,0],[5]],[[0,4],7,[[10,9,1,4,2],0],[[3,1,7],4,[10,8,7],[0]],2],[10,[9,7,[10,3,2,2]],[[10,5,4],[3],[4]]]]
|
||||
|
||||
[[[9,8,8],[0]],[[],2,1,3],[4,[[]],[8,[4,0,6],7,2,[2,1]],[0,8,[5]],[5,9,[],5,6]],[4,[1,[6,7],1],10],[1,[1]]]
|
||||
[[7,[[2,3,0,5,8],7,[],8,[]]],[[0],0,[[2],[0,0,2],[1,0]],4]]
|
||||
|
||||
[[[[1,8,6],[4,1,6,4],8,[7,7,8],3],[[2,1,1,8],0,10,7,[]]]]
|
||||
[[[[9,10,7,1],8,0]],[[]],[4,[2,0,[4,2,10,8,0]],[],[[10,9,10,7],5,5,1,0]]]
|
||||
|
||||
[[4,7,7],[],[[0,[10,7,3,8],8,[10,0]]],[[9],0]]
|
||||
[[[2,[9,7],[4,2,8,5]]],[[[6,7,4],2,1,[4,1,8],[6,10]],[[4,10,6],[6,2]],[],6,[4]],[[3,1],[[5,10],3],[0]]]
|
||||
|
||||
[[[[7,0],1,[0,10,4,0],[8]],0],[],[2],[10,[[0],[10,1,0,4,1],5,10,4],9,7]]
|
||||
[[[[]],[[],[7],[],[5,5,5],[8,7,1]],3],[[[9],[],3,4,[7,5,2]],[0,[7,8,0,4,8],[2],[8,4]],[]],[7,[1,9,[5,9,0,4],[]],[[7,8,10,5],[10,6,10,9],0,9,6],[6,4,[]]]]
|
||||
|
||||
[[9],[[[9,9,7],0,[1,10,4]],8,[[1,9,4],[4,10,2,4],[5,6,9,9,8]]],[[],[7,[1]],[4,10,1,[],[1]],[[4,10,8,4],[9,4,8,1,0]]],[10,10],[[[0,4,3],[5,8,4,5]],[],[1]]]
|
||||
[[[1,[],4,[10,1,7,4,0]],7,[[6,8,9,10,9],[4,10,2],[1,5,3,3,10],6],[[5,2,5,9],[8,8,9]]],[[0]],[10,[5,[9,3],2],[],[0,7,[9,10,3,5,9],1,1]]]
|
||||
|
||||
[[7,[],0,[[4],[9,1,10,9,0],[],8],[3,[1,8],7]],[1],[]]
|
||||
[[1,[3,6],[5,3,0,5,4],5],[[[8,3,1],2,[10],[],7],[1,[4],[6,10,0,8,6]],[[1,10,7,4],8],10],[5,[5,3,6],6,1]]
|
||||
|
||||
[[4,1,6,7,8],[],[4]]
|
||||
[[[],[1,3,8,7,5],1]]
|
||||
|
||||
[[],[],[[3,[7,2,5,0],5],[4,[3,10,9,4,1],5,6,[7,7,10,0]],7],[9,8]]
|
||||
[[[],10,2,[[9,9,8],0,[8,2,3,9,1],[5,3,4],1],[2,7,[1,8,0,6],[8,8]]],[[[7],[4,5,7,8],5,7,5],7],[[6],5],[[[3,0,6,4],10],8,[],[9,[]]]]
|
||||
|
||||
[[[],3,[2,[],[8],4,[9,5,9,9,4]],[[],[0]],[1,5,[4]]]]
|
||||
[[[2,4,1,[3,5,6,2],9],4,[1,1,[],[3,2,7]],4],[[],8,4],[3]]
|
||||
|
||||
[[[[0,6,8],[8,7,7,10,4],[1]],[[2,7,3],3]],[],[]]
|
||||
[[4,7,4,6,[0]],[[[6,9,2,5,8],6,[7],10],4,1],[[[4,5,5,2,9],6,8,9],[[1,6,4,3]],7,[]],[[[4,4],[3,6],[5,9,7],4,6],2,5,6]]
|
||||
|
||||
[[[0,[9,4]],8,[8,10,8,[8,10,8]],[8,[3,9,6],10]],[[10,[7],8],2],[],[]]
|
||||
[[1,3,[10]],[4,1],[0],[[0,10,8,6],2,[[7,3]]]]
|
||||
|
||||
[[[0,[0],3,[3]]],[],[7,4]]
|
||||
[[6,[],9,[[2,10,8,6,2],[6]],[[2,10,0,0,6],7,5,[8,1,10],9]],[[[],[3,1,1,1],[9]],7,1,7,[]],[],[1]]
|
||||
|
||||
[[1,1,[]],[8,2,9,5],[[6,8,[10,6,9],[9,1,4,8],[3,7,0]],[]]]
|
||||
[[[10,[9,5,9],9],[4,8,0,4,[5,4]],9,[4],0],[[6,[0,2]],10,5],[],[[[1,5]],4,[3,[1,4,4],[7,10,5,6],6,0]],[]]
|
||||
|
||||
[[8,6,[],7],[[],[],3,[[2,4,6]],[[3,9],5,[8],[6]]]]
|
||||
[[6,[[10,9,9],6,[1,1,8,1]],[[4,6,10,3,1],[4,2,10,1,9],0,1],[[]]],[6,[[1,7,0,8,5],[5,2],[4,8,7,10],[4,4],[4,6,4,10,9]]],[[8],[[6,4,10,8],[3,9,9],[5,4,5],[3,4,10,5,6]],6,[0,[2,5,0,2,0]]]]
|
||||
|
||||
[[8,[4,6,[1],[9,6,3]],[7],10,7],[10,3],[[4,1,[8,4,8,7,2]],1,10]]
|
||||
[[[[9,7,8],4,[2,6,6],3,7]],[8,0,10,[[1,5,3,6],4,[],[7]]],[[]],[[[7,10]],0,2,8,[[],[7,4,8],6,4]]]
|
||||
|
||||
[[4,[[5,3,9,4,0]],4,[[],[3,9,3,1,1]],10],[[3,[7,3,9]]],[[5]],[[[1,8,4,0],[5,4,5],[10],6,[7,10,9]],10,[3],[5]]]
|
||||
[[],[8,4,10],[2,3,[10],7],[[[9,1,2],5,6],[],6,6],[[[7,9,10,0,7]]]]
|
||||
|
||||
[[0,6,5,[3]],[9,[],[]],[],[[1,9,[2],8]],[[[3],[7,4,4],[]],[6],[[7,5,2,1],[9,5,8,0],[4,5,10,8,5],9],2]]
|
||||
[[10,[[2,7],0,[4,10]]],[0],[[],9],[6,[[10,1,5],[0,3,8,0],10,[3,10]],0,5]]
|
||||
|
||||
[[4,7,6,[[10,4,1,8,3],6,[4,4,7],8]],[4]]
|
||||
[[6,[[5,8,8,10],[7,2],1]],[[[1,10,9],[2,1,8,6],[6,10]],[4,2]],[0,[[1],10,[1,7,4,6],3,2],3,[0,4,[]],[[9],[3,3,5,9],5]],[[5,8,4,[0]]]]
|
||||
|
||||
[1,10,7,0]
|
||||
[1,10,7,0,7]
|
||||
|
||||
[[[],6,[[8,7,7],[]],[],[[1,0],4,10]],[6,[[6,0,1],[2,5,3,9],[1,3,7]]],[4,7,[4],[[3,7]],7],[[10,9],[9]],[[[7],8,[],[6]],[[4,10,4],[]],1,[0,4,[5,4,1,4,6]],6]]
|
||||
[[[],[3,7]],[3],[],[[],[[4,2,10],[2,2,2,9],[8,5,0,7]],0],[[[8],[4,10,7,4]]]]
|
||||
|
||||
[[[],[4,3,[8,9,4,2],10],[3,6,5,[]],[]]]
|
||||
[[6,5],[[8],1],[10,[2,1],0,3],[[[0,3,1,8]],[],0,4,[3,3,6,[5,3,8]]],[[7,[5,10,2,7,5],10],[[0,2,7,4],2,[8,10,10,0,6]],[[5],[],[0],[]],[[9,0,6,9],9,1,[9]]]]
|
||||
|
||||
[[[4],[3,5,9,[]]],[6,10],[9,[[6],[],[2],[2,1]],0,[]]]
|
||||
[[[1,0,9,10,[9,5,1,2]],[],0,[[6,1,8,9,5]],[[],2,7]],[[10],7,[9,[1,5,8],[8,7],4,3],[2,[5,3,9,8,2],4]],[2,7,[[6,10,6,2,3],6]],[[[9,4,4,8],4,0,[3,7,2,8]],[[],8,[]]]]
|
||||
|
||||
[[4],[[[1,3,2,8,10],[],[0],5,[2,6]],[0,[5,0,10]],[],9,1],[],[[[0],9],[[3,0,8],1],5,[3,[1],[4,3,6]]],[8,1,[0,[4,7,3,0],[3,1,1],5,10],10,6]]
|
||||
[[[5,9,[7]],9,6,[10]]]
|
||||
|
||||
[[5,[[2,9]],[[6,0,3,10]],3,4],[3,4,8],[9]]
|
||||
[[3,[],3,8,3],[1,6,[[10,2],[2,4,10]],7,[]],[4],[[],[],4,3,8],[[],3,0,6]]
|
||||
|
||||
[[4],[],[[[1,5,0,10,1],10,5,3,[9,3,7]],[6,4],8],[]]
|
||||
[[],[0,1,[4,0,3,1],3,5],[10,[[4,9,2,8]]]]
|
||||
|
||||
[[[8,[3,4]],7,[]],[[8,3,4],[7,[5,0,3,3,0],[10,5,6,10],1],[5,1,[8],10,9]]]
|
||||
[[1],[9,4,[4,[2,1,8,2,6],7,[]],[0,7,4],[]]]
|
||||
|
||||
[[[[1,7],[10,7,2],8],4,[[5,10],3,[6,7,8]],[[0],2,6,8],3],[9,[[4,10,2]]]]
|
||||
[[[10],7,[[],[],0,1],7,[]],[]]
|
||||
|
||||
[[[2,0,[0,8,10,3]],0,2,[9,0,[0,2,7],[10,2,2],7],[5]],[],[[8,1,10],2],[]]
|
||||
[[10,7,2,2,[]],[[[2,2,6,2,5]]],[],[9,8,7]]
|
||||
|
||||
[[5,5,[[10,1],[]]]]
|
||||
[[9,2,3,[8,3,[0]],0],[[[10],[10,8],10],6],[[[1],[7,8,1]],4]]
|
||||
|
||||
[[6,[],6,6],[[]],[1,[[9],9,6]]]
|
||||
[[[[]]],[3,6,7],[7],[3]]
|
||||
|
||||
[[8,10],[[0,8,4,9,5],[6,4,9,[5,8]],8,[10,[9,9,6,5],[1,7,1,0,10],2,5]],[1,8,[1],8,7],[]]
|
||||
[[[0,2,3,[8,2,8,1]],[8,8,1,[4,10]],2],[3,8,3,2],[6,2,[],2]]
|
||||
|
||||
[[[[1,2,4],0,7],[4,[8,9,3],[8,3,3,0,3],[6,2]]],[8],[]]
|
||||
[[],[[[9,2,7,9],[1,4,1],7],[[6,8],5,[6,7]],[6,3,[0,1,3,8,0],[]],[[]],1],[5,5,9,6],[1]]
|
||||
|
||||
[[5,8,[10,5],[6],[]],[[10,6,[0,5],10]],[6,[],[],9,10]]
|
||||
[[7],[[[6,5,1,5],[5,10,0,5],6,[]],9],[],[5,2,[2,4,[5],1]],[5]]
|
||||
|
||||
[[[4,[0],2,[2],[8,2,9,10,10]],[0]]]
|
||||
[[4,3,[[5,9,9,9],9,[0,10,5,6],0]],[[2,5,7,[2,10,5,9,9]],3,[10,[4]],9,1],[[[10,9,1,8,3],6,[2,6],[5,6,10,3],7],5,[2,[2,9,0,4],6,0,[5,8,8,1,0]],[[7],[4,3],[10,8,5,0,4],[8,4,4,7],5],1],[[[],[3]],[[9,5,2,1,1],[5,9]]],[3,4,7]]
|
||||
|
||||
[[10,9,10,3,[]]]
|
||||
[[[[],[8,7,7,5,8],6,[7,7,8],[3,2,5]]],[4,6,[[4,1,0,6],4,[10,8,6,2,1],4]],[],[[[6],[],6],10,10,2],[6,[[1,5,10,5,9],6],[[4],5,[10,10,9]],10,9]]
|
||||
|
||||
[[9,0],[],[[5,[],[4,5]],8]]
|
||||
[[7,[[1],6,5,4]],[[6,0]]]
|
||||
|
||||
[[[[9,1],[6,5,2,8,8],2,2,7],[[5,3],[8,1,4,9,1]],4],[[2]],[6,4,0,7,3]]
|
||||
[[[4],[],[0]],[5,[[7,0,5,0,4]],4,8]]
|
||||
|
||||
[[1,[[7],[],5,5,3]]]
|
||||
[[],[5],[[8,[5,4,8],[]],3,[3,[10,1,2,2],[7],9],5,0]]
|
||||
|
||||
[[3,[1,8],6],[9]]
|
||||
[[1,[[3,9,7],4,[4],4,[]]],[[8],[[0],4]],[6],[1,10],[[0]]]
|
||||
|
||||
[[1,0,[[7,4,4,8],[],[8,2,3]]],[4,9,0,[[3,3],3]],[3,[]],[1,10,0,9,[3,8,[9]]]]
|
||||
[[[10,[5,4,2,1],4,[9,3,8,4]]],[[4],1],[]]
|
||||
|
||||
[[4,10,4,1],[[1,10]],[[6,[1,7],[8,0],6],1],[5,[[],[3,4,2]],[]],[9]]
|
||||
[[[[3,6],[4,4,0,6],6,[4,4,8],[6,8,4,9]],[10],[6,[6,1,6,7]],5]]
|
||||
|
||||
[[[[0,8,1,4],[],7,4,[3]],[5,7,3,[6,6]]],[[[],[4,3,4,0],7,4],[3,[2,4,2],[]],[[4],7],6,[]],[0,[1,5],10,[[6,10,7,3]],[6,[]]]]
|
||||
[[[[8]],8,2,[[0,7,7,4,1],[7,9],[],[],4]],[[6],[]],[[],9,6]]
|
||||
|
||||
[[[],[0,[4],10,[4,9,10],3],2,4,[]],[7,1,[10,10,5,10,2],7,[0,9,[6,4]]],[[[],5],9,3,7,9]]
|
||||
[[[[6,1],2,[6,4,10,3]],[10,[],8,4,[0]]]]
|
||||
|
||||
[[[[6,2,7,2],[4],[5,2,0]],[[0,2]],[[3,7,10,8,5],[],[2],4,8],4]]
|
||||
[[[],[8,[0],7,[5,6,3,7,3]],6],[[],[[6,10],2,[3,1,7,6]],[6,[]],[[]],4],[[0,[1,8,10,2,5]],3,10,[9,9,[],8],10],[6,7,[[4,9,10,8],1,[]],1,[[8,9],[],1]]]
|
||||
|
||||
[[5,[5,[9,6,1,9],[7]],6,[],[]],[10]]
|
||||
[[[[9,1],[8],[2,6],[10,4,1],[2]]],[10,0,9,[0,[9,2,5,3],7,4,1]],[7,[[1,1,4,1,2],[10,5,6,9,6],[6,9],6,3],[]]]
|
||||
|
||||
[[2,[[4,7,2,8,9],5,4,2,[2]],[[7],[5,6],3,[]]],[9,6,6,[2,2,8,[],[0,3,6,4]],[6,2,8]],[[[2,1],2,[8],[0,5,7,9,10],10],0,[],1,[6,3,10,3,[]]],[[1,9,9],[[10,3,7]],3,[4,[6,3,1],[],[9],6]]]
|
||||
[[3,2],[],[[],0,[[2,3,9,4],9,[6,6,1]],[[10,5,1,4],4,2,[5]]],[[[1,0,4],[5,4,4,1,2],[1,6],[4,5],[]],[[0,6,3]],[5]],[]]
|
||||
|
||||
[[6],[],[0,[7],[],8,0]]
|
||||
[[],[[8,[8,0,0,4],9,7,2],[[2],[9],[1,8,5,0],[5,5,7,3]]],[9],[[],[9,10,[5,5,4,7],[5,1,2,0,5]],[[1,0],10,[5,10,1],9],0]]
|
||||
|
||||
[[8,[[3,0,2,2,7],7,7,[0,3,0]]],[[[0,3,4],[9,7,0,4,1],9],[[3,10,10,4]],8,8]]
|
||||
[[3],[4,6,6,10,[]],[[[7,1,5,10],[5],[10,3],5],6]]
|
||||
|
||||
[[10,8,[[3,6,9],10,0],7,2],[[],[]],[6,[[]],[]]]
|
||||
[[[[9,10],7,4,0,[6]]],[5]]
|
||||
|
||||
[[1,[]]]
|
||||
[[[2,8],7,[[10,4],10,[]]],[[[],[2,1],[10,6,2,7],[9]],[[],3,[],[6,4,3,6,3]],[0,[4,8,3,0,5]],8,3],[2,[[5,10,5,0],[6,4,8,4],3,[3,10,5,3],[6,5,3,8,7]],[[10,8,9]]]]
|
||||
|
||||
[[[[],9],2,2,8],[3,[[],[10,1,1,4,2],[0,7,3]],8],[[],[4]],[[[]],9,4,[5,[3,5,4,4],[],8]],[]]
|
||||
[[6,[8,3,[7],[9,6]]]]
|
||||
|
||||
[[[[],7],9,[],1,[[],10,2,9]],[[[8,1,6,6],0],2,5,5,[[8,6,5,3],1,6,4,0]],[[8],10,[],2],[[10,2,7,5,[10,3]],[[10,10],7]],[7]]
|
||||
[[10],[5,[1,[0,10,4,4,6],2,[3],7],9],[8,4,6,2]]
|
||||
|
||||
[[],[[3,6],[],0,[0,[1],[4,10],4],[[7]]],[8,[[2,8]],[[5,3,6,7]]]]
|
||||
[[[8,[1,1,6,7,1]],[],4],[[6,[],[6,7],[5],[5]]],[[[],0],5],[6,10,6,[]]]
|
||||
|
||||
[[[],[5,[9],[10,4],[1],7]],[1,[2,[10,1,9,0,6],5]],[[[2]],[],[[8,1,9,8,8],8,[],6,8]],[[[6,3,6,4,2],1,[4,6,6,10,9],8,[9,7,7,10]],10],[2]]
|
||||
[[4],[[],7,9,[[0,8,1,2],[9,8],0,[5],8]],[[8,[9,6],3,[5,6]]],[6,[5,[9,10,4,7],4],[],2,6],[[],8,[[7,7]],[6,0,[8]]]]
|
||||
|
||||
[[9],[1,[],2,[[],5,[7,9,2,1],[7],[]],3],[0,[],[[5,1,2,0],0,[10,9,10,6,10],[8,1],5]],[7,[[3,8,9,10],[0,2]],[2,0],9,[[1,3,9,3,9],[6,6,3],[]]],[4]]
|
||||
[[[6,3,7],9,[[1,3,5,8,10],1,[6,10,10,9],3,[1,7]]]]
|
||||
|
||||
[[],[[],5]]
|
||||
[[8],[7,2,10]]
|
||||
|
||||
[[6,[4,[3],[],[1,7,4,2,5],[3,10,10]],8,[],[9,8,[]]],[[0,0,3],[5,[5,2,5],4,[5,1,2,8,6],9],4],[[]]]
|
||||
[[1,10],[4],[[0],3,[[8],5,[2,6,10,3]]]]
|
||||
|
||||
[[],[8,5,9],[[[5],[3]],7,4,4],[8]]
|
||||
[[],[]]
|
||||
|
||||
[[8,[],0]]
|
||||
[[4,4,6],[9,5,[[3,8,4,5],5],9,[[5,3],[0,4,0,3],3,[4,10],7]]]
|
||||
|
||||
[[[[6,2,3,9,9],[4,1],10,[],3],[4,1,[8,5,5,8],[6,7,2],[4]]],[[[10,4,2,10,9],[2],[2,4,6],3],[[0,8,10],[4],[0,7,0,9,0]],[3]],[4,7,3,8]]
|
||||
[[[6,5,0],9,5,7,2],[[[],[],7,3,0]],[[7],[],4],[1,6,6,[],9]]
|
||||
96
ressources/day13.py
Normal file
96
ressources/day13.py
Normal file
@@ -0,0 +1,96 @@
|
||||
import json
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
|
||||
def parse(puzzle_input: str) -> list[list[int, ...]]:
|
||||
"""Convert str representations of lists into real int lists"""
|
||||
str_pkts: list[list[str, str]] = [
|
||||
packet.splitlines() for packet in puzzle_input.split("\n\n")
|
||||
]
|
||||
int_pkts: list[list[int, ...]] = []
|
||||
for pkt in str_pkts:
|
||||
int_pk: list[int, ...] = []
|
||||
for pk in pkt:
|
||||
# Here's the magick - I'm highly averse to eval()
|
||||
int_pk.append(json.loads(pk))
|
||||
int_pkts.append(int_pk)
|
||||
return int_pkts
|
||||
|
||||
|
||||
def compare(l: int, r: int) -> int:
|
||||
"""Compare 2 ints, return 1, 0, -1 depending on values"""
|
||||
if l < r:
|
||||
return 1
|
||||
elif l > r:
|
||||
return -1
|
||||
else:
|
||||
return 0
|
||||
|
||||
|
||||
def compare_packets(left: list[int, ...], right: list[int, ...]) -> int:
|
||||
"""Compare 2 lists to establish correct order"""
|
||||
match left, right:
|
||||
case int(), int():
|
||||
return compare(left, right)
|
||||
case int(), list():
|
||||
return compare_packets([left], right)
|
||||
case list(), int():
|
||||
return compare_packets(left, [right])
|
||||
case list(), list():
|
||||
for l, r in zip(left, right):
|
||||
res = compare_packets(l, r)
|
||||
if res != 0:
|
||||
return res
|
||||
return compare_packets(len(left), len(right))
|
||||
|
||||
|
||||
def part1(pairs: list[list[int, ...]]) -> int:
|
||||
"""Solve part 1"""
|
||||
sum_of_indices: int = 0
|
||||
for idx, pair in enumerate(pairs):
|
||||
if compare_packets(*pair) == 1:
|
||||
sum_of_indices += idx + 1
|
||||
return sum_of_indices
|
||||
|
||||
|
||||
def flatten(l: list[list[int]]) -> list[int]:
|
||||
"""Flatten a nested list one level"""
|
||||
return [item for sublist in l for item in sublist]
|
||||
|
||||
|
||||
def find_index(l: list[list[int]], item: list[int]) -> int:
|
||||
"""Return index of where item falls in list"""
|
||||
item_idx: int = 0
|
||||
for pkt in flatten(l):
|
||||
if compare_packets(pkt, item) == 1:
|
||||
item_idx += 1
|
||||
return item_idx
|
||||
|
||||
|
||||
def part2(pairs: list[list[int, ...]]) -> int:
|
||||
"""Solve part 2"""
|
||||
# Remove one layer of list to match flattened list above
|
||||
first_divider: list[int] = [2]
|
||||
second_divider: list[int] = [6]
|
||||
|
||||
first_pos: int = find_index(pairs, first_divider) + 1
|
||||
second_pos: int = find_index(pairs, second_divider) + 2
|
||||
return first_pos * second_pos
|
||||
|
||||
|
||||
def solve(puzzle_input: str) -> tuple[int, int]:
|
||||
"""Solve the puzzle for the given input"""
|
||||
data: list[list[int, ...]] = parse(puzzle_input)
|
||||
solution1: int = part1(data) # Correct answer was 4734 (with my data)
|
||||
solution2: int = part2(data) # Correct answer was 21836 (with my data)
|
||||
|
||||
return solution1, solution2
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
for path in sys.argv[1:]:
|
||||
print(f"{path}:")
|
||||
puzzle_input = pathlib.Path(path).read_text().strip()
|
||||
solutions = solve(puzzle_input)
|
||||
print("\n".join(str(solution) for solution in solutions))
|
||||
76
src/Day10.hs
Normal file
76
src/Day10.hs
Normal file
@@ -0,0 +1,76 @@
|
||||
module Day10
|
||||
( Instruction (..),
|
||||
parseProgram,
|
||||
signalStrength,
|
||||
executeProgram,
|
||||
draw,
|
||||
isSpriteDrawn,
|
||||
day10
|
||||
)
|
||||
where
|
||||
|
||||
import Control.Arrow ((>>>))
|
||||
import Data.List.Split (chunksOf)
|
||||
|
||||
data Instruction = Addx Int | Noop
|
||||
deriving (Show, Eq)
|
||||
|
||||
newtype Pixel = Pixel Bool deriving (Eq)
|
||||
|
||||
instance Show Pixel where
|
||||
show (Pixel True) = "▓"
|
||||
show (Pixel False) = "░"
|
||||
|
||||
|
||||
type CRT = String
|
||||
|
||||
parseProgram :: String -> [Instruction]
|
||||
parseProgram = lines >>> map parseProgram'
|
||||
where
|
||||
parseProgram' :: String -> Instruction
|
||||
parseProgram' "noop" = Noop
|
||||
parseProgram' line = splitAt 4 >>> snd >>> read >>> Addx $ line
|
||||
|
||||
|
||||
isSpriteDrawn :: Int -> Int -> Bool
|
||||
isSpriteDrawn x p = abs (position - x) <= 1
|
||||
where
|
||||
position = p `mod` 40
|
||||
|
||||
draw :: [Int] -> CRT
|
||||
draw registerValues = unlines lastPicture
|
||||
where
|
||||
pictures = zipWith isSpriteDrawn registerValues [0..]
|
||||
lastPicture = concatMap (show . Pixel) >>> chunksOf 40 $ pictures
|
||||
|
||||
|
||||
|
||||
signalStrength :: [Int] -> Int
|
||||
signalStrength e = start + sum computedRest
|
||||
where
|
||||
start = e !! 20 * 20
|
||||
rest = drop 20 e
|
||||
withCycle = zip [60, 100..] (every 40 rest)
|
||||
computedRest = [c*r | (c,r) <- withCycle]
|
||||
|
||||
every :: Int -> [a] -> [a]
|
||||
every n xs = case drop (n-1) xs of
|
||||
y : ys -> y : every n ys
|
||||
[] -> []
|
||||
|
||||
executeProgram :: [Instruction] -> [Int]
|
||||
executeProgram = scanl (+) 1 . concatMap execOne
|
||||
where
|
||||
execOne instruction = case instruction of
|
||||
Noop -> [0]
|
||||
Addx x -> [0, x]
|
||||
|
||||
day10 :: IO ()
|
||||
day10 = do
|
||||
input <- readFile "ressources/day10-input"
|
||||
putStrLn "Day10"
|
||||
let states = parseProgram >>> executeProgram $ input
|
||||
let signal = signalStrength states
|
||||
let crt = draw states
|
||||
putStrLn ("Signal strength: " ++ show signal)
|
||||
putStrLn ("CRT picture: \n" ++ crt)
|
||||
101
src/Day11.hs
Normal file
101
src/Day11.hs
Normal file
@@ -0,0 +1,101 @@
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module Day11
|
||||
( runMonkeyMachine,
|
||||
mostActiveMonkeys,
|
||||
monkeyBusiness,
|
||||
day11,
|
||||
runPart1Machine,
|
||||
runPart2Machine,
|
||||
worryLimit,
|
||||
divideBy3,
|
||||
)
|
||||
where
|
||||
|
||||
import Control.Monad.State.Strict (execState, get, modify', put)
|
||||
import qualified Control.Monad.State.Strict as St
|
||||
import Data.Foldable (forM_, toList)
|
||||
import Data.List (sortOn)
|
||||
import Data.Ord (Down (..))
|
||||
import Data.Sequence ((|>))
|
||||
import qualified Data.Sequence as S
|
||||
import Data.Text (pack)
|
||||
import Day11.Parser
|
||||
|
||||
day11 :: IO ()
|
||||
day11 = do
|
||||
input <- readFile "ressources/day11-input"
|
||||
putStrLn "Day11"
|
||||
let monkeys = (monkeyBusiness . mostActiveMonkeys . runPart1Machine . parseMonkeys) (pack input)
|
||||
putStrLn ("Part 1 monkey business: " ++ show monkeys)
|
||||
let monkeys' = (monkeyBusiness . mostActiveMonkeys . runPart2Machine . parseMonkeys) (pack input)
|
||||
putStrLn ("Part 2 monkey business: " ++ show monkeys')
|
||||
|
||||
type MonkeyState = St.State (S.Seq Monkey)
|
||||
|
||||
runPart1Machine :: [Monkey] -> [Monkey]
|
||||
runPart1Machine = runMonkeyMachine divideBy3 20
|
||||
|
||||
runPart2Machine :: [Monkey] -> [Monkey]
|
||||
runPart2Machine monkeys = runMonkeyMachine (worryLimit monkeys) 10000 monkeys
|
||||
|
||||
worryLimit :: [Monkey] -> WorryReducer
|
||||
worryLimit monkeys = (`mod` limit)
|
||||
where
|
||||
limit = product $ map _test monkeys
|
||||
|
||||
|
||||
runMonkeyMachine :: WorryReducer -> Int -> [Monkey] -> [Monkey]
|
||||
runMonkeyMachine eval i monkeys = toList (infiniteMachine !! i)
|
||||
where
|
||||
infiniteMachine = iterate go $ S.fromList monkeys
|
||||
go :: S.Seq Monkey -> S.Seq Monkey
|
||||
go m = execState go' m
|
||||
go' :: MonkeyState ()
|
||||
go' = mapM_ (doMonkey eval) [0 .. length monkeys - 1]
|
||||
|
||||
mostActiveMonkeys :: [Monkey] -> [Monkey]
|
||||
mostActiveMonkeys = take 2 . sortOn (Down . _inspectionCount)
|
||||
|
||||
monkeyBusiness :: [Monkey] -> Int
|
||||
monkeyBusiness = product . map _inspectionCount
|
||||
|
||||
-- update a sequence of monkeys according to the moves of the monkey at position idx
|
||||
doMonkey :: WorryReducer -> Int -> MonkeyState ()
|
||||
doMonkey reducer idx = do
|
||||
horde <- get
|
||||
let m = horde `S.index` idx
|
||||
let targets = fmap (evalMonkey reducer m) (_items m)
|
||||
let m' = m {_items = S.empty, _inspectionCount = _inspectionCount m + S.length (_items m)}
|
||||
put $ S.update idx m' horde
|
||||
forM_ targets $ \movement ->
|
||||
modify' (move movement)
|
||||
|
||||
-- update other monkeys according to a list of calculated moves
|
||||
move :: (Int, Int) -> S.Seq Monkey -> S.Seq Monkey
|
||||
move (to, item) horde
|
||||
| item < 0 = error ("Item worry level overflow: " ++ show (to, item))
|
||||
| otherwise =
|
||||
let m = horde `S.index` to
|
||||
m' = m {_items = _items m |> item}
|
||||
in S.update to m' horde
|
||||
|
||||
type WorryReducer = Int -> Int
|
||||
|
||||
divideBy3 :: WorryReducer
|
||||
divideBy3 = flip div 3
|
||||
|
||||
evalMonkey :: WorryReducer -> Monkey -> Int -> (Int, Int)
|
||||
evalMonkey reducer monkey item = (target, newLevel)
|
||||
where
|
||||
afterOp = case _operation monkey of
|
||||
Add Old -> item * 2
|
||||
Add (Fixed x) -> item + x
|
||||
Multiply Old -> item * item
|
||||
Multiply (Fixed x) -> item * x
|
||||
newLevel = reducer afterOp
|
||||
isDivisible = newLevel `mod` _test monkey == 0
|
||||
target =
|
||||
if isDivisible
|
||||
then _ifDivisible monkey
|
||||
else _otherwise monkey
|
||||
98
src/Day11/Parser.hs
Normal file
98
src/Day11/Parser.hs
Normal file
@@ -0,0 +1,98 @@
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
module Day11.Parser (
|
||||
parseMonkeys,
|
||||
Monkey (..),
|
||||
Operation (..),
|
||||
Op (..),
|
||||
)
|
||||
where
|
||||
|
||||
import Text.Megaparsec
|
||||
import Text.Megaparsec.Char
|
||||
import Data.Text (Text)
|
||||
import Data.Void (Void)
|
||||
import Control.Monad (void)
|
||||
import qualified Data.Sequence as S
|
||||
|
||||
type Parser = Parsec Void Text
|
||||
|
||||
data Op = Fixed Int | Old
|
||||
deriving (Show, Eq)
|
||||
|
||||
data Operation = Add Op | Multiply Op
|
||||
deriving (Show, Eq)
|
||||
|
||||
data Monkey = Monkey
|
||||
{ _nr :: Int
|
||||
, _items :: S.Seq Int
|
||||
, _operation :: Operation
|
||||
, _test :: Int
|
||||
, _ifDivisible :: Int
|
||||
, _otherwise :: Int
|
||||
, _inspectionCount :: Int }
|
||||
deriving (Show, Eq)
|
||||
|
||||
parseMonkeys :: Text -> [Monkey]
|
||||
parseMonkeys input = case parse (monkey `sepBy` void eol) "" input of
|
||||
Left err -> error (show err)
|
||||
Right result -> result
|
||||
|
||||
monkey :: Parser Monkey
|
||||
monkey = do
|
||||
void (string "Monkey ")
|
||||
nr <- many numberChar
|
||||
void (char ':')
|
||||
void eol
|
||||
startingItems <- items
|
||||
operation <- op
|
||||
d <- divisor
|
||||
ifDiv <- ifDivisible
|
||||
ifOther <- ifOtherwise
|
||||
return Monkey
|
||||
{ _nr=read nr
|
||||
, _items=S.fromList startingItems
|
||||
, _operation=operation
|
||||
, _test=d
|
||||
, _ifDivisible=ifDiv
|
||||
, _otherwise=ifOther
|
||||
, _inspectionCount=0 }
|
||||
|
||||
ifDivisible :: Parser Int
|
||||
ifDivisible = do
|
||||
x <- read <$> (string " If true: throw to monkey " >> many numberChar)
|
||||
void eol
|
||||
return x
|
||||
|
||||
ifOtherwise :: Parser Int
|
||||
ifOtherwise = do
|
||||
x <- read <$> (string " If false: throw to monkey " >> many numberChar)
|
||||
void eol
|
||||
return x
|
||||
|
||||
divisor :: Parser Int
|
||||
divisor = do
|
||||
d <- read <$> (string " Test: divisible by " >> many numberChar)
|
||||
void eol
|
||||
return d
|
||||
|
||||
items :: Parser [Int]
|
||||
items = do
|
||||
void (string " Starting items: ")
|
||||
startingItems <- sepBy1 (many numberChar) (string ", ")
|
||||
void eol
|
||||
return (map read startingItems)
|
||||
|
||||
op :: Parser Operation
|
||||
op = do
|
||||
o <- void (string " Operation: new = old ") >> addOp <|> mulOp
|
||||
void eol
|
||||
return o
|
||||
where
|
||||
old = string "old" >> return Old
|
||||
num = Fixed . read <$> many numberChar
|
||||
addOp = do
|
||||
void (string "+ ")
|
||||
Add <$> (old <|> num)
|
||||
mulOp = do
|
||||
void (string "* ")
|
||||
Multiply <$> (old <|> num)
|
||||
87
src/Day12.hs
Normal file
87
src/Day12.hs
Normal file
@@ -0,0 +1,87 @@
|
||||
module Day12
|
||||
( day12,
|
||||
possibleStarts,
|
||||
parseGrid,
|
||||
findPath,
|
||||
GridPoints (..),
|
||||
Grid,
|
||||
findBestPath
|
||||
)
|
||||
where
|
||||
|
||||
import Algorithm.Search (dijkstra)
|
||||
import Data.Char (ord)
|
||||
import Data.Map (Map)
|
||||
import qualified Data.Map as Map
|
||||
import Data.Maybe (mapMaybe)
|
||||
import Data.Tuple (swap)
|
||||
import Linear.V2 (V2 (..))
|
||||
import Data.Sort (sortOn)
|
||||
|
||||
type Pos = V2 Int
|
||||
|
||||
type Grid = Map Pos Char
|
||||
|
||||
data GridPoints = GridPoints { _start :: Pos, _end :: Pos }
|
||||
deriving (Show, Eq)
|
||||
|
||||
parseGrid :: String -> (GridPoints, Grid)
|
||||
parseGrid input =
|
||||
( GridPoints
|
||||
{ _start = inverseGrid Map.! 'S',
|
||||
_end = inverseGrid Map.! 'E'
|
||||
},
|
||||
Map.fromList grid
|
||||
)
|
||||
where
|
||||
rows = zip [0 ..] $ lines input
|
||||
grid = concatMap (uncurry colsForRow) rows
|
||||
inverseGrid = Map.fromList $ map swap grid
|
||||
|
||||
colsForRow :: Int -> String -> [(Pos, Char)]
|
||||
colsForRow r = zipWith makePos [0 ..]
|
||||
where
|
||||
makePos c height = (V2 r c, height)
|
||||
|
||||
findPath :: Grid -> GridPoints -> Maybe (Int, [Pos])
|
||||
findPath grid GridPoints {_start = start, _end = end} =
|
||||
dijkstra (neighbors grid) (const . const 1) solutionFound start
|
||||
where
|
||||
solutionFound = (==) end
|
||||
|
||||
neighbors :: Grid -> Pos -> [Pos]
|
||||
neighbors grid pos = filter (canMove grid pos) possiblePositions
|
||||
where
|
||||
directions = [V2 1 0, V2 (-1) 0, V2 0 1, V2 0 (-1)]
|
||||
possiblePositions = map (+ pos) directions
|
||||
|
||||
canMove :: Grid -> Pos -> Pos -> Bool
|
||||
canMove grid from p = case grid Map.!? p of
|
||||
Just c -> asHeight c <= (currentHeight + 1)
|
||||
Nothing -> False
|
||||
where
|
||||
asHeight 'S' = asHeight 'a'
|
||||
asHeight 'E' = asHeight 'z'
|
||||
asHeight x = ord x - ord 'a'
|
||||
currentHeight = asHeight $ grid Map.! from
|
||||
|
||||
possibleStarts :: Grid -> [Pos]
|
||||
possibleStarts grid = map fst $ filter (\(_, v) -> v == 'a') (Map.toList grid)
|
||||
|
||||
findBestPath :: Grid -> GridPoints -> (Int, [Pos])
|
||||
findBestPath grid points = fastest
|
||||
where
|
||||
starts = possibleStarts grid
|
||||
newPoints = [points { _start = s} | s <- starts]
|
||||
allPaths = mapMaybe (findPath grid) newPoints
|
||||
fastest = head $ sortOn fst allPaths
|
||||
|
||||
day12 :: IO ()
|
||||
day12 = do
|
||||
input <- readFile "ressources/day12-input"
|
||||
putStrLn "Day12"
|
||||
let (positions, grid) = parseGrid input
|
||||
let path = findPath grid positions
|
||||
putStrLn ("Cost and path : " ++ show path)
|
||||
let fastest = findBestPath grid positions
|
||||
putStrLn ("Cost and path for nices route: " ++ show fastest)
|
||||
117
src/Day13.hs
Normal file
117
src/Day13.hs
Normal file
@@ -0,0 +1,117 @@
|
||||
{-# LANGUAGE BlockArguments #-}
|
||||
|
||||
module Day13 (parsePackets, Packet (..), checkPair, sumIndices, day13, parsePacketList, addDividers, part2, findDividers, dividers) where
|
||||
|
||||
import Text.Megaparsec
|
||||
import Text.Megaparsec.Char
|
||||
import Data.Void (Void)
|
||||
import Control.Monad (void)
|
||||
import Data.List (intercalate, elemIndex, sort)
|
||||
import Data.Maybe (catMaybes, mapMaybe)
|
||||
|
||||
data Packet = List [Packet] | Entry Int
|
||||
|
||||
instance Eq Packet where
|
||||
(Entry a) == (Entry b) = a == b
|
||||
(List [Entry a]) == (Entry b) = a == b
|
||||
(Entry a) == (List [Entry b]) = a == b
|
||||
(List []) == (Entry _) = False
|
||||
(List []) == (List (_:_)) = False
|
||||
(List []) == (List []) = True
|
||||
(Entry _) == (List []) = False
|
||||
(List (a:as)) == (List (b:bs)) = a == b && List as == List bs
|
||||
a@(Entry _) == b@(List _) = List [a] == b
|
||||
a@(List _) == b@(Entry _) = a == List [b]
|
||||
(List (_:_)) == (List []) = False
|
||||
|
||||
instance Ord Packet where
|
||||
compare (Entry x) (Entry y) = x `compare` y
|
||||
compare (List []) (List []) = EQ
|
||||
compare (List []) (List (_:_)) = LT
|
||||
compare (List ((Entry x):xs)) (List ((Entry y):ys))
|
||||
| x < y = LT
|
||||
| x == y = List xs `compare` List ys
|
||||
| otherwise = GT
|
||||
compare (List (x:xs)) (List (y:ys)) =
|
||||
case x `compare` y of
|
||||
LT -> LT
|
||||
EQ -> List xs `compare` List ys
|
||||
GT -> GT
|
||||
compare (List (_:_)) (List []) = GT
|
||||
compare (Entry x) (List ys) = List [Entry x] `compare` List ys
|
||||
compare (List xs) (Entry y)= List xs `compare` List [Entry y]
|
||||
|
||||
|
||||
newtype PacketPair = PacketPair (Packet, Packet) deriving (Eq)
|
||||
|
||||
instance Show PacketPair where
|
||||
show (PacketPair (p1, p2)) = show p1 ++ "\n" ++ show p2 ++ "\n"
|
||||
|
||||
instance Show Packet where
|
||||
show (Entry n) = show n
|
||||
show (List ps) = "[" ++ intercalate "," (map show ps) ++ "]"
|
||||
|
||||
type Parser = Parsec Void String
|
||||
|
||||
parsePackets :: String -> [PacketPair]
|
||||
parsePackets input = case parse (packetPairs `sepBy` eol) "" input of
|
||||
Left err -> error (show err)
|
||||
Right result -> result
|
||||
|
||||
parsePacketList :: String -> [Packet]
|
||||
parsePacketList input = case parse (packetLine `sepBy` eol) "" input of
|
||||
Left err -> error (show err)
|
||||
Right result -> catMaybes result
|
||||
|
||||
packetLine :: Parser (Maybe Packet)
|
||||
packetLine = Just <$> parsePacket <|> return Nothing
|
||||
|
||||
packetPairs :: Parser PacketPair
|
||||
packetPairs = do
|
||||
p1 <- parsePacket
|
||||
void eol
|
||||
p2 <- parsePacket
|
||||
void eol
|
||||
return $ PacketPair (p1, p2)
|
||||
|
||||
parsePacket :: Parser Packet
|
||||
parsePacket = do
|
||||
void $ char '['
|
||||
entries <- (parseNum <|> parsePacket) `sepBy` char ','
|
||||
void $ char ']'
|
||||
return $ List entries
|
||||
where
|
||||
parseNum = Entry . read <$> some numberChar
|
||||
|
||||
checkPair :: PacketPair -> Bool
|
||||
checkPair (PacketPair (p1, p2)) = p1 <= p2
|
||||
|
||||
|
||||
sumIndices :: [PacketPair] -> Int
|
||||
sumIndices pairs = sum $ map fst $ filter snd $ zip [1..] $ map checkPair pairs
|
||||
|
||||
|
||||
dividers :: [Packet]
|
||||
dividers = [List [List [Entry 2]], List [List [Entry 6]]]
|
||||
|
||||
addDividers :: [Packet] -> [Packet]
|
||||
addDividers = (++) dividers
|
||||
|
||||
-- find the 1-based indices of the dividers
|
||||
findDividers :: [Packet] -> [Int]
|
||||
findDividers packets = map (+1) positions
|
||||
where
|
||||
positions = mapMaybe findIndex dividers
|
||||
findIndex x = x `elemIndex` packets
|
||||
|
||||
part2 :: [Packet] -> Int
|
||||
part2 packets = product $ findDividers $ sort $ addDividers packets
|
||||
|
||||
day13 :: IO ()
|
||||
day13 = do
|
||||
input <- readFile "ressources/day13-input"
|
||||
putStrLn "Day13"
|
||||
let pairs = parsePackets input
|
||||
putStrLn ("Sum of indices: " ++ show (sumIndices pairs))
|
||||
let packets = parsePacketList input
|
||||
putStrLn ("Decoder key: " ++ show (part2 packets))
|
||||
@@ -30,7 +30,7 @@ data Operation = Operation
|
||||
type Content = Char
|
||||
newtype Stack = Stack [Content] deriving (Show, Eq)
|
||||
|
||||
content :: Stack -> [Content]
|
||||
content :: Stack -> [Content]
|
||||
content (Stack c) = c
|
||||
|
||||
instance Semigroup Stack where
|
||||
|
||||
92
src/Day7.hs
92
src/Day7.hs
@@ -1,89 +1,10 @@
|
||||
module Day7 (
|
||||
buildTree,
|
||||
buildTree',
|
||||
mkdir,
|
||||
Directory (..),
|
||||
calculateSize,
|
||||
filterDirectories,
|
||||
sumUp,
|
||||
day7
|
||||
) where
|
||||
|
||||
import Day7.Parser
|
||||
import Data.Map (Map)
|
||||
import qualified Data.Map as Map
|
||||
|
||||
data Directory = Directory
|
||||
{ sub :: Map String Directory
|
||||
, files :: Map String Int
|
||||
, isRoot :: Bool
|
||||
} deriving (Eq)
|
||||
|
||||
|
||||
instance Show Directory where
|
||||
show d = show (files d) ++ " - " ++ show (sub d) ++ "\n"
|
||||
|
||||
mkdir :: Directory
|
||||
mkdir = Directory { sub = Map.empty, files = Map.empty, isRoot = False }
|
||||
|
||||
rootDirectory :: Directory
|
||||
rootDirectory = Directory { sub = Map.empty, files = Map.empty, isRoot = True }
|
||||
|
||||
buildTree :: [TerminalCommand] -> Directory
|
||||
buildTree commands = fst (buildTree' rootDirectory commands)
|
||||
|
||||
buildTree' :: Directory -> [TerminalCommand] -> (Directory, [TerminalCommand])
|
||||
buildTree' dir [] = (dir, [])
|
||||
buildTree' dir (command:cs) = case command of
|
||||
Listing entries ->
|
||||
let asFiles = Map.fromList $ toFiles entries
|
||||
newDir = dir { files = asFiles }
|
||||
in buildTree' newDir cs
|
||||
In dirName ->
|
||||
let subFolders = sub dir
|
||||
selectedDir = Map.findWithDefault mkdir dirName subFolders
|
||||
(replacement, rest) = buildTree' selectedDir cs
|
||||
updatedSub = Map.insert dirName replacement subFolders
|
||||
in buildTree' dir { sub = updatedSub} rest
|
||||
Out -> (dir, cs)
|
||||
Root -> if isRoot dir
|
||||
then buildTree' dir cs
|
||||
else (dir, command:cs)
|
||||
|
||||
toFiles :: [ListingEntry] -> [(String, Int)]
|
||||
toFiles ((FileListing name size):rest) = (name, size): toFiles rest
|
||||
toFiles (_:rest) = toFiles rest
|
||||
toFiles [] = []
|
||||
|
||||
sizeThreshold :: Int
|
||||
sizeThreshold = 100000
|
||||
|
||||
calculateSize :: Directory -> Int
|
||||
calculateSize dir = sum (Map.elems (files dir)) + sum sizes
|
||||
where
|
||||
subFolders = Map.elems (sub dir)
|
||||
sizes = map calculateSize subFolders
|
||||
|
||||
flatten :: Directory -> [(String, Directory)]
|
||||
flatten dir = flatten' ("/", dir)
|
||||
where
|
||||
flatten' (name, d) = (name, d) : concatMap flatten' (Map.toList (sub d))
|
||||
|
||||
sizeOfDirectories :: Directory -> [(String, Int)]
|
||||
sizeOfDirectories dir = map withSize allDirectories
|
||||
where
|
||||
allDirectories = flatten dir
|
||||
withSize (name, directory) = (name, calculateSize directory)
|
||||
|
||||
filterDirectories :: (Int -> Bool) -> Directory -> [(String, Int)]
|
||||
filterDirectories predicate dir = filter (\(_, size) -> predicate size) $ sizeOfDirectories dir
|
||||
|
||||
sumUp :: [(String, Int)] -> Int
|
||||
sumUp = sum . map snd
|
||||
|
||||
forceRight :: Either a b -> b
|
||||
forceRight (Left _) = error "forced Right but got Left"
|
||||
forceRight (Right b) = b
|
||||
import Day7.Interpreter
|
||||
import Shared
|
||||
|
||||
day7 :: IO ()
|
||||
day7 = do
|
||||
@@ -92,15 +13,12 @@ day7 = do
|
||||
let parsed = forceRight $ parseTerminalLines input
|
||||
let tree = buildTree parsed
|
||||
let small = filterDirectories (<= 100000) tree
|
||||
let sumOfSmall = sumUp small
|
||||
let sumOfSmall = sum small
|
||||
putStrLn ("Sum of those directories is " ++ show sumOfSmall)
|
||||
let rootSize = snd . head $ sizeOfDirectories tree
|
||||
putStrLn ("Root size is " ++ show rootSize)
|
||||
let rootSize = head $ sizeOfDirectories tree
|
||||
let freeSpace = 70000000 - rootSize
|
||||
let requiredSpace = 30000000 - freeSpace
|
||||
putStrLn ("Required space is " ++ show requiredSpace)
|
||||
let bigEnough = filterDirectories (>= requiredSpace) tree
|
||||
let onlySizes = map snd bigEnough
|
||||
let smallest = minimum onlySizes
|
||||
let smallest = minimum bigEnough
|
||||
putStrLn ("Smallest directory that is still large enough " ++ show smallest)
|
||||
|
||||
|
||||
81
src/Day7/Interpreter.hs
Normal file
81
src/Day7/Interpreter.hs
Normal file
@@ -0,0 +1,81 @@
|
||||
module Day7.Interpreter (
|
||||
buildTree,
|
||||
mkdir,
|
||||
FileTree (..),
|
||||
Directory,
|
||||
calculateSize,
|
||||
filterDirectories,
|
||||
sizeOfDirectories,
|
||||
) where
|
||||
|
||||
import Day7.Parser
|
||||
import Data.Map (Map)
|
||||
import qualified Data.Map as Map
|
||||
import qualified Data.Foldable as F
|
||||
|
||||
|
||||
data FileTree a = FileTree
|
||||
{ sub :: Map String (FileTree a)
|
||||
, files :: Map String a
|
||||
, isRoot :: Bool
|
||||
} deriving (Eq)
|
||||
|
||||
-- Directory is a FileTree with file sizes of Int
|
||||
type Directory = FileTree Int
|
||||
|
||||
-- pretty much only useful for summing up file sizes
|
||||
instance F.Foldable FileTree where
|
||||
foldMap f dir = foldMap f (files dir) <> mconcat mappedSubfolders
|
||||
where
|
||||
subFolders = Map.elems $ sub dir
|
||||
mappedSubfolders = map (foldMap f) subFolders
|
||||
|
||||
instance Show a => Show (FileTree a) where
|
||||
show d = "DIR " ++ show (Map.toList $ files d) ++ " - " ++ show (Map.toList $ sub d) ++ "\n"
|
||||
|
||||
mkdir :: Directory
|
||||
mkdir = FileTree { sub = Map.empty, files = Map.empty, isRoot = False }
|
||||
|
||||
rootDirectory :: Directory
|
||||
rootDirectory = mkdir { isRoot = True }
|
||||
|
||||
buildTree :: [TerminalCommand] -> Directory
|
||||
buildTree commands = fst (buildTree' rootDirectory commands)
|
||||
where
|
||||
-- executes terminal commands and returns all remaining commands
|
||||
buildTree' :: Directory -> [TerminalCommand] -> (Directory, [TerminalCommand])
|
||||
buildTree' dir [] = (dir, [])
|
||||
buildTree' dir (command:cs) = case command of
|
||||
Listing entries ->
|
||||
let asFiles = Map.fromList $ toFiles entries
|
||||
newDir = dir { files = asFiles }
|
||||
in buildTree' newDir cs -- update current directory and return all remaining commands
|
||||
In dirName ->
|
||||
let subFolders = sub dir
|
||||
selectedDir = Map.findWithDefault mkdir dirName subFolders -- select or create folder
|
||||
(replacement, rest) = buildTree' selectedDir cs -- recurse down
|
||||
updatedSub = Map.insert dirName replacement subFolders -- update folder the map of the current directory
|
||||
in buildTree' dir { sub = updatedSub} rest -- continue with updated folder and rest of commands
|
||||
Out -> (dir, cs) -- return to previous caller and return all remaining commands
|
||||
Root -> if isRoot dir
|
||||
then buildTree' dir cs -- return to previous caller as long is current directory is not root
|
||||
else (dir, command:cs) -- keep the Root command because it is not yet completed
|
||||
|
||||
-- convert to file-pairs and ignore directories
|
||||
toFiles :: [ListingEntry] -> [(String, Int)]
|
||||
toFiles ((FileListing name size):rest) = (name, size): toFiles rest
|
||||
toFiles (_:rest) = toFiles rest
|
||||
toFiles [] = []
|
||||
|
||||
calculateSize :: Directory -> Int
|
||||
calculateSize = F.foldl' (+) 0
|
||||
|
||||
flatten :: Directory -> [Directory]
|
||||
flatten d = d : concatMap flatten (Map.elems (sub d))
|
||||
|
||||
sizeOfDirectories :: Directory -> [Int]
|
||||
sizeOfDirectories = map calculateSize . flatten
|
||||
|
||||
filterDirectories :: (Int -> Bool) -> Directory -> [Int]
|
||||
filterDirectories predicate dir = filter predicate $ sizeOfDirectories dir
|
||||
|
||||
@@ -18,7 +18,7 @@ data ListingEntry = DirListing DirName | FileListing FileName Size
|
||||
|
||||
data TerminalCommand = In DirName | Out | Root | Listing [ListingEntry]
|
||||
deriving (Show, Eq)
|
||||
|
||||
|
||||
parseTerminalLines :: String -> Either ParseError [TerminalCommand]
|
||||
parseTerminalLines = parse terminal "(error)"
|
||||
|
||||
@@ -59,7 +59,7 @@ cd = do
|
||||
_ <- string "cd "
|
||||
name <- many $ noneOf "\n"
|
||||
_ <- char '\n'
|
||||
return (nameToDir name)
|
||||
return $ nameToDir name
|
||||
|
||||
nameToDir :: DirName -> TerminalCommand
|
||||
nameToDir "/" = Root
|
||||
|
||||
81
src/Day8.hs
Normal file
81
src/Day8.hs
Normal file
@@ -0,0 +1,81 @@
|
||||
module Day8 (
|
||||
Forest,
|
||||
Visibillity,
|
||||
parseForest,
|
||||
checkVisibility,
|
||||
countVisible,
|
||||
findMaxScenicScore,
|
||||
viewingDistance,
|
||||
day8
|
||||
)where
|
||||
|
||||
import qualified Data.Matrix as M
|
||||
import Data.Matrix ((!))
|
||||
import Data.Char (isDigit)
|
||||
import qualified Data.Vector as V
|
||||
import Data.Monoid (Sum (..), getSum, Product (..), getProduct)
|
||||
import Control.Arrow ((>>>))
|
||||
|
||||
type Forest = M.Matrix Int
|
||||
type Visibillity = M.Matrix Bool
|
||||
|
||||
parseForest :: String -> Forest
|
||||
parseForest input = M.fromList rows cols asNumbers
|
||||
where
|
||||
ls = lines input
|
||||
cols = length (head ls)
|
||||
rows = length ls
|
||||
asNumbers :: [Int]
|
||||
asNumbers = map (read . (: [])) . filter isDigit $ input
|
||||
|
||||
checkAgainstNeighbours :: (Int -> [V.Vector Int] -> a) -> Forest -> M.Matrix a
|
||||
checkAgainstNeighbours f forest = M.matrix (M.nrows forest) (M.ncols forest) check
|
||||
where
|
||||
check(x, y) =
|
||||
let row = M.getRow x forest
|
||||
col = M.getCol y forest
|
||||
-- left and top are reversed to order the as seen from (x,y)
|
||||
left = V.reverse $ V.take (y - 1) row
|
||||
right = V.drop y row
|
||||
top = V.reverse $ V.take (x - 1) col
|
||||
bottom = V.drop x col
|
||||
v = forest ! (x,y)
|
||||
in f v [left, right, top, bottom]
|
||||
|
||||
checkVisibility :: Forest -> Visibillity
|
||||
checkVisibility = checkAgainstNeighbours isVisible
|
||||
where
|
||||
isVisible treeHeight = any (all (< treeHeight))
|
||||
|
||||
countVisible :: Visibillity -> Int
|
||||
countVisible = foldMap (Sum . isTrue) >>> getSum
|
||||
where
|
||||
isTrue True = 1
|
||||
isTrue False = 0
|
||||
|
||||
checkScenicScores :: Forest -> M.Matrix Int
|
||||
checkScenicScores = checkAgainstNeighbours allDistances
|
||||
where
|
||||
allDistances treeHeight neighbors = foldMap (viewingDistance treeHeight >>> Product) >>> getProduct $ neighbors
|
||||
|
||||
viewingDistance :: Int -> V.Vector Int -> Int
|
||||
viewingDistance treeHeight neighbors
|
||||
| V.length neighbors == 0 = 0
|
||||
| V.head neighbors >= treeHeight = 1
|
||||
| V.head neighbors < treeHeight = 1 + viewingDistance treeHeight (V.tail neighbors)
|
||||
| otherwise = 0
|
||||
|
||||
findMaxScenicScore :: Forest -> Int
|
||||
findMaxScenicScore = checkScenicScores >>> M.toList >>> maximum
|
||||
|
||||
day8 :: IO ()
|
||||
day8 = do
|
||||
input <- readFile "ressources/day08-input"
|
||||
putStrLn "Day8"
|
||||
let forest = parseForest input
|
||||
let visibleTrees = checkVisibility >>> countVisible $ forest
|
||||
putStrLn ("Number of visible trees is " ++ show visibleTrees)
|
||||
let highestScenicScore = findMaxScenicScore forest
|
||||
putStrLn ("Highest scenic score is " ++ show highestScenicScore)
|
||||
|
||||
|
||||
116
src/Day9.hs
Normal file
116
src/Day9.hs
Normal file
@@ -0,0 +1,116 @@
|
||||
module Day9
|
||||
( parseMovements,
|
||||
Move (..),
|
||||
Grid (..),
|
||||
up,
|
||||
down,
|
||||
left,
|
||||
right,
|
||||
diag,
|
||||
still,
|
||||
step,
|
||||
recordPositions,
|
||||
normalizeMovement,
|
||||
Step (..),
|
||||
follow,
|
||||
buildTails,
|
||||
day9,
|
||||
)
|
||||
where
|
||||
|
||||
import Control.Arrow ((>>>))
|
||||
import Control.Monad.Trans.State.Strict (State, modify, runState)
|
||||
import qualified Data.Set as S
|
||||
|
||||
newtype Move = Move (Int, Int)
|
||||
deriving (Show, Eq)
|
||||
|
||||
newtype Step = Step (Int, Int)
|
||||
deriving (Show, Eq)
|
||||
|
||||
up :: Int -> Move
|
||||
up y = Move (0, y)
|
||||
|
||||
down :: Int -> Move
|
||||
down y = Move (0, y * (-1))
|
||||
|
||||
left :: Int -> Move
|
||||
left x = Move (x * (-1), 0)
|
||||
|
||||
right :: Int -> Move
|
||||
right x = Move (x, 0)
|
||||
|
||||
diag :: Int -> Move
|
||||
diag x = Move (x, x)
|
||||
|
||||
still :: Move
|
||||
still = Move (0, 0)
|
||||
|
||||
type Pos = (Int, Int)
|
||||
|
||||
data Grid = Grid {h :: Pos, t :: Pos} deriving (Show, Eq)
|
||||
|
||||
data MovementLog = MovementLog {visited :: S.Set Pos, recordedSteps :: [Step]}
|
||||
deriving (Show, Eq)
|
||||
|
||||
logOne :: (Pos, Step) -> MovementLog -> MovementLog
|
||||
logOne (p, s) (MovementLog v steps) =
|
||||
MovementLog (S.insert p v) (s : steps)
|
||||
|
||||
buildTails :: [Step] -> [([Pos], [Step])]
|
||||
buildTails steps = iterate (snd >>> recordPositions) ([], steps)
|
||||
|
||||
recordPositions :: [Step] -> ([Pos], [Step])
|
||||
recordPositions steps = (allPositions, allSteps)
|
||||
where
|
||||
-- insert last tail position
|
||||
allPositions = S.toList $ S.insert lastTailPos (visited state)
|
||||
allSteps = reverse (recordedSteps state)
|
||||
|
||||
((_, Grid {t = lastTailPos}), state) =
|
||||
runState (recordPositions' steps Grid {h = (0,0), t = (0,0)}) (MovementLog S.empty [])
|
||||
|
||||
recordPositions' :: [Step] -> Grid -> State MovementLog ([Step], Grid)
|
||||
recordPositions' [] grid = return ([], grid)
|
||||
recordPositions' (m : ms) Grid {h = headPos, t = tailPos} =
|
||||
let newHead = headPos `step` m
|
||||
followStep = follow newHead tailPos
|
||||
newTail = tailPos `step` followStep
|
||||
in modify (logOne (newTail, followStep))
|
||||
>> recordPositions' ms Grid {h = newHead, t = newTail}
|
||||
|
||||
parseMovements :: String -> [Move]
|
||||
parseMovements = lines >>> map toMove
|
||||
where
|
||||
toMove ('U' : ' ' : xs) = up $ read xs
|
||||
toMove ('D' : ' ' : xs) = down $ read xs
|
||||
toMove ('L' : ' ' : xs) = left $ read xs
|
||||
toMove ('R' : ' ' : xs) = right $ read xs
|
||||
toMove _ = error "cannot parse movement"
|
||||
|
||||
normalizeMovement :: Move -> [Step]
|
||||
normalizeMovement (Move (dx, 0)) = replicate (abs dx) (Step (signum dx, 0))
|
||||
normalizeMovement (Move (0, dy)) = replicate (abs dy) (Step (0, signum dy))
|
||||
normalizeMovement m = error $ "cannot normalize movement: " ++ show m
|
||||
|
||||
step :: Pos -> Step -> Pos
|
||||
step (x, y) (Step (dx, dy)) = (x + dx, y + dy)
|
||||
|
||||
follow :: Pos -> Pos -> Step
|
||||
follow (x1, y1) (x2, y2)
|
||||
| abs dx > 1 || abs dy > 1 = Step (signum dx, signum dy)
|
||||
| otherwise = Step (0, 0)
|
||||
where
|
||||
dx = x1 - x2
|
||||
dy = y1 - y2
|
||||
|
||||
day9 :: IO ()
|
||||
day9 = do
|
||||
input <- readFile "ressources/day09-input"
|
||||
putStrLn "Day9"
|
||||
let headSteps = parseMovements >>> concatMap normalizeMovement $ input
|
||||
let allTails = buildTails headSteps
|
||||
let positions = (!! 1) >>> fst >>> length $ allTails
|
||||
putStrLn ("Number of distinct positions " ++ show positions)
|
||||
let tail9 = (!! 9) >>> fst >>> length $ allTails
|
||||
putStrLn ("Number of distinct positions of tail 9" ++ show tail9)
|
||||
44
src/Lib.hs
44
src/Lib.hs
@@ -1,29 +1,27 @@
|
||||
module Lib
|
||||
( someFunc
|
||||
) where
|
||||
|
||||
import Day1
|
||||
import Day2
|
||||
import Day3
|
||||
import Day4
|
||||
import Day5
|
||||
import Day6
|
||||
import Day7
|
||||
|
||||
import Day1 (day1)
|
||||
import Day2 (day2)
|
||||
import Day3 (day3)
|
||||
import Day4 (day4)
|
||||
import Day5 (day5)
|
||||
import Day6 (day6)
|
||||
import Day7 (day7)
|
||||
import Day8 (day8)
|
||||
import Day9 (day9)
|
||||
import Day10 (day10)
|
||||
import Day11 (day11)
|
||||
import Day12 (day12)
|
||||
import Day13 (day13)
|
||||
|
||||
days :: [IO ()]
|
||||
days = [day1, day2, day3, day4, day5, day6, day7, day8, day9, day10, day11, day12, day13]
|
||||
|
||||
sep :: IO ()
|
||||
sep = putStrLn "---------"
|
||||
|
||||
someFunc :: IO ()
|
||||
someFunc = do
|
||||
day1
|
||||
putStrLn "-----------"
|
||||
day2
|
||||
putStrLn "-----------"
|
||||
day3
|
||||
putStrLn "-----------"
|
||||
day4
|
||||
putStrLn "-----------"
|
||||
day5
|
||||
putStrLn "-----------"
|
||||
day6
|
||||
putStrLn "-----------"
|
||||
day7
|
||||
|
||||
someFunc = mapM_ (>> sep) days
|
||||
|
||||
|
||||
6
src/Shared.hs
Normal file
6
src/Shared.hs
Normal file
@@ -0,0 +1,6 @@
|
||||
module Shared(forceRight) where
|
||||
|
||||
forceRight :: Either a b -> b
|
||||
forceRight (Left _) = error "forced Right but got Left"
|
||||
forceRight (Right b) = b
|
||||
|
||||
193
test/Day10Spec.hs
Normal file
193
test/Day10Spec.hs
Normal file
@@ -0,0 +1,193 @@
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
|
||||
module Day10Spec (spec) where
|
||||
|
||||
import Control.Arrow ((>>>))
|
||||
import Day10
|
||||
import Test.Hspec
|
||||
import Text.Heredoc
|
||||
|
||||
testInput :: String
|
||||
testInput = [str|noop
|
||||
|addx 3
|
||||
|addx -5
|
||||
|]
|
||||
|
||||
testProgram :: [Instruction]
|
||||
testProgram = [Noop, Addx 3, Addx (-5)]
|
||||
|
||||
testInput2 :: String
|
||||
testInput2 = [str|addx 15
|
||||
|addx -11
|
||||
|addx 6
|
||||
|addx -3
|
||||
|addx 5
|
||||
|addx -1
|
||||
|addx -8
|
||||
|addx 13
|
||||
|addx 4
|
||||
|noop
|
||||
|addx -1
|
||||
|addx 5
|
||||
|addx -1
|
||||
|addx 5
|
||||
|addx -1
|
||||
|addx 5
|
||||
|addx -1
|
||||
|addx 5
|
||||
|addx -1
|
||||
|addx -35
|
||||
|addx 1
|
||||
|addx 24
|
||||
|addx -19
|
||||
|addx 1
|
||||
|addx 16
|
||||
|addx -11
|
||||
|noop
|
||||
|noop
|
||||
|addx 21
|
||||
|addx -15
|
||||
|noop
|
||||
|noop
|
||||
|addx -3
|
||||
|addx 9
|
||||
|addx 1
|
||||
|addx -3
|
||||
|addx 8
|
||||
|addx 1
|
||||
|addx 5
|
||||
|noop
|
||||
|noop
|
||||
|noop
|
||||
|noop
|
||||
|noop
|
||||
|addx -36
|
||||
|noop
|
||||
|addx 1
|
||||
|addx 7
|
||||
|noop
|
||||
|noop
|
||||
|noop
|
||||
|addx 2
|
||||
|addx 6
|
||||
|noop
|
||||
|noop
|
||||
|noop
|
||||
|noop
|
||||
|noop
|
||||
|addx 1
|
||||
|noop
|
||||
|noop
|
||||
|addx 7
|
||||
|addx 1
|
||||
|noop
|
||||
|addx -13
|
||||
|addx 13
|
||||
|addx 7
|
||||
|noop
|
||||
|addx 1
|
||||
|addx -33
|
||||
|noop
|
||||
|noop
|
||||
|noop
|
||||
|addx 2
|
||||
|noop
|
||||
|noop
|
||||
|noop
|
||||
|addx 8
|
||||
|noop
|
||||
|addx -1
|
||||
|addx 2
|
||||
|addx 1
|
||||
|noop
|
||||
|addx 17
|
||||
|addx -9
|
||||
|addx 1
|
||||
|addx 1
|
||||
|addx -3
|
||||
|addx 11
|
||||
|noop
|
||||
|noop
|
||||
|addx 1
|
||||
|noop
|
||||
|addx 1
|
||||
|noop
|
||||
|noop
|
||||
|addx -13
|
||||
|addx -19
|
||||
|addx 1
|
||||
|addx 3
|
||||
|addx 26
|
||||
|addx -30
|
||||
|addx 12
|
||||
|addx -1
|
||||
|addx 3
|
||||
|addx 1
|
||||
|noop
|
||||
|noop
|
||||
|noop
|
||||
|addx -9
|
||||
|addx 18
|
||||
|addx 1
|
||||
|addx 2
|
||||
|noop
|
||||
|noop
|
||||
|addx 9
|
||||
|noop
|
||||
|noop
|
||||
|noop
|
||||
|addx -1
|
||||
|addx 2
|
||||
|addx -37
|
||||
|addx 1
|
||||
|addx 3
|
||||
|noop
|
||||
|addx 15
|
||||
|addx -21
|
||||
|addx 22
|
||||
|addx -6
|
||||
|addx 1
|
||||
|noop
|
||||
|addx 2
|
||||
|addx 1
|
||||
|noop
|
||||
|addx -10
|
||||
|noop
|
||||
|noop
|
||||
|addx 20
|
||||
|addx 1
|
||||
|addx 2
|
||||
|addx 2
|
||||
|addx -6
|
||||
|addx -11
|
||||
|noop
|
||||
|noop
|
||||
|noop
|
||||
|]
|
||||
|
||||
spec :: Spec
|
||||
spec =
|
||||
describe "Day10" $ do
|
||||
describe "Part1" $ do
|
||||
it "parses" $ do
|
||||
parseProgram testInput `shouldBe` testProgram
|
||||
it "executes" $ do
|
||||
executeProgram testProgram `shouldBe` [1,1,1,4,4,-1]
|
||||
it "executes larger program" $ do
|
||||
let registerValues = parseProgram >>> executeProgram $ testInput2
|
||||
registerValues !! 20 `shouldBe` 21
|
||||
registerValues !! 60 `shouldBe` 19
|
||||
registerValues !! 100 `shouldBe` 18
|
||||
registerValues !! 140 `shouldBe` 21
|
||||
registerValues !! 180 `shouldBe` 16
|
||||
registerValues !! 220 `shouldBe` 18
|
||||
it "computes signal strength" $ do
|
||||
let registerValues = parseProgram >>> executeProgram $ testInput2
|
||||
signalStrength registerValues `shouldBe` 13140
|
||||
it "prints a crt" $ do
|
||||
let registerValues = parseProgram >>> executeProgram $ testInput2
|
||||
putStrLn $ draw registerValues
|
||||
it "sprites drawn" $ do
|
||||
isSpriteDrawn 1 1 `shouldBe` True
|
||||
isSpriteDrawn 1 1 `shouldBe` True
|
||||
|
||||
68
test/Day11Spec.hs
Normal file
68
test/Day11Spec.hs
Normal file
@@ -0,0 +1,68 @@
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
|
||||
module Day11Spec (spec) where
|
||||
|
||||
import Data.Foldable (toList)
|
||||
import qualified Data.Sequence as S
|
||||
import Data.Text (Text)
|
||||
import Day11
|
||||
import Day11.Parser
|
||||
import Test.Hspec
|
||||
import Text.Heredoc
|
||||
import Data.Int (Int64)
|
||||
|
||||
testInput :: Text
|
||||
testInput =
|
||||
[str|Monkey 0:
|
||||
| Starting items: 79, 98
|
||||
| Operation: new = old * 19
|
||||
| Test: divisible by 23
|
||||
| If true: throw to monkey 2
|
||||
| If false: throw to monkey 3
|
||||
|
|
||||
|Monkey 1:
|
||||
| Starting items: 54, 65, 75, 74
|
||||
| Operation: new = old + 6
|
||||
| Test: divisible by 19
|
||||
| If true: throw to monkey 2
|
||||
| If false: throw to monkey 0
|
||||
|
|
||||
|Monkey 2:
|
||||
| Starting items: 79, 60, 97
|
||||
| Operation: new = old * old
|
||||
| Test: divisible by 13
|
||||
| If true: throw to monkey 1
|
||||
| If false: throw to monkey 3
|
||||
|
|
||||
|Monkey 3:
|
||||
| Starting items: 74
|
||||
| Operation: new = old + 3
|
||||
| Test: divisible by 17
|
||||
| If true: throw to monkey 0
|
||||
| If false: throw to monkey 1
|
||||
|]
|
||||
|
||||
exampleMonkeys :: [Monkey]
|
||||
exampleMonkeys = parseMonkeys testInput
|
||||
|
||||
spec :: Spec
|
||||
spec =
|
||||
describe "Day11" $ do
|
||||
describe "Part1" $ do
|
||||
it "parses" $ do
|
||||
head exampleMonkeys `shouldBe` Monkey 0 (S.fromList [79, 98]) (Multiply (Fixed 19)) 23 2 3 0
|
||||
_items (exampleMonkeys !! 1) `shouldBe` S.fromList [54, 65, 75, 74]
|
||||
it "runs part 1 monkey machine for 20 rounds" $ do
|
||||
let monkeys = runMonkeyMachine divideBy3 20 exampleMonkeys
|
||||
map _inspectionCount monkeys
|
||||
`shouldBe` [101, 95, 7, 105]
|
||||
map _inspectionCount (mostActiveMonkeys monkeys) `shouldBe` [105, 101]
|
||||
map _nr (mostActiveMonkeys monkeys) `shouldBe` [3, 0]
|
||||
monkeyBusiness (mostActiveMonkeys monkeys) `shouldBe` 10605
|
||||
|
||||
it "runs part 2 monkey machine for 10000 rounds" $ do
|
||||
let monkeys = runMonkeyMachine (worryLimit exampleMonkeys) 10000 exampleMonkeys
|
||||
map _inspectionCount monkeys
|
||||
`shouldBe` [52166, 47830, 1938, 52013]
|
||||
monkeyBusiness (mostActiveMonkeys monkeys) `shouldBe` 2713310158
|
||||
30
test/Day12Spec.hs
Normal file
30
test/Day12Spec.hs
Normal file
@@ -0,0 +1,30 @@
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
|
||||
module Day12Spec (spec) where
|
||||
|
||||
import Day12
|
||||
import Test.Hspec
|
||||
import Text.Heredoc
|
||||
import Data.Maybe (fromJust, isJust)
|
||||
|
||||
testInput :: String
|
||||
testInput = [str|Sabqponm
|
||||
|abcryxxl
|
||||
|accszExk
|
||||
|acctuvwj
|
||||
|abdefghi
|
||||
|]
|
||||
|
||||
spec :: Spec
|
||||
spec =
|
||||
describe "Day12" $ do
|
||||
describe "Part1" $ do
|
||||
it "finds a path" $ do
|
||||
let (points, grid) = parseGrid testInput
|
||||
let result = findPath grid points
|
||||
isJust result `shouldBe` True
|
||||
fst (fromJust result) `shouldBe` 31
|
||||
it "finds shortest paths from all lowest points" $ do
|
||||
let (points, grid) = parseGrid testInput
|
||||
let fastest = findBestPath grid points
|
||||
fst fastest `shouldBe` 29
|
||||
71
test/Day13Spec.hs
Normal file
71
test/Day13Spec.hs
Normal file
@@ -0,0 +1,71 @@
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
|
||||
module Day13Spec (spec) where
|
||||
|
||||
import Day13
|
||||
import Test.Hspec
|
||||
import Text.Heredoc
|
||||
import Data.List (sort, elem, elemIndex)
|
||||
|
||||
testInput :: String
|
||||
testInput = [str|[1,1,3,1,1]
|
||||
|[1,1,5,1,1]
|
||||
|
|
||||
|[[1],[2,3,4]]
|
||||
|[[1],4]
|
||||
|
|
||||
|[9]
|
||||
|[[8,7,6]]
|
||||
|
|
||||
|[[4,4],4,4]
|
||||
|[[4,4],4,4,4]
|
||||
|
|
||||
|[7,7,7,7]
|
||||
|[7,7,7]
|
||||
|
|
||||
|[]
|
||||
|[3]
|
||||
|
|
||||
|[[[]]]
|
||||
|[[]]
|
||||
|
|
||||
|[1,[2,[3,[4,[5,6,7]]]],8,9]
|
||||
|[1,[2,[3,[4,[5,6,0]]]],8,9]
|
||||
|]
|
||||
|
||||
falsePositive :: String
|
||||
falsePositive = "[[],[[[10,2,6],[1,4,9,2,5]],[],[5,2],[1,3,5]],[[[7,2,2,0],[0,1],10],10,[9,[4,8],[8,2,10],[1,4,2]],7,[[2]]]]\n" ++
|
||||
"[[],[[[],[],[9,10,5,6],2,[0]],10],[[],[[4,9,3,7],7,4],[],2,2],[8,[6,8,[7,5,5],[2,4,8,0,7],[3,1,7,3,9]],[[9,1,5,1],[5,1,1],[],[2,1,2,1]],[[0,9,1,10],5,[],10,[5,0,10,2]],[10,[3,4,8,8,4],5]]]\n"
|
||||
|
||||
spec :: Spec
|
||||
spec =
|
||||
describe "Day12" $ do
|
||||
describe "Part1" $ do
|
||||
it "parser a single pair" $ do
|
||||
let input = "[1,[],3]\n[]\n"
|
||||
show (head $ parsePackets input) `shouldBe` input
|
||||
it "checks order" $ do
|
||||
Entry 1 <= Entry 2 `shouldBe` True
|
||||
Entry 2 <= Entry 1 `shouldBe` False
|
||||
List [] <= List [] `shouldBe` True
|
||||
List [] <= List [Entry 1] `shouldBe` True
|
||||
List [Entry 1] <= List [] `shouldBe` False
|
||||
List [Entry 1] <= Entry 2 `shouldBe` True
|
||||
List [Entry 2] <= Entry 1 `shouldBe` False
|
||||
let pair = head $ parsePackets falsePositive
|
||||
checkPair pair `shouldBe` False
|
||||
it "checks examples" $ do
|
||||
let pairs = parsePackets testInput
|
||||
length pairs `shouldBe` 8
|
||||
sumIndices pairs `shouldBe` 13
|
||||
map checkPair pairs `shouldBe` [True, True, False, True, False, True, False, False]
|
||||
describe "Part2" $ do
|
||||
it "checks examples" $ do
|
||||
let packets = sort $ addDividers $ parsePacketList testInput
|
||||
let a = packets !! 9
|
||||
let b = head dividers
|
||||
a `shouldBe` b
|
||||
elem (head dividers) packets `shouldBe` True
|
||||
findDividers packets `shouldBe` [10, 14]
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ module Day6Spec (spec) where
|
||||
|
||||
import Test.Hspec
|
||||
import Day6
|
||||
import qualified Data.Sequence as S
|
||||
|
||||
spec :: Spec
|
||||
spec =
|
||||
|
||||
@@ -4,8 +4,9 @@ module Day7Spec (spec) where
|
||||
import Test.Hspec
|
||||
import Text.Heredoc
|
||||
|
||||
import Day7
|
||||
import Shared
|
||||
import Day7.Parser
|
||||
import Day7.Interpreter
|
||||
import qualified Data.Map as Map
|
||||
|
||||
inputPart1 :: String
|
||||
@@ -72,10 +73,6 @@ cdOutParsed = [
|
||||
Listing [FileListing "f" 23, DirListing "foo", DirListing "bar"]
|
||||
]
|
||||
|
||||
forceRight :: Either a b -> b
|
||||
forceRight (Left _) = error "forced Right but got Left"
|
||||
forceRight (Right b) = b
|
||||
|
||||
spec :: Spec
|
||||
spec =
|
||||
describe "Day7" $ do
|
||||
@@ -129,5 +126,5 @@ spec =
|
||||
let parsed = forceRight $ parseTerminalLines inputPart1
|
||||
let tree = buildTree parsed
|
||||
let filtered = filterDirectories (<= 100000) tree
|
||||
let summed = sumUp filtered
|
||||
let summed = sum filtered
|
||||
summed `shouldBe` 95437
|
||||
|
||||
64
test/Day8Spec.hs
Normal file
64
test/Day8Spec.hs
Normal file
@@ -0,0 +1,64 @@
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
module Day8Spec (spec) where
|
||||
|
||||
import Test.Hspec
|
||||
import Text.Heredoc
|
||||
import Control.Arrow ((>>>))
|
||||
|
||||
import qualified Data.Matrix as M
|
||||
import qualified Data.Vector as V
|
||||
import Day8
|
||||
|
||||
testInput :: String
|
||||
testInput = [str|30373
|
||||
|25512
|
||||
|65332
|
||||
|33549
|
||||
|35390
|
||||
|]
|
||||
|
||||
testVisibility :: Visibillity
|
||||
testVisibility = M.fromList 5 5
|
||||
[x,x,x,x,x,
|
||||
x,x,x,o,x,
|
||||
x,x,o,x,x,
|
||||
x,o,x,o,x,
|
||||
x,x,x,x,x]
|
||||
where
|
||||
x = True
|
||||
o = False
|
||||
|
||||
smallForest :: String
|
||||
smallForest = [str|1234
|
||||
|5678
|
||||
|9012
|
||||
|]
|
||||
|
||||
parsedSmallForest :: Forest
|
||||
parsedSmallForest = M.fromList 3 4 $ [1..9] ++ [0,1,2]
|
||||
|
||||
spec :: Spec
|
||||
spec =
|
||||
describe "Day8" $ do
|
||||
describe "Part1" $ do
|
||||
it "parses a forest" $ do
|
||||
parseForest smallForest `shouldBe` parsedSmallForest
|
||||
it "checks visibility" $ do
|
||||
let forest = parseForest testInput
|
||||
checkVisibility forest `shouldBe` testVisibility
|
||||
it "counts visible things" $ do
|
||||
let v = parseForest >>>
|
||||
checkVisibility >>>
|
||||
countVisible $ testInput
|
||||
v `shouldBe` 21
|
||||
describe "Part2" $ do
|
||||
it "calculates viewing distance from height" $ do
|
||||
viewingDistance 5 (V.fromList [3]) `shouldBe` 1
|
||||
viewingDistance 5 (V.fromList [5,2]) `shouldBe` 1
|
||||
viewingDistance 5 (V.fromList [1,2]) `shouldBe` 2
|
||||
viewingDistance 5 (V.fromList [3,5,3]) `shouldBe` 2
|
||||
it "calculates the scenic score" $ do
|
||||
let s = parseForest >>>
|
||||
findMaxScenicScore $ testInput
|
||||
s `shouldBe` 8
|
||||
|
||||
102
test/Day9Spec.hs
Normal file
102
test/Day9Spec.hs
Normal file
@@ -0,0 +1,102 @@
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
|
||||
module Day9Spec (spec) where
|
||||
|
||||
import Control.Arrow ((>>>))
|
||||
import Day9
|
||||
import Test.Hspec
|
||||
import Text.Heredoc
|
||||
import Data.List (sort)
|
||||
|
||||
testInput :: String
|
||||
testInput =
|
||||
[str|R 4
|
||||
|U 4
|
||||
|L 3
|
||||
|D 1
|
||||
|R 4
|
||||
|D 1
|
||||
|L 5
|
||||
|R 2
|
||||
|]
|
||||
|
||||
expectedPositions :: [(Int, Int)]
|
||||
expectedPositions = sort [
|
||||
(2,4),(3,4),
|
||||
(3,3),(4,3),
|
||||
(1,2),(2,2),(3,2),(4,2),
|
||||
(4,1),
|
||||
(0,0),(1,0),(2,0),(3,0)
|
||||
]
|
||||
|
||||
testInput2 :: String
|
||||
testInput2 = [str|R 5
|
||||
|U 8
|
||||
|L 8
|
||||
|D 3
|
||||
|R 17
|
||||
|D 10
|
||||
|L 25
|
||||
|U 20
|
||||
|]
|
||||
|
||||
spec :: Spec
|
||||
spec =
|
||||
describe "Day9" $ do
|
||||
describe "Part1" $ do
|
||||
it "parses the instructions" $ do
|
||||
parseMovements testInput
|
||||
`shouldBe` [ right 4,
|
||||
up 4,
|
||||
left 3,
|
||||
down 1,
|
||||
right 4,
|
||||
down 1,
|
||||
left 5,
|
||||
right 2
|
||||
]
|
||||
it "moves a step" $ do
|
||||
step (0, 0) (Step (1, 1)) `shouldBe` (1, 1)
|
||||
step (0, 0) (Step (1, 0)) `shouldBe` (1, 0)
|
||||
step (1, 0) (Step (-1, 0)) `shouldBe` (0, 0)
|
||||
step (0, 1) (Step (0, -1)) `shouldBe` (0, 0)
|
||||
it "normalizes movement" $ do
|
||||
normalizeMovement still `shouldBe` []
|
||||
normalizeMovement (left 2) `shouldBe` [Step (-1, 0),Step (-1, 0)]
|
||||
normalizeMovement (right 1) `shouldBe` [Step (1, 0)]
|
||||
normalizeMovement (up 1) `shouldBe` [Step (0, 1)]
|
||||
normalizeMovement (down 2) `shouldBe` [Step (0, -1), Step (0, -1)]
|
||||
it "follows the head" $ do
|
||||
follow (1, 0) (0, 0) `shouldBe` Step (0, 0)
|
||||
follow (0, 1) (0, 0) `shouldBe` Step (0, 0)
|
||||
follow (1, 1) (0, 0) `shouldBe` Step (0, 0)
|
||||
follow (2, 1) (0, 0) `shouldBe` Step (1, 1)
|
||||
follow (1, 2) (0, 0) `shouldBe` Step (1, 1)
|
||||
follow (2, 2) (0, 0) `shouldBe` Step (1, 1)
|
||||
follow (4, 2) (3, 0) `shouldBe` Step (1, 1)
|
||||
it "moves around and records tail position" $ do
|
||||
let positions = parseMovements
|
||||
>>> concatMap normalizeMovement
|
||||
>>> recordPositions
|
||||
>>> fst
|
||||
>>> sort
|
||||
$ testInput
|
||||
length positions `shouldBe` 13
|
||||
positions `shouldBe` expectedPositions
|
||||
it "solves the riddle" $ do
|
||||
input <- readFile "ressources/day09-input"
|
||||
let headSteps = parseMovements >>> concatMap normalizeMovement $ input
|
||||
let allTails = buildTails headSteps
|
||||
let positions = (!! 1) >>> fst >>> length $ allTails
|
||||
positions `shouldBe` 5878
|
||||
it "solves example of part 2" $ do
|
||||
let headSteps = parseMovements >>> concatMap normalizeMovement $ testInput2
|
||||
let allTails = buildTails headSteps
|
||||
let tail9Positions = fst $ allTails !! 9
|
||||
length tail9Positions `shouldBe` 36
|
||||
it "solves the riddle part 2" $ do
|
||||
input <- readFile "ressources/day09-input"
|
||||
let headSteps = parseMovements >>> concatMap normalizeMovement $ input
|
||||
let allTails = buildTails headSteps
|
||||
let positions = (!! 9) >>> fst >>> length $ allTails
|
||||
positions `shouldBe` 2405
|
||||
Reference in New Issue
Block a user