Compare commits
10 commits
a390ad9988
...
3b12de4970
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3b12de4970 | ||
|
|
a1f97bac83 | ||
|
|
2ad5f62785 | ||
|
|
0b388cbd13 | ||
|
|
6509fc79ea | ||
|
|
54fd03233a | ||
|
|
f630ef6874 | ||
|
|
a2f7808f6d | ||
|
|
745abc936e | ||
|
|
5a6abbd73c |
34 changed files with 6701 additions and 4 deletions
|
|
@ -7,5 +7,7 @@ edition = "2021"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
itertools = "0.10"
|
itertools = "0.10"
|
||||||
num-traits = "0.2.15"
|
lazy_static = "1.4"
|
||||||
|
num-traits = "0.2"
|
||||||
|
regex = "1.7"
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
|
|
|
||||||
23
data/day07/example01.txt
Normal file
23
data/day07/example01.txt
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
$ cd /
|
||||||
|
$ ls
|
||||||
|
dir a
|
||||||
|
14848514 b.txt
|
||||||
|
8504156 c.dat
|
||||||
|
dir d
|
||||||
|
$ cd a
|
||||||
|
$ ls
|
||||||
|
dir e
|
||||||
|
29116 f
|
||||||
|
2557 g
|
||||||
|
62596 h.lst
|
||||||
|
$ cd e
|
||||||
|
$ ls
|
||||||
|
584 i
|
||||||
|
$ cd ..
|
||||||
|
$ cd ..
|
||||||
|
$ cd d
|
||||||
|
$ ls
|
||||||
|
4060174 j
|
||||||
|
8033020 d.log
|
||||||
|
5626152 d.ext
|
||||||
|
7214296 k
|
||||||
1135
data/day07/input.txt
Normal file
1135
data/day07/input.txt
Normal file
File diff suppressed because it is too large
Load diff
5
data/day08/example01.txt
Normal file
5
data/day08/example01.txt
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
30373
|
||||||
|
25512
|
||||||
|
65332
|
||||||
|
33549
|
||||||
|
35390
|
||||||
99
data/day08/input.txt
Normal file
99
data/day08/input.txt
Normal file
|
|
@ -0,0 +1,99 @@
|
||||||
|
131102031022411233124153000402524132243245422402002121234345453535321113450535302430144220243210033
|
||||||
|
210030011133442111442145434004231353202400601331445042106230540242340014332243105022302133441101011
|
||||||
|
201302044230110302341330012044051130055046354663404014033243655520410125432425532024143403330032232
|
||||||
|
210303103204034020151134514120046162664361356330261302226530654326452225134535222440444443410101130
|
||||||
|
021310332113230035544033314213544254421233042151226601345516101654005025035545035333140023212102212
|
||||||
|
220140301231432453044535532323066560244052510442522465306425021511260132313424322110345422300411332
|
||||||
|
103013240142011245425311001542145655516105003352455141424412415222100145355043202120423034202120403
|
||||||
|
314103304322445325255534650156565303510461206034672755654106425161056213552330050310445352323213402
|
||||||
|
243430113305332145305400366156126611120357766767667531265661631510215134106224240155532142014202020
|
||||||
|
344044011305120500223111213354316112154646744635155132374774442641061323024416155344101304242413014
|
||||||
|
210001340311202411013214565026366577746364242672331436164352252445110000414212215202321411504422400
|
||||||
|
001030344254033552521244445311464542617442572153467545366653342426676363026234406640015310103000111
|
||||||
|
123004351234415456501532136126535464236513321263256111263236363424471316560661104630322511135024314
|
||||||
|
243444301010130503501065440067414335615573435151661324666436573133444251763541254166141130405531401
|
||||||
|
301333054435342646553265615125271561444757162666247563564724434377461174733226461663122454115301022
|
||||||
|
313333115034033032461152521554721624436564356545874583322623147632365263427634464233444421123452114
|
||||||
|
434441324240044110131332722354256132333522657745624745724323263635746316535120231124164652542245541
|
||||||
|
020013043025261604606066777717675561448878622688884553346728286853164272251311263510330645452212040
|
||||||
|
225405401530036646635664123763243188844858643328244728344354343287813231363771264361344552214134043
|
||||||
|
444013205241103641532477643143435563484567276423226466226434857664377176552653732212146514023430325
|
||||||
|
235444033555452351644577725572733823223422438445886848336238372267477767173715122521014452405344110
|
||||||
|
022222500504231055646646534633724257646568684735488756288737857786232268232655151633323530463425151
|
||||||
|
412102254551210100735562467375656382325864659764674335534465738553284326347575542675435335613154320
|
||||||
|
202304233522424114651647265763556544532358373769578879369385574555386666783363244334360301665155255
|
||||||
|
400235422666401262236327746826382638573848989589958764697958946664233887757677777164614616200413302
|
||||||
|
413211350405512664175712772346875822558798479568486643787487763573785465875336133314155235265153544
|
||||||
|
412112650043523364626154522655787734369585968849884958638795656846722736645822544573361050432101002
|
||||||
|
040151232015244534675233447267274466883354564933934639355395374945757347634723116764261154205631025
|
||||||
|
053511566106055552733487866435428673379594867554589579573759867856436754328455243315565403452366550
|
||||||
|
402441261342655261311663778728277373873487457867467678497684746937764462833722831553364205512206541
|
||||||
|
401560462601374333165687778774966694644847875679669694796453568554383377242683474675113640166014002
|
||||||
|
245431640441276372256235534578677594558499466595957658548574676357557473852362834636123725105611001
|
||||||
|
140325466637452621767678632447835458776865576466546548894776445753494487385328422645157221103664133
|
||||||
|
253440020224216474125727543697395446885846849486744757588954688447585337348374328857266123303626032
|
||||||
|
522360463154354425644334277863647479565896696996775849896649575745746557964548536537415577142552050
|
||||||
|
402351634474624167474857559553949899894799879644496759587555549787974996993634823833353424316316042
|
||||||
|
414140006077774645384224689955449865767867876647679668857949995687773539976755288762714471242526254
|
||||||
|
032242255462211412258653836566746764685477947565799869886769647489953985859547537844111624535631156
|
||||||
|
241646435225236526565228495485878686676559956669957869665758947786478934645637286347261114426145563
|
||||||
|
512215356337536722737525437473645894558456658976958699776986594778559569864962457825216143344215016
|
||||||
|
322625244746336257345525895486859454957989669585766859958667775649875866654855238722721513671212305
|
||||||
|
044600535247217686848675385837958687859856856865869679556868995579875763985654342678317263541605554
|
||||||
|
430320424173321746345287493633447589689698796959599858768985856685945573454358785585284454656334025
|
||||||
|
232026013361136674773333583555589876467998965697988698997966777468454666855894285223681327425505166
|
||||||
|
354332536226232536453676489538955896788985786767799998876886965757444485955456462568453444425456521
|
||||||
|
016154147271566788586769489946847647867857556667888797775895768988576579978395627453672756147414326
|
||||||
|
463454162462563733454784956555887864475857986666689767978699985965647598648778424456255355723655466
|
||||||
|
021001072567511684363734454496747746785559778677966778897776558954997794766634668356686124441524525
|
||||||
|
234605435156344755776859794859864756797769876888968689787579998559856654953446748662382433262116262
|
||||||
|
030666223611312438477278595797684446757958596668696976678757986797965899875556377876865147373650335
|
||||||
|
245046541536764737224694794369857786796969878968689968797958865856864988656773724353268427134461620
|
||||||
|
265066622261247542566375373496969757789659688887789988798956868878668565665794723743572475263161166
|
||||||
|
422245453144736877586299945587888888767997586686876996879786788998867747683776448657845662361505315
|
||||||
|
210351625547722865278485967857788659769765586689699988976775596895984657648869967252632246417436621
|
||||||
|
141004614422116428487735355858968995455599988699767679796595755979678769336598642342483777532511004
|
||||||
|
533362561377622426377686383498446767487997987976886899988585956569875694463399574483265564264622314
|
||||||
|
456163507723454276868637866355647859456998677889778989889969998954684957667483346372863274465245646
|
||||||
|
030644251421316636263479555487765499846688669798677798668968599994746869757876565775844144255106462
|
||||||
|
510135336311735337436764935399965949469956999767696876898578576969547984463869253278467243311543030
|
||||||
|
466524526117724766584368696865578944888566858759789698699778689456856774865884337672615767136523254
|
||||||
|
254110631463762333865539645936466585858655857657659586556989585456479575455563845762632676471423233
|
||||||
|
562434653773762262468663566995359545869887797866957588766855659579865834576343438465353323754454240
|
||||||
|
112066240641477224475587449447989749648974898785555767886979489566644938356955638286634724441631625
|
||||||
|
330443313353347713822865768695549469777556759786896565758769775757475566378642426537546311412140051
|
||||||
|
040065350247621726448577745444446666557767548565886798996759654466566755698345662584625446342463260
|
||||||
|
330536625076531353825376746548345995946649894668956867559446757474398638639624464682343654214032311
|
||||||
|
530251120326432762683357643388548466489576697998869899549584977659746869733837538723573545213461105
|
||||||
|
255356015316555756432734833639785737748988987965669458947565666746847669548847254811135737404226043
|
||||||
|
454354550123557227257454326863468487794448666674495859497588676766356646553276336612337324063553462
|
||||||
|
144340525160235512164242786385886753536996894579865659848488534457479379684556654637432614663443613
|
||||||
|
305316054035171372138527636345993984687638579458566486795488343446895753373444445772513544116215313
|
||||||
|
543055400456632262131666826787874497775946535566897457748984377394483964377555447341647525602315351
|
||||||
|
412546632444321676125286364645444448636496473746537653585847369856994564666782226566264742530022340
|
||||||
|
044233444612165527122563533685825959374668734768758953663536843946435452847223172365277563546141540
|
||||||
|
340030454102343151253211647666557354334348799955649644348678747758347287426221514313112316663165454
|
||||||
|
011020051334501654522762446268866586389746656669789443696677886848328248582411315534364123146250501
|
||||||
|
305413453334030464614216442476475733478966457359966737766476988846463467574624373625606065562242335
|
||||||
|
034215112203016427473135421577622448726677469646375339565639944867546662453345521671403262325021214
|
||||||
|
132210543140531252452317342463454885388566728556533533877354846446665578244115675240031664244524501
|
||||||
|
201140051634662646614612354714626525722377445426842485568735384726362363654642742661135663265002510
|
||||||
|
025011353243541235316415314133578633558245363633567643474723462264656821637416273202656565602515322
|
||||||
|
121540314222665224011553176734444466578255884322834667368468238484254776573264467333645106223352155
|
||||||
|
233134314541654641520531771126551528746557387438726348653238283875537147555615754035502132555444301
|
||||||
|
424510000505066600303343337525732714723283556468834467558232644677477536766533666404266150255104242
|
||||||
|
041433452552331436330125237255465337374884372735358382327855756643676341445255435062065033314033212
|
||||||
|
141025211241314363206626056633223121353133645783244374622462256271457773212200625560321421020100213
|
||||||
|
224101010422251643133220616233621223532466525114754865347141165612135423157400060111225313054434032
|
||||||
|
004040052225144131342364656025377722754756627621767354111575442445436452322335541156250421012350243
|
||||||
|
043322120521041516241540153402233524371432721521521276133447761312616332565246332656140342120501432
|
||||||
|
200232013354533102134562014146621725413251577715376671261144475237357064044430050234040121014304202
|
||||||
|
011420212054031401033241133121106532344212712314572323662643147467661343340045361122545415103011124
|
||||||
|
102223410325432324313243446514164004156475643254444557477323147134144354265066260422110450012141414
|
||||||
|
031411112311321035125554420606413626050373327654774373667767140605036115333551650220414205214132024
|
||||||
|
210204032200320524351051665115025502044361230251377575706601164652440120455165201034431244211004301
|
||||||
|
331131223444034015143142430503454436431142412165246111316106164251614223504203533022310134023423343
|
||||||
|
120300034332102045152234220042512653414152606411234665213124345325420542210314454221024423343223220
|
||||||
|
200230420442302210441134513143532363040132120013505235035543064245636124512505054404233133430423011
|
||||||
|
000202411243122420140310501035333204626352325031215630345206242502134153000033354044334042221310101
|
||||||
|
111301302244231442013332415144033330063530643146335532313306033656410450441505505240142210004121122
|
||||||
8
data/day09/example01.txt
Normal file
8
data/day09/example01.txt
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
R 4
|
||||||
|
U 4
|
||||||
|
L 3
|
||||||
|
D 1
|
||||||
|
R 4
|
||||||
|
D 1
|
||||||
|
L 5
|
||||||
|
R 2
|
||||||
8
data/day09/example02.txt
Normal file
8
data/day09/example02.txt
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
R 5
|
||||||
|
U 8
|
||||||
|
L 8
|
||||||
|
D 3
|
||||||
|
R 17
|
||||||
|
D 10
|
||||||
|
L 25
|
||||||
|
U 20
|
||||||
2000
data/day09/input.txt
Normal file
2000
data/day09/input.txt
Normal file
File diff suppressed because it is too large
Load diff
146
data/day10/example01.txt
Normal file
146
data/day10/example01.txt
Normal file
|
|
@ -0,0 +1,146 @@
|
||||||
|
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
|
||||||
6
data/day10/expected01.txt
Normal file
6
data/day10/expected01.txt
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
## ## ## ## ## ## ## ## ## ##
|
||||||
|
### ### ### ### ### ### ###
|
||||||
|
#### #### #### #### ####
|
||||||
|
##### ##### ##### #####
|
||||||
|
###### ###### ###### ####
|
||||||
|
####### ####### #######
|
||||||
143
data/day10/input.txt
Normal file
143
data/day10/input.txt
Normal file
|
|
@ -0,0 +1,143 @@
|
||||||
|
noop
|
||||||
|
addx 26
|
||||||
|
addx -21
|
||||||
|
addx 2
|
||||||
|
addx 3
|
||||||
|
noop
|
||||||
|
noop
|
||||||
|
addx 23
|
||||||
|
addx -17
|
||||||
|
addx -1
|
||||||
|
noop
|
||||||
|
noop
|
||||||
|
addx 7
|
||||||
|
noop
|
||||||
|
addx 3
|
||||||
|
addx 1
|
||||||
|
noop
|
||||||
|
noop
|
||||||
|
addx 2
|
||||||
|
noop
|
||||||
|
addx 7
|
||||||
|
noop
|
||||||
|
addx -12
|
||||||
|
addx 13
|
||||||
|
addx -38
|
||||||
|
addx 5
|
||||||
|
addx 34
|
||||||
|
addx -2
|
||||||
|
addx -29
|
||||||
|
addx 2
|
||||||
|
addx 5
|
||||||
|
addx 2
|
||||||
|
addx 3
|
||||||
|
addx -2
|
||||||
|
addx -1
|
||||||
|
addx 8
|
||||||
|
addx 2
|
||||||
|
addx 6
|
||||||
|
addx -26
|
||||||
|
addx 23
|
||||||
|
addx -26
|
||||||
|
addx 33
|
||||||
|
addx 2
|
||||||
|
addx -37
|
||||||
|
addx -1
|
||||||
|
addx 1
|
||||||
|
noop
|
||||||
|
noop
|
||||||
|
noop
|
||||||
|
addx 5
|
||||||
|
addx 5
|
||||||
|
addx 3
|
||||||
|
addx -2
|
||||||
|
addx 2
|
||||||
|
addx 5
|
||||||
|
addx 5
|
||||||
|
noop
|
||||||
|
noop
|
||||||
|
addx -2
|
||||||
|
addx 4
|
||||||
|
noop
|
||||||
|
noop
|
||||||
|
noop
|
||||||
|
addx 3
|
||||||
|
noop
|
||||||
|
noop
|
||||||
|
addx 7
|
||||||
|
addx -1
|
||||||
|
addx -35
|
||||||
|
addx -1
|
||||||
|
addx 5
|
||||||
|
addx 3
|
||||||
|
noop
|
||||||
|
addx 4
|
||||||
|
noop
|
||||||
|
noop
|
||||||
|
noop
|
||||||
|
noop
|
||||||
|
noop
|
||||||
|
addx 5
|
||||||
|
addx 1
|
||||||
|
noop
|
||||||
|
noop
|
||||||
|
noop
|
||||||
|
addx -7
|
||||||
|
addx 12
|
||||||
|
addx 2
|
||||||
|
addx 7
|
||||||
|
noop
|
||||||
|
addx -2
|
||||||
|
noop
|
||||||
|
noop
|
||||||
|
addx 7
|
||||||
|
addx 2
|
||||||
|
addx -39
|
||||||
|
noop
|
||||||
|
noop
|
||||||
|
addx 5
|
||||||
|
addx 2
|
||||||
|
addx -4
|
||||||
|
addx 25
|
||||||
|
addx -18
|
||||||
|
addx 7
|
||||||
|
noop
|
||||||
|
addx -2
|
||||||
|
addx 5
|
||||||
|
addx 2
|
||||||
|
addx 6
|
||||||
|
addx -5
|
||||||
|
addx 2
|
||||||
|
addx -22
|
||||||
|
addx 29
|
||||||
|
addx -21
|
||||||
|
addx -7
|
||||||
|
addx 31
|
||||||
|
addx 2
|
||||||
|
noop
|
||||||
|
addx -36
|
||||||
|
addx 1
|
||||||
|
addx 5
|
||||||
|
noop
|
||||||
|
addx 1
|
||||||
|
addx 4
|
||||||
|
addx 5
|
||||||
|
noop
|
||||||
|
noop
|
||||||
|
noop
|
||||||
|
addx 3
|
||||||
|
noop
|
||||||
|
addx -13
|
||||||
|
addx 15
|
||||||
|
noop
|
||||||
|
addx 5
|
||||||
|
noop
|
||||||
|
addx 1
|
||||||
|
noop
|
||||||
|
addx 3
|
||||||
|
addx 2
|
||||||
|
addx 4
|
||||||
|
addx 3
|
||||||
|
noop
|
||||||
|
addx -3
|
||||||
|
noop
|
||||||
27
data/day11/example01.txt
Normal file
27
data/day11/example01.txt
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
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
|
||||||
55
data/day11/input.txt
Normal file
55
data/day11/input.txt
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
Monkey 0:
|
||||||
|
Starting items: 97, 81, 57, 57, 91, 61
|
||||||
|
Operation: new = old * 7
|
||||||
|
Test: divisible by 11
|
||||||
|
If true: throw to monkey 5
|
||||||
|
If false: throw to monkey 6
|
||||||
|
|
||||||
|
Monkey 1:
|
||||||
|
Starting items: 88, 62, 68, 90
|
||||||
|
Operation: new = old * 17
|
||||||
|
Test: divisible by 19
|
||||||
|
If true: throw to monkey 4
|
||||||
|
If false: throw to monkey 2
|
||||||
|
|
||||||
|
Monkey 2:
|
||||||
|
Starting items: 74, 87
|
||||||
|
Operation: new = old + 2
|
||||||
|
Test: divisible by 5
|
||||||
|
If true: throw to monkey 7
|
||||||
|
If false: throw to monkey 4
|
||||||
|
|
||||||
|
Monkey 3:
|
||||||
|
Starting items: 53, 81, 60, 87, 90, 99, 75
|
||||||
|
Operation: new = old + 1
|
||||||
|
Test: divisible by 2
|
||||||
|
If true: throw to monkey 2
|
||||||
|
If false: throw to monkey 1
|
||||||
|
|
||||||
|
Monkey 4:
|
||||||
|
Starting items: 57
|
||||||
|
Operation: new = old + 6
|
||||||
|
Test: divisible by 13
|
||||||
|
If true: throw to monkey 7
|
||||||
|
If false: throw to monkey 0
|
||||||
|
|
||||||
|
Monkey 5:
|
||||||
|
Starting items: 54, 84, 91, 55, 59, 72, 75, 70
|
||||||
|
Operation: new = old * old
|
||||||
|
Test: divisible by 7
|
||||||
|
If true: throw to monkey 6
|
||||||
|
If false: throw to monkey 3
|
||||||
|
|
||||||
|
Monkey 6:
|
||||||
|
Starting items: 95, 79, 79, 68, 78
|
||||||
|
Operation: new = old + 3
|
||||||
|
Test: divisible by 3
|
||||||
|
If true: throw to monkey 1
|
||||||
|
If false: throw to monkey 3
|
||||||
|
|
||||||
|
Monkey 7:
|
||||||
|
Starting items: 61, 97, 67
|
||||||
|
Operation: new = old + 4
|
||||||
|
Test: divisible by 17
|
||||||
|
If true: throw to monkey 0
|
||||||
|
If false: throw to monkey 5
|
||||||
5
data/day12/example01.txt
Normal file
5
data/day12/example01.txt
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
Sabqponm
|
||||||
|
abcryxxl
|
||||||
|
accszExk
|
||||||
|
acctuvwj
|
||||||
|
abdefghi
|
||||||
41
data/day12/input.txt
Normal file
41
data/day12/input.txt
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
abcccaaaaaaccccccccaaaaaccccccaaaaaaccccccaaaaaaaacccaaaaaaaccaaaacccccccccccccccccccccccccaaaaaacccccccccccccccccccccccccccccaaaaaa
|
||||||
|
abcccaaaaaacccccccaaaaaaccccaaaaaaaacccccccaaaaaaaaaaaaaaaaccaaaaacccccccccccccccccccccccccaaaaaacccccccccccccccccccccccccccccaaaaaa
|
||||||
|
abccccaaaaacaaaccaaaaaaaacccaaaaaaaaacccccccaaaaaaaaaaaaaaaacaaaaaacccccccccaaacccccccccccaaaaaaaaccccccccccaaccccccccccccccccaaaaaa
|
||||||
|
abccccaaaaccaaaaaaaaaaaaacccaaaaaaaaaacccccaaaaaaaaaaaaaaaaaaacaaaacccccccccaaaacccccccccaaaaaaaaaacccccccccaaaccccccccccccccccccaaa
|
||||||
|
abcccccccccaaaaaacccaacccccccccaaacaaaccccccaacccccccaaaaaaaaacaacccccccccccaaaacccccccccaaaaaaaaaacccccccccaaaccacaaccccccccccccaaa
|
||||||
|
abcccccccccaaaaaacccaacccccccccaaacccccccccccccccccccaaaacaaaacccccccaacaaccaaaccccccccccaccaaaaacacccccccccaaaacaaaaccccccccccccaac
|
||||||
|
abccccccccccaaaaacccccccccccccccacccaaaacccccccccccccaaaacccccccccccccaaaacccccccccccaacccccaaaaccccccccjjjjaaaaaaaaaccccccccccccccc
|
||||||
|
abccccccccccaaaacccccccccccccccccccaaaaacccccccccccccaaaccccccccccccccaaaaacccccccccaaaaaacccaaccccccccjjjjjjkkaaaacccccccccaacccccc
|
||||||
|
abcccccaaccccccccccccccccccccccccccaaaaaacccccccccccccaacccccccccccccaaaaaaccccccccccaaaaaccccccccccccjjjjjjjkkkkaacccccaacaaacccccc
|
||||||
|
abccaaaacccccccccccccccccccccccccccaaaaaaccccccccccccccccccccccccccccaaaacaccccccccaaaaaaaccccaacccccjjjjoooookkkkkkkklllaaaaaaacccc
|
||||||
|
abccaaaaaacccccccccccccccccccccccccaaaaacccccccccccccccccccccccccccccccaaccccccccccaaaaaaaaccaaaaccccjjjoooooookkkkkkkllllaaaaaacccc
|
||||||
|
abcccaaaaacccccccccccccccccccccccccccaaaccccccccaaaacccccccccccccccccccccccccccccccaaaaaaaaccaaaaccccjjooooooooppkkppplllllaccaacccc
|
||||||
|
abccaaaaaccccccccccccaccccccccccccccccccccccccccaaaacccccccccccccccccccccccccccccccccaaacacccaaaacccijjooouuuuoppppppppplllccccccccc
|
||||||
|
abcccccaacccccccccccaaaaaaaaccccccccccccccccccccaaaaccccaaccccccccaaacccccccccccccaacaaccccccccccccciijoouuuuuuppppppppplllcccaccccc
|
||||||
|
abcccccccccccccccccccaaaaaaccccccccccccccccccccccaaccccaaaacccccccaaaaccccccccccaaaaaaccccccccccccciiiiootuuuuuupuuuvvpppllccccccccc
|
||||||
|
abcccccccccccccccccccaaaaaaccaaaaacccccccccccccccccccccaaaacccccccaaaaccccccccccaaaaaaccccccccccccciiinnotuuxxxuuuuvvvpppllccccccccc
|
||||||
|
abccccccccccccccacccaaaaaaaacaaaaaaacccccccccccccccccccaaaacccccccaaacccccaaaaccaaaaaccccaaccccccciiiinnnttxxxxuuyyyvvqqqllccccccccc
|
||||||
|
abcccccccccccaaaaccaaaaaaaaaaaaaaaaaaccaacccccccccccccccccccccccccccccccccaaaacccaaaaaccaaacccccciiinnnnnttxxxxxyyyyvvqqqllccccccccc
|
||||||
|
abaaaacccccccaaaaaaaaaaaaaaaaaaaaaaaaaaaacccccccccccccccccccccccccccccccccaaaacccaaaaaacaaaccccciiinnnnttttxxxxxyyyyvvqqmmmccccccccc
|
||||||
|
abaaaaccccccccaaaaacccaaaaacaaaaaacaaaaaaccccccccccccccccaaccccccccccccccccaacccccccaaaaaaaaaaciiinnnnttttxxxxxyyyyvvqqqmmmccccccccc
|
||||||
|
SbaaaacccccccaaaaaccccaaaaaccaaaaaaaaaaaccccccccccccccccaaacaacccccccccccccccccccccccaaaaaaaaachhhnnntttxxxEzzzzyyvvvqqqmmmccccccccc
|
||||||
|
abaaaacccccccaacaacccccaaaaaaaacaaaaaaaaaccccccccccccccccaaaaaccccccccccccccccccccccccaaaaaaacchhhnnntttxxxxxyyyyyyvvvqqmmmdddcccccc
|
||||||
|
abaaaacccccccccccccccccccaaaaaacaaaaaaaaaacccccccccccccaaaaaaccccccccaaaccccccccccccccaaaaaaccchhhnnntttxxxxywyyyyyyvvvqqmmmdddccccc
|
||||||
|
abaacccccccccccccccccccaaaaaaacccccaaaaaaacccccccccccccaaaaaaaacccccaaaacccccccccccccaaaaaaacaahhhmmmttttxxwwyyyyyyyvvvqqmmmdddccccc
|
||||||
|
abcccccccccccccccccccccaaaaaaacaaccaaacccccccccccccccccaacaaaaacccccaaaacccccccccccccaaacaaaaaahhhmmmmtsssswwyywwwwvvvvqqqmmdddccccc
|
||||||
|
abcccccccccccccccaaaccccaaaaaaaaaacaaccaaccccccccccccccccaaacaccccccaaaacccccccccccccccccaaaaacahhhmmmmmsssswwywwwwwvvrrqqmmdddccccc
|
||||||
|
abcccccccccccccaaaaaaccccaaaaaaaaaccaaaacccccccccccccccccaacccccccccccccccccccccccaaaccccaaaaaaahhhhhmmmmssswwwwwrrrrrrrrmmmmddccccc
|
||||||
|
abcccccccccccccaaaaaaccccaaaaaaaaaaaaaaaaaccccccccccccccccccccccccccccccccccccccaaaaaacccccaaaaachhhhhmmmmsswwwwrrrrrrrrrkkmdddccccc
|
||||||
|
abccccccccccccccaaaaaccccccaaaaaaaaaaaaaaaccccccccccccccccccccccccccccccccccccccaaaaaaccccaaaaacccchhggmmmssswwrrrrrkkkkkkkkdddacccc
|
||||||
|
abccaaaacccccccaaaaacccccccccaaaaaacaaaaacccccccccccccccccccccccccccccccccccccccaaaaaaccccaacaaaccccggggmmsssssrrlkkkkkkkkkdddaccccc
|
||||||
|
abccaaaacccccccaaaaacccccccccaaaaaaccccaacccccccccccccccccccccccccccccccccccccccaaaaaccccccccaaccccccgggmllssssrllkkkkkkkeeeddaccccc
|
||||||
|
abccaaaacccccccaaacccccccccccaaaaaacccccccccccccccccccaacccccccccccccccccccccccaaaaaacccccccccccccccccggllllssslllkkeeeeeeeeeaaacccc
|
||||||
|
abcccaaccccccccaaacaaaccccccaaaaaaaaaaacccccccccccccaaaaaacccccccccccccccccccccaaacaaacccccaacccccccccggglllllllllfeeeeeeeeaaaaacccc
|
||||||
|
abccccccccccaaaaaaaaaaccccccccccccaccaaaccacccccccccaaaaaaccccaaccaacccaaccccccaaaaaaacccccaaccccccccccggglllllllfffeeecccaaaaaacccc
|
||||||
|
abccccccccccaaaaaaaaacccccccccccccccaaaaaaaccccccccccaaaaaccccaaaaaacccaaaaaaccaaaaaacccaaaaaaaacccccccggggllllfffffccccccaacccccccc
|
||||||
|
abcccccccccccaaaaaaacccccccccccccccccaaaaaaccaacccccaaaaaccccccaaaaacccaaaaaacaaaaaaacccaaaaaaaaccccccccgggffffffffccccccccccccccccc
|
||||||
|
abccccccccccccaaaaaaacccccccccccccaaaaaaaaacaaaaccccaaaaacaaaaaaaaaacaaaaaaacaaaaaaaaaccccaaaacccccccccccggffffffacccccccccccccccaaa
|
||||||
|
abccccccccccccaaaaaaacaaccccccccccaaaaaaaaacaaaacccccaaaaaaaaaaaaaaaaaaaaaaacaaaaaaaaaacccaaaaacccccccccccaffffaaaaccccccccccccccaaa
|
||||||
|
abccccccccccccaaacaaaaaacccccccccccaaaaaaaacaaaaaaaaaaaaaaaaaaaaaaaaacaaaaaaacccaaacaaaccaaaaaacccccccccccccccccaaaccccccccccccccaaa
|
||||||
|
abccccccccccccaaccaaaaaccccccccccccccaaaaaaaccccaaaaaaaaaaaaccccaacccccaaaaaacccaaaccccccaaccaacccccccccccccccccaaacccccccccccaaaaaa
|
||||||
|
abcccccccccccccccaaaaaaaaccccccccccccaacccacccccccaaaaaaaaaaccccaacccccaaccccccccaccccccccccccccccccccccccccccccccccccccccccccaaaaaa
|
||||||
23
data/day13/example01.txt
Normal file
23
data/day13/example01.txt
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
[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]
|
||||||
449
data/day13/input.txt
Normal file
449
data/day13/input.txt
Normal file
|
|
@ -0,0 +1,449 @@
|
||||||
|
[[1,4,7,4,8],[],[8,0,7,[],[]]]
|
||||||
|
[[10,[5,[0,2,5,3,3],[9,7,9],6],7,9,[2,9,[],4,0]],[8]]
|
||||||
|
|
||||||
|
[[7],[7],[[[3,4,6],1,[1,2,4],[7,5,3,5,2]],[[1,3,2,7],10,[9,9,0,2]],[9],[1,[10,4,7],[5,2,1],[10,9,4,3]],[7,[8,9,9,4],[]]],[],[]]
|
||||||
|
[[8,[[]],[7,3],4],[[[2,3]],10,[[4],[3,9,4],[0,6,5],1,3]],[],[]]
|
||||||
|
|
||||||
|
[[5],[[[],[8,0,4],1],[],2,6,10]]
|
||||||
|
[[[[3,0],[7,10,9]],[9,4,3]]]
|
||||||
|
|
||||||
|
[[2,10,[1,[],5],[[1],[3,0,9,7,2],[6]],[[],[7,0,2]]],[[[0,10]]]]
|
||||||
|
[[3,[[],[5,0,2],2],7,[[0,2,9],2,[4]]],[3,[[4,5]],[[10,2,5,1],[1],9,[3,3,7,7,10],9]],[]]
|
||||||
|
|
||||||
|
[[[[],9,7,[2,8,2,1],[6,3,7,6]],8]]
|
||||||
|
[[[[9,8,2],[10],[9,0,3],0,[3,5,0]]],[]]
|
||||||
|
|
||||||
|
[[[9,10,[1,0,6],[1,2]],[[],[9,5,3],[7,3,10,1],0,0],5,10,[]],[]]
|
||||||
|
[[5,6,1,6],[8,6,5,[7,0,5,[0,4,3,6,6],[8,7,8,5]]],[[[1,2],9,1],10,4,3,[5,[5,10,9,9],7,0,[2,3]]],[[[1,5],[0],0],3,[[]]]]
|
||||||
|
|
||||||
|
[[0,[[4,6,4,8]],3,[10]],[],[6,8,6],[8,[3,[7,7,10,6,5]],[0,8,[7],[],5]],[1,[3,[4,4,8,3,8],3,[1,9,8,3,10],[0,5,8]]]]
|
||||||
|
[[0,[],10]]
|
||||||
|
|
||||||
|
[[[[2,4],[5],10,1],[3,6,3],8,0,9],[9,1,9],[[[1],[2,0,7],[10,2],6,[10,9]],[[10],[1,0,3],5,[1,7],[]],3]]
|
||||||
|
[[9,6,3],[[6,[8,10,3],2,[6,1],10],1],[]]
|
||||||
|
|
||||||
|
[[8,[],[10]],[]]
|
||||||
|
[[[[8,5,6,6,5],1,[10]],[]],[],[],[7],[2,2]]
|
||||||
|
|
||||||
|
[[9,3]]
|
||||||
|
[[0,[1],6,[10,0,6],7],[7,[1,[4,3,10],[],[6,6]],5,[9],7],[7,[[6,2,7,2,5],9,8,7,[9]]],[5]]
|
||||||
|
|
||||||
|
[[9,9,[[10]],[8,[7]]],[8,5,7,[[6,1,8],[9,5],[],10,8],[8,[10],[],[5,3,2]]]]
|
||||||
|
[[[9,9,6],1,0,9,[[0],[8],2,0]],[[9,5],[[],[9]],3,[[0],9,3,0,8],10],[[[4],[8,2],[2,0,3]],3,6,[[3,8]],4]]
|
||||||
|
|
||||||
|
[[4,3,[[10,8,3,1,10],[9]]]]
|
||||||
|
[[[6,[0],[3,4],[0]],[],[6,2,[],1],[[],1,[1,4,3,7],9,4]],[0,[[0],[9,2]],1]]
|
||||||
|
|
||||||
|
[[[[8,4],[7,8,6,10,1],[]],[[2,8,10,4,5],[0,8],7,[1,5],4],8,[1]],[],[]]
|
||||||
|
[[3,[4,[3,3,4]]],[[],1,9,[0]],[[],[[6,9,1],[10,2,3,2,8],3],3,5]]
|
||||||
|
|
||||||
|
[[[[0,3,7],3,[4,0],[6,2,0],4],1,[[3,4,7],8,[1]],2]]
|
||||||
|
[[0,6,[[6,9,6],9,[0],[2,10]],4]]
|
||||||
|
|
||||||
|
[[2,[],6,[[8,10],7,7]],[[[1,2,3,8,3]]],[]]
|
||||||
|
[[[],9,9],[9],[[2,4,8,[7]],[1],1,9]]
|
||||||
|
|
||||||
|
[[1],[[[],[6,7,6,8],0,[2,3]]]]
|
||||||
|
[[[[9,7,2]],3,[8],7,[[3,6,10]]],[[],10]]
|
||||||
|
|
||||||
|
[[3,6,[5]],[5]]
|
||||||
|
[[],[0,[[6,2],[]],3,4,[[6,1,6,10],8,[5,8],5]],[1,4],[[[8]]],[4,3,[[7,2],9,[],3,3],[5,0,[9,0],10],[[7,8,2],3,3,3]]]
|
||||||
|
|
||||||
|
[[[7,[]],[]]]
|
||||||
|
[[[[0,1,2],[3,7,6,5,9],8],[7]],[[[8,6,3,6,2],[7,0,2,5,3],[1,2,1],8]],[7,[2,[0,0,4],[4,1,8],5,[7]],4,2,5]]
|
||||||
|
|
||||||
|
[[9,1,10,[[5],[],[2,1,4],5,0]],[10,[2,9,1],[10,[0,4],9,4],9],[[4,3,6,[0,3,10,6]],[4,[2]],9],[],[]]
|
||||||
|
[[6,[4,[2]],[],10],[[[1,1,5],[5,6,6],7],[2],[[10],[],10],[[3,3],1,5,[1,1,9,4,3]],0],[8,[],[[]],10,1],[1,[],[[7,4,2],1,0,9],2],[[0,9],[[2],9,[9,1,8]],1,[4,1,9,[3]],3]]
|
||||||
|
|
||||||
|
[[[3,[],[9,7]],[[3,0,2,6],2,[0,9,1],[6],[7,4,0,7]],[3,[],[10,1,6,2],0],5,3],[3,[]],[],[2,[[],10,4],[6,[5]]],[]]
|
||||||
|
[[],[],[[7,[1,1],4,7,[6]],[4],[7,3,6,[4,9,8,3],7],[4,8]]]
|
||||||
|
|
||||||
|
[[4,3,8,2,6],[[[8,1]]],[[6,3],[3],[8,[7,7,4,2]]],[8,[6,[10,10,3],0,8],[],7,[10]],[8,0,7,4]]
|
||||||
|
[[5,10],[],[6],[]]
|
||||||
|
|
||||||
|
[[2,6]]
|
||||||
|
[[1,7]]
|
||||||
|
|
||||||
|
[[4,0,[[],[2,6,3],10]],[[],[1]]]
|
||||||
|
[[3,10,2],[[10,[7],[7],5],[[0,4],[9,1,8,8]],1,[9],1]]
|
||||||
|
|
||||||
|
[[3],[[[2,1,5,0]],8,7,[[5,7]],[[],2,8]],[[9,[3,5,2,8]],[[4,7,9],[8,7,4]],[3,10],3,7],[[]]]
|
||||||
|
[[5,[],3],[8,[[2,8,10],[],9,[7,9,7],[3,10,4,1,10]],6],[]]
|
||||||
|
|
||||||
|
[7,7,4,8,0]
|
||||||
|
[7,7,4,8]
|
||||||
|
|
||||||
|
[[],[5],[4,0,[[1]],[[],[0,1,0],[8]],[[9,8],6,[],[8,8,6,1,4]]]]
|
||||||
|
[[],[0,[]]]
|
||||||
|
|
||||||
|
[[[],10],[[[2,7,7,0],[5,5,1,8],0,[]]],[[[5,6,4],0,3,[10,3,2,10,2]],7,9,4,6],[[[],[6],[3,7,4,6,3],4,7]],[4,[]]]
|
||||||
|
[[8]]
|
||||||
|
|
||||||
|
[[],[],[[10,[0,7],9,[3,6],[]]],[5,[1,2,[1],[9,2,3,4]],[[6,7,7,1,10],7],[8],[[10,8],[2,3,5,2,5],[9,9,9,10,7],[8,2]]]]
|
||||||
|
[[7],[],[[[1],9,10,[9,1,1,4],6]],[[[7,4],0,[10,1],9],0,[[],[1,6,6],[]]],[]]
|
||||||
|
|
||||||
|
[[],[10,3,1],[[[9,5,10,10,5],[4,1],5,6,10],0]]
|
||||||
|
[[4,[[8,9,0],0,[0,10,2,4],7,5],[8,2,3,5],0],[],[3,[[0,1,2,10]]],[6,[],[[],0,3,[4,4,4,3,4]],0],[[[5],5,3],[[],[3],4,0,[3,3,6]],4,[0,6,[]],[5,5,7]]]
|
||||||
|
|
||||||
|
[[[],4,[1,0,0,7],10],[],[],[7,[8,[4,0,10]],[[4,5,4,7],6,8,1,[7,10]]],[[[3,6,0],1,8,2],[],10,0,1]]
|
||||||
|
[[4,7,5],[6,[[0,9],[1]],[[2],[8,1,2]],8,[9,[7],7,1,[7,0,6,4]]]]
|
||||||
|
|
||||||
|
[[6,[[6,10,4,3,8],5]],[],[[[8,9,6],[5,9,8,4,4],[3,10,3]],10,9],[[8,3,[6,2,5,1],[1,7,1]],[5,[3,8,3],[2,3,7,5],8],[[7,5,2],[5],[4,1,10],9]],[5,1,7]]
|
||||||
|
[[],[5,[6,[4,0,8,10,0],[9,6]]],[[],6,[[3]]],[]]
|
||||||
|
|
||||||
|
[[2,[]]]
|
||||||
|
[[[]]]
|
||||||
|
|
||||||
|
[[[8,[3,9,1,0,2],[],[1,10,9,10],[1,10,3,2,7]],6,[[8,9,0],[8,1],4]],[[5,[],[3,2,3,2,2]],[],[0,[10],7,3],5],[[10]]]
|
||||||
|
[[0,10,[3,3,7,[1,1,5],5],1],[[1,5,5,7,6],[],[],7],[],[1,[9,8,[4],2]],[[],[0,0,[3],[1]],[5,[9,10,1,1],8,1]]]
|
||||||
|
|
||||||
|
[[10,0,3],[2],[1],[[[9,9,3,10]],[],2]]
|
||||||
|
[[[0,3,[9,1,1,5],6,[]],[8,10,5,1,[8,2,4,0,8]],[[4,9,7,7,4],[7,7,7,5,5],7],[[],[2,10,4,6,2],[6],[6,4,2,2]],2]]
|
||||||
|
|
||||||
|
[[[[9,1,2,6,9],[8,4,5]],0]]
|
||||||
|
[[9,[[6],[],2,7,0],1,[[8,0,9],[5,1,1],10,8]],[3,[[10,3,7,0,1]]],[1,[[],2,3,[5,5],0],[[8,6,1,9,2],10,[],4]],[]]
|
||||||
|
|
||||||
|
[[0,3,6,4]]
|
||||||
|
[[7,3,[5,[5,7],[9,3,7],0],[[7,7,10,2,3]],[10,[0,9,0,5]]],[],[]]
|
||||||
|
|
||||||
|
[[1,1,[2,[1]],[[8,2,7]]],[7],[[3],8],[[[7,1,7],[1,6,5,0,2],7,[4,3],4],1,8,2,[[8,9]]]]
|
||||||
|
[[[10,[],5]],[[3],[6,5,5,[1,2]],8,3]]
|
||||||
|
|
||||||
|
[[6,0,8,6],[2,5,[[10,8,6,0],6,[3,10,7]],[4,[3,9],[4,6,3]],9],[]]
|
||||||
|
[[10,[],[[10,5,6,1,10],5,[9,1,1,8]],[[2,8,8,6,5],10,4,[5,0,2,6,1],5]]]
|
||||||
|
|
||||||
|
[[[[2,8,9,4],[8,9],[7,0],[10]],4,9],[[0,[3,2,4,0]],2,[[0,0],[10,9,1],6,[5,6,3,8]]]]
|
||||||
|
[[[6,10],[9,9],[1],[4,9,6,[3,6],[]]],[6,2,6,[[7,1,4],1,7,[4]],5],[[[10,4,6]],[4]],[5,[[5]],[[7,1,7,0,1],3,2,7,[4,5,7,8]],[10,8]],[[4,[]]]]
|
||||||
|
|
||||||
|
[[10]]
|
||||||
|
[[[7,[]],[10,[0,1,4,6,3],0]]]
|
||||||
|
|
||||||
|
[[5],[8]]
|
||||||
|
[[[3],10,[[7,1,1,5,6],0,4,2],8,[[6,3],[10,2,9],[3,10,3,3],1]]]
|
||||||
|
|
||||||
|
[[],[]]
|
||||||
|
[[2,1]]
|
||||||
|
|
||||||
|
[[],[5,8,2],[[[1,0]],4,[[2,5],8,[6,0],10]],[[[3,8,10,7],8,8,1],1,9]]
|
||||||
|
[[0,4,[[7],0,[],[5,8,7,8,4]],[2,0],4],[2,5,5,[]],[],[0,[[3,3],0,[10,1,0],5]],[]]
|
||||||
|
|
||||||
|
[[[[4,2,8],10],[7],0],[7,[10]],[[6,[],[1,5,8],[2,1,1],8]],[[]],[[[5,5,7]],[[]],[[],[],8],7]]
|
||||||
|
[[],[[[6,7,6,1,2],4,9,[7]],7,10,4],[[],4,1]]
|
||||||
|
|
||||||
|
[[6],[],[8],[[[6],2,9],[[],1,1,[],[2,5,3]],5,8,[[8,3],7,[],[2,10,7,0],9]]]
|
||||||
|
[[8,[[9,9,1,8],6,[6,8],1,7]],[[0,[5,7,8],6,8,6],0,2,4,[[10,6,10,6,8],[8,3,7,5],[0],2,[0]]],[],[[10],[[],[8,9,3,8,2],[6,3,2,1],[7,10,8,7,1]],[7]],[2]]
|
||||||
|
|
||||||
|
[[10,[[4,6],[9,10,8,6,6],[10,6,0],1,0]],[[3],10,[]],[[1],2],[1,[1,[3,1,2],1,10],[[9,1],[2,4,0,10,4]],[0,8,[5,1,9,9,7],3],5],[[[10,4,3,3]],[[3,6,1],1],[[4,2,10,7,3],8,[2,6,0],[6]]]]
|
||||||
|
[[8],[[[9,6,0]],[],[],10],[[[],6,[7],[2,2,9,6]],0,10,1,1],[[[1,7,0],6,10,6,2],3,[]],[2,6,6,[]]]
|
||||||
|
|
||||||
|
[[3,[[2,10,3,2,4],7],2,[[],7]],[],[],[[[1,4,9,3],[],7,[0,7]],0,1,3,4]]
|
||||||
|
[[4,3,[4,1,[]],[[6,5,1],10,4]]]
|
||||||
|
|
||||||
|
[[7],[0,[3,[0,9],10],[[9,5],9,7],1,[0,[0,8,9,3,7],2]],[2],[4],[[[8],4,[7,4],8],9,7,[2,5,8]]]
|
||||||
|
[[10,[[0,3],[9]]]]
|
||||||
|
|
||||||
|
[[[[],9,[8,8,9,10,9]],[],10,10],[10,[],0]]
|
||||||
|
[[0,[],6,3,[[],[]]],[7,[8]],[[[4,3,3,2,9],10,4,[]],5],[]]
|
||||||
|
|
||||||
|
[[3]]
|
||||||
|
[[[3],[],[6,[7,9],[1,7,3],[8]],2,0]]
|
||||||
|
|
||||||
|
[[[[5,8],[5],[7,5,7,6,4]],[[],1,[0,10,3,0,1]]],[]]
|
||||||
|
[[[[6,10],[1,4],[7]]]]
|
||||||
|
|
||||||
|
[[[[6],[9,8,5]],4,[[7,6,3,2],[7,3,6,3],9,[6,4,0,5]],4],[5,[],9,[[],[6,0,9,9],4]],[[],1]]
|
||||||
|
[[[[],6,3],3,[]],[0,1,[8,[1,9,10]],0],[9,[[3,0,6,0,3],0,0],[2,[8,9,3,10]],7,[[6,3,8,9,4],[2]]],[[],0],[6,[6,[4,3]],[],4,[10,9,[2,7,9,8,3],8,[]]]]
|
||||||
|
|
||||||
|
[[5,8,[[1,8],4,[8],[10],0],8],[],[[9,9,10,1],2,[1,8,[4,7,4,1,0],[8],6]],[[],[7,0,[4,2,7,5]],10,[]]]
|
||||||
|
[[0,[5,6],10],[[[2,9,5,1],4,[5,7,6,3,10]],8,[4,[2,4,3],9],5],[],[[9,[4],[9,5]]]]
|
||||||
|
|
||||||
|
[[[],7,[[3],8,5,[8,7]]],[[5,4,3,8,[]],7,[[]],[],[4,[6,7],7,3]]]
|
||||||
|
[[7,2,4,[8,[0,3],1,6,[]]],[],[9,6,[8,9,3,0],[]]]
|
||||||
|
|
||||||
|
[[[],7],[0,10,[0,[9,9],8,7,[8,3,0]]]]
|
||||||
|
[[],[[[1,5],[10,4]],[[2,1,4,1],[3,2],4,[7,9,10,5,4]],7,[]]]
|
||||||
|
|
||||||
|
[[10,4]]
|
||||||
|
[[[[8,3,10]]],[1,[[1,8,9,9,6],[6,5,2,6,3],5],8],[6,8],[10,1,[[4,4,8],7]]]
|
||||||
|
|
||||||
|
[[[[]]],[],[9,8]]
|
||||||
|
[[0,1,8],[1,[5,1,[10,2,4,2,5],8,8],6,2],[4,[4,[3],3,[2,0,3],7],6,[]],[[[8,5,3],10,[1,2,6,6]],4]]
|
||||||
|
|
||||||
|
[[7,[2]],[]]
|
||||||
|
[[[[1,5,10,0,2],1,[8,2,8,2],[5,10,8,2]],4,2,[2],2],[[6,[],[],[]],[[]],9],[9,3],[8,2]]
|
||||||
|
|
||||||
|
[[],[1],[2,[[0],8,9],5,[[10,0,3,5,2],7,2,[9,2,2],[9]],[[7],[]]]]
|
||||||
|
[[6],[[[5,4],[],[4,0]],[[5,3,0],7,[8,2,10,7],[0,8,5],5],[],[0,5],5],[[10,7],4,5,9]]
|
||||||
|
|
||||||
|
[[7,10,3,2],[1]]
|
||||||
|
[[10,[[7,7,9,4,9]],2,[3,8,[],[],10]],[7,[[2,4],7,0,[9]],4,[[10]]]]
|
||||||
|
|
||||||
|
[[4,[2,[],[1],10],4],[[[7],[4,6],[9,1,10,0,4],3,[2]],[[7,4]]],[[4,4,5,0]],[5,1,[[3,0,8,10]]],[3,[[2],[3,8],[],[2,6]],3,[10,[7,3],9],3]]
|
||||||
|
[[[[2,0],[2,4,10,10,9],2],7,10,[],8]]
|
||||||
|
|
||||||
|
[[[[6,4,5,2,9]],1,[3],[6,[10,1],9,[10,10],[3,1,6,10]],5],[[]],[],[8,10,2,10,[[10,8,6],2,[],[10,9,1,10],1]]]
|
||||||
|
[[[],2],[[[7,2,2,9,7],7,2,4],[[2],3,5]]]
|
||||||
|
|
||||||
|
[[[],[[8,5,7],[0,0,10,7]],10],[[0,10]],[[8,6],4,[4],[[],[1,0,4],[5,2,0,3,8],[9,2,5,8]]]]
|
||||||
|
[[0,[[7,7]],0,[],4]]
|
||||||
|
|
||||||
|
[[5,0],[3,[],6,[3,10,0]]]
|
||||||
|
[[[],[4,[10,3,10],[9,4,5,0]],[],[[10,7,6,6,0],1],[10,10,7,[],[1,0,4,0,7]]],[[1],[],[],[4]],[8,[],8,[[2,6,8],2,[2]],10],[[[8,3,3,5,4],[5,8,2,8,9]],4,6],[3,2]]
|
||||||
|
|
||||||
|
[[1]]
|
||||||
|
[[9,1,2,6,3]]
|
||||||
|
|
||||||
|
[[8],[9,[[]],9,[[0,5,8,1],7,0,3,[0,4,1,6]],[[3,8,9,6,3],[],[8,7,4,6,10],[8,7,0]]],[[[5],[9,7,6],[8,3,2],1],8,6,[10,[6,6]],9],[[],10,[7,[6,4,3],[],6,4]],[[3],[[6]],[6,[],[],[9],[10]],9,6]]
|
||||||
|
[[[],2,[0,[3,5],4,9],3,[]]]
|
||||||
|
|
||||||
|
[[[[1],7],[[],4,[4,8,8],[10,7,3,2],[]],[]],[7,1,6,0,[3,0,[1,0,2,6,5],[2,2,9,6,2],[6,9,6,7,10]]]]
|
||||||
|
[[[[3,2,8,9,3],[6,2,4,7],[2,7],[7,2,9,2],[3,4]],[]],[[3,2],[1,2,[9,10,3],[7],[8,8,7,3]],[0],[[4],10,5,3],[6,[],[0],[]]]]
|
||||||
|
|
||||||
|
[[[5,[],[],5],[0,[1,0,5,1,3],10]],[8,[4,10,3,[]],5,1]]
|
||||||
|
[[2,[[8,7],5],5,0],[],[[],5],[[],2,[[9],5,[7,2,1,0],[6,2,8]],[[2,4,2],8,[9,7,8,0,7]],10]]
|
||||||
|
|
||||||
|
[[4,7,[2,3,9],3]]
|
||||||
|
[[[[0],[0,1],7],[1,[]],4],[],[[[5,8,5,8],8,[10,6,8,4,8],[10,3,7,5],10],[]],[[[1,8,6],[5],[9,2,6,3,2]],[1,[9,10,3,2,7],[2,10],10,4],7]]
|
||||||
|
|
||||||
|
[[[],[10],[4,[2],6,[8,1],7],8],[[9,[9,8,9,10,10],7,[8,0,9,7,4],[]],[[7,2],[5,5,9,1,3],[4,8,6],[2,10],5],3,[4,[5,6],8,[]]],[8,[7,[9,1],[1,8,6,2,7]]],[8,[],[],[[0,1],8,2],0]]
|
||||||
|
[[8,[[1,6,3],1,[6,7,0],10],10],[9,[[7,6],9,[7,6,10],9],6],[10,[[6,7],9,4,5],7,0,1],[[3],[6,1,[3,4],[0,0,5],[]]],[[[0]],10,5,[[7],[],7,[7,7,3]]]]
|
||||||
|
|
||||||
|
[[[],7,5,1],[4],[4,[[3],0,6,[9,0,3,3,0],6],9,[[9,9,2,5]]]]
|
||||||
|
[[[[10,0,7],8],[[6,9,1],3,[2,1,1,0],10],4,10]]
|
||||||
|
|
||||||
|
[[[[10,9,4,1,9],[1,4],0],3,[9,[2,5,0,9],9,8]],[7,[8,[1],3,[6,1,7,1,5],4],[[10,2],[9,4,7,4],[10,2]]],[10,6,0],[[[10],[],[2,3,8,6,8],2,6],[[5,3,2]],9,8,1],[[4],[[2,5,3,4],1],[2,7,4,6,[4,6]]]]
|
||||||
|
[[10,[[4,0,7,7,2],[7],[6,8]],9,7],[6]]
|
||||||
|
|
||||||
|
[[1,4,6],[],[[0,[7,6,10],[8]],[9],[[3,4],10,[9,6,5],3],[[3]]],[8,[],1,9]]
|
||||||
|
[[[5]],[[2],[[1,3,6]],0,6,10],[4,1,[10,4,10,3],2],[6,6]]
|
||||||
|
|
||||||
|
[[],[6,1,[[5,8]],2]]
|
||||||
|
[[7,[9,[],[5]],[6,[8,1],3],8,[6,[10,0,1],3,[6],[]]],[8,1,3,[4,[5,3,5],[],[3,10],8],0]]
|
||||||
|
|
||||||
|
[[[3],3],[3,[10,[2,6,4,7],[10,4,4,6]],[3,10],[0,8,6,2,[10,10,5,9,8]]],[[4,2,5,[],2],[[],[9,0,8],[2,4,5,0]],[[6,10,6],9],[4,4,9,4],10],[[]],[[[7]],7,[6,[6],8],8,[[8,8]]]]
|
||||||
|
[[0,[7,[3,10,4],2]],[0,1,[[1,1],[6,0,10],2,4,[10,3]],5,4],[[[3,3,2,4],[3],3,[0,2,8,5,3]]]]
|
||||||
|
|
||||||
|
[[[],10,[4,2]],[]]
|
||||||
|
[[[4,[10,6,3,1],[0,2,10,2,3]],9,[4,1,7,9,8]],[[[5],2,2,[8,8]],7],[[],[[],[8,4,3,7],[],[2,9,4,4],[]],[[7,10,10,9,8],3,2,6],2],[3,[[4,8,8],[10,5],1,3,8]],[[[0,7,2,4,3],[],[2,10],4,4],[],1]]
|
||||||
|
|
||||||
|
[[3,9,10],[[[4,7,4],[10,2,4,7,7],[8]],[[3,1,5,4,4]]]]
|
||||||
|
[[5,7,5,[[7,9,1]],[[9,7,1,4,2],1]],[10,10,5,[[0,0,7,8],3]],[[3],[],[1,[1,2]],[]],[[],0,6]]
|
||||||
|
|
||||||
|
[[[[0,6,9],[9,9],7],2,3],[[[8,9,7,7],8,5,[6]],4,5]]
|
||||||
|
[[1],[10,[[]],8,[[0,2],[2,10,4],[3],[]]],[],[[1,5,[4,1,0]],[],[5,[8,2]],[5]],[0,9,[],6,7]]
|
||||||
|
|
||||||
|
[[9,4,[9,4]]]
|
||||||
|
[[[[2],8,8,[10,1],[6]]],[[[],[8,9],6],[]],[[1,[8],5,2,10],7]]
|
||||||
|
|
||||||
|
[[[[3,1,2,2],0,[7,1]],[],2,9,2],[[6,[4,0,0],[4,4,6,3,2],[1,10,5,10,8],5],[4,[3,8,5,3],3,[2,6,0,4,0]],[[8,5,4,6]],3],[[[10,1,5],[],[2,3,9],[4,8]],3,[3,[],8,1]],[[[7,5,2,8,7],[4,8],[10,10],3,0],[[3],[6,9,9,5,9],4],6,5,[[2,10],[10,4],1,[10,8]]]]
|
||||||
|
[[],[9,8,[0,[9]],8,[4,[3,5]]],[]]
|
||||||
|
|
||||||
|
[[[2,1]],[],[[],2],[[[1,7,2,9,7],3,6,[5,0,7]],6],[]]
|
||||||
|
[[2,[6,[5,4,8,0],8,6],[[8,7,5,3],[5,1,3,6],[1],2,[0,1]]],[[[9]],[[],[],2],5,6,7]]
|
||||||
|
|
||||||
|
[[[0],[9,[]]]]
|
||||||
|
[[],[1,[7,[10],[10,6],7,[7,8,9,3]],[[8],[0],[],[9]]],[[5],[6,8]],[[8,[0,4,0],5,[2,1,10,6],[]],6,6,[[],3]],[[[2,2,7,3,3]],3,3]]
|
||||||
|
|
||||||
|
[[9,4,[[5,10],[],[],[9,8,10,0,8],[1,6,8]],8,6],[[[0,1,9],2,[9,8,2,7]],0],[]]
|
||||||
|
[[10,5,2],[[7,[8,4]],7,4],[],[6],[4]]
|
||||||
|
|
||||||
|
[[[6,[8],[1,9,6,9],[10,1],6],[[7,3,3],2,7,[1,0,3,2,4],[7]],4],[9,[[7,5,10,4],6,4],[[4,2,9],[7,2],[0]],2]]
|
||||||
|
[[[]],[3,[[0],[9],[],[],10]],[3,10],[7,10,[],[0,7,2,8],[3,[8,6]]]]
|
||||||
|
|
||||||
|
[[6],[],[5,[6]]]
|
||||||
|
[[],[[9,[1,1]]],[3,0,[],2,[]]]
|
||||||
|
|
||||||
|
[[[6,10,[]],[1,[7,4],2],6,4,[[2,8,5],5,6,[1,6,9],[9,3,4,10]]],[]]
|
||||||
|
[[],[7,[5,[9,1,5,6],[1,4,10],[2,4,10,9,3]]]]
|
||||||
|
|
||||||
|
[[],[10,0,7,0],[2]]
|
||||||
|
[[10,[[6,2,8]]],[[1,9,[]],3,4],[1,[5],1,1]]
|
||||||
|
|
||||||
|
[[[5,7,4,1,[9,8,7,7]],[10]],[4,7,[[4,9,9],1,6,[10,4],7],[7,10,7,5],9]]
|
||||||
|
[[],[8,0],[2,[8,3,8,1]],[[[6,8,6]],[2,7,7],[[8],5,9]],[[1,[5,8,5,7]],[9],[0,8,4,7,[]],[9,5]]]
|
||||||
|
|
||||||
|
[[[6,6],1,10,9,10]]
|
||||||
|
[[6,6,7,[[8,7,6],3,[4],10],[8,6,[0,3,9,3,0],[5,9,10]]],[8,4,[5,[9,5,2,2],[8],4,10],2,[[10,6,6,0],[6,6,7,3],6,0,[1,6,6]]],[[],[],4],[4,[1,[2,3,1,7],3],8]]
|
||||||
|
|
||||||
|
[]
|
||||||
|
[[1,[[4,2,6,0,1],[8,6]],[6,[4,5,9,3],10,[0,7]],8],[6,3,7,[[10,7,10,4,7],[3,0,5,10,10],10]],[[]]]
|
||||||
|
|
||||||
|
[[5,5,[[],0,[3,10],[6,3]],[9,[10,0,6,8,8]]],[[[1,3,1],8]],[],[]]
|
||||||
|
[[6,5,[8,0,9],9,2],[10,[3]]]
|
||||||
|
|
||||||
|
[[[],8]]
|
||||||
|
[[8,0],[[6],[4,8,[9,2,2,0],[5],[]],2],[[4,3,[9,3,5,4,5]],[[1,6,0,8],5]],[4,10,[[9,8,5,10,5],2,[4,9,9,1],[10,8,9,2],[4,10,5]],[9,1]]]
|
||||||
|
|
||||||
|
[[[[5],[3,7],9]],[[7,10,[7,6,0],[1,0,5,6],[3,5,2,4,0]],[[2,0,7,1,7],1,[7,0,4,10],6],0,[9]],[3,[3,5,[10,8],[5,9,9]],2],[6,[],1,3]]
|
||||||
|
[[[[5,4]],[[1,9,0,5,8],4,[2,6,2,0],9]],[9,[0,7,[2,8,10,6]],[[10],[4,2,4,3,4],0],4],[],[2]]
|
||||||
|
|
||||||
|
[[[2,[2,10,4,4,6],10,6,[3,8,3,0,2]],[[3,0,2,0],[7,1],[1,0]]]]
|
||||||
|
[[[8,1,1,[9,2]],[[9,7,2],[],7,4,3],[1,[3],[2,3],3,4],[[1],[6,7,3,2]],7],[6],[[[2,5,4,4],[],4,9,4],[[10,8,4,0],8,[1,1,6,2,6],[6,8,5,10,0],7]]]
|
||||||
|
|
||||||
|
[[],[3],[[2,5,9],2,9,[[5,9],[2,3]]],[[3,1,[3,10,4,3,9],[2,0,6]],[[6,3],6,[9,7,9,7,10],[8,7,8,0,6]],7,[],[7]]]
|
||||||
|
[[[6,8,4,[4]]]]
|
||||||
|
|
||||||
|
[[2,7,[],[6,[1]]],[[[8,0],[4,8],[]],[0,[2,2,1,3],[8,0,3,7,4],[7,7,4,5,3],2],1,[7,[3,9],[5,6,8,8,5],[7,2,9]]],[[0,9,4,4],[9,4]]]
|
||||||
|
[[[10,[7],5,[]],10,10,4],[1,[[],0,[10,10,7],[7,10,1,4],10],4,[0,[8,9,1,8,8],3]],[]]
|
||||||
|
|
||||||
|
[[[3],0],[[5,1,[4,10,4],9]],[6,5,[[7,1,8],2,8,[0],5]],[[[5]],[5,[7,10],[1,9],2,[9]],2],[]]
|
||||||
|
[[[[10,5,0,1]],8,[]],[[1],[7]]]
|
||||||
|
|
||||||
|
[[3,6,4,[7,[6,9,4,9,9],8],[10]],[0,9,3,[[],8,[10,7,1,8],7,[1,2,5,7,7]]],[4],[[4],[],7],[[[2,9,1,5,6]],8,3]]
|
||||||
|
[[[5,[7,1,4,8,9]],[[2,8,8,2,10],7,[8,9],9],10,[[3,1,0,3,3],[3,7,10,0,8]],[5,2,[3],[2,3]]],[],[5,8]]
|
||||||
|
|
||||||
|
[[[],6,10,0]]
|
||||||
|
[[[[8],9,4,[],[]],[5,10,1,[1,4,10,9,0]],2,9,1]]
|
||||||
|
|
||||||
|
[[]]
|
||||||
|
[[[3,4]],[[8,0,[1,9,6,7]],[9,[10,2,6,3],2,[3,6,7,8,6]],[]]]
|
||||||
|
|
||||||
|
[[[[10],0,6,3,[4,4,3,5,10]],[2,[6,4,7]]],[]]
|
||||||
|
[[5,8,[0,[0,5],[0,8],6,[]],[8]],[[[5],[7,5,8,9],[2],[]]],[6],[[8,[9,8]],[[0,10,10],[7,6,6,2,10],[10],[]],[[2]],[4,[],[2,1],[7],4],[0,7]]]
|
||||||
|
|
||||||
|
[[0],[],[5],[4,7]]
|
||||||
|
[[3],[6,6],[5,0],[4]]
|
||||||
|
|
||||||
|
[[[]],[9,[[1,7,8]]]]
|
||||||
|
[[[4],7,8],[[10,3]],[10,[[7,6,10,10],7,7],[7,9,1],3,2]]
|
||||||
|
|
||||||
|
[[],[[[],[2,5,7,6,1],8,7,9],[4,[7,5],[10]],[[7,3,1,1,3],0,1]],[10,10,[4]],[],[8,[[9,4]],[8,[3,2],[7,4],0],5,8]]
|
||||||
|
[[4,[],2],[],[],[0,4]]
|
||||||
|
|
||||||
|
[[[4,1,9,[8,6],8],[6]],[2],[2],[[[2,3],[8,7,8,1,5],4,0,2],[[3],[1,9,10,6],3,[1,1,4,1]],[[9,5,6],[10,4,10,4],1],4],[7]]
|
||||||
|
[[[1],8,[[8]],[[6,10,5],7,7,9],[3]],[5],[[8,9],[[10,1,2],[4,8],5,6],4],[[4],8,[5],[[4,9,3,2,5],8,[],[0,4,9,4],0],9]]
|
||||||
|
|
||||||
|
[[[],[[],7,[]],8,1],[[[0,9,5,10,0],7,9,[1,5]],7,2],[[6,[4,2,0,0,1],6,2,[1,8]]],[[0,[]],5],[0,[],[[],[8,0,6],[9],2,10]]]
|
||||||
|
[[5,[[3,3,9],[3,1],[]],[9,[1,8,7,9],0,2,4]]]
|
||||||
|
|
||||||
|
[[0],[4,9,[[],8,[2]]],[[6,4,1,[],2],8,[[9,1,2],3,7,[1,1,2]],4,[2,[10,7,7,9,0],2,10]]]
|
||||||
|
[[10,[[0,2,5,10],8,[10],1,[8]]],[[[7],[4,8],[7],[9,10],9],0],[[[0,6],[8,3,3],[5,10,1,1,1],7],[4],[10],8,6]]
|
||||||
|
|
||||||
|
[[0,4],[4],[5,[3,[3,7,3]],[[4,1,0,7]],9],[4,[[5,6],[7],0,6,[7,6,7,0,5]]]]
|
||||||
|
[[],[1],[5,[[2,1,6]],1,[7,[8,7,6,1,4],2,[4,5]],1],[],[[9]]]
|
||||||
|
|
||||||
|
[[1,8],[6],[[[9],[9],[2,10,8],[2,3,1,0],[6,7]],0,2,[1]],[]]
|
||||||
|
[[[1,3,8],[[4,5,4],2,[8,8,7,9],[6,8]],9],[[1,8,[4,9,9,8,8]]],[6,[1,[5,8,3,1,4],[],[9],[6,5,2]]]]
|
||||||
|
|
||||||
|
[[],[[],[[9]]],[]]
|
||||||
|
[[5,[4,4,[1,3,8,5],10,0],0,[],7],[]]
|
||||||
|
|
||||||
|
[[5]]
|
||||||
|
[[[],5,3,10,3],[[1],[5,[0],[],10,8],[[10,6,3,2,6],[5,10,1,7],2,[7]]],[8,[[2,3,9,2,9]],10,10]]
|
||||||
|
|
||||||
|
[[[2,1,9],0,[10,5,6],[0]],[[4],9,[5,3]]]
|
||||||
|
[[7,2,0,9],[[1,3],4,3,7],[9],[],[5,[[8,3],7,[2,0,1,2]],9]]
|
||||||
|
|
||||||
|
[[[5,3],5],[],[8,[1,10,[10,1]],[6,0],[[1,2,0,2],4,0],[]],[[10,6,7,1],3,[8],[[3,10,9,0],7,[5,1],3,8]],[[7,6],10]]
|
||||||
|
[[2,8],[7,3],[[1,[6,2],7],5],[[6,[1,10,4],[0,5],[4,5]],10,10],[]]
|
||||||
|
|
||||||
|
[[2],[[[],[],[0,8,6,2,1],6,[5]],[[1,4,5,5,7],1,2],1]]
|
||||||
|
[[],[[[8,5,9,8,7],5,[7,7,10]]],[8]]
|
||||||
|
|
||||||
|
[[[],7],[[[9,10,6,6],[6,10,1,9,4]],[1,9,0,[0,4,10],10],4],[[[5,7],6,3,6],[[9],[2,3,5],0],2],[[[10,10]],[0,[8],[6,6],5],[[8,8],5,7],[8],2],[9,9,[[]]]]
|
||||||
|
[[[8],[[9,0,6,6,5],8],[4,[7],[4,6,6],[3,3],10],8,[]],[[[8,2]]],[9,4,[[4]],[[1,5],[0],[1,6,1],[]],0],[0,3,9,[6,7,1,0,[]]]]
|
||||||
|
|
||||||
|
[[3,[],[[1],[4],7,[1,2,0,6,5],[5]],6],[4,9,1,1],[5,[[4,2]],[]],[2],[8,2]]
|
||||||
|
[[[8,[7,9,8,0,4],[2,3,3],[],[9,5,6]],3,[2,[2,1,3,10,10],9,[4,9,2,2],8],2],[3,0,0,5,[4,[2,1],6,[2,3,9,1,8]]],[9,0,7],[8,5,1,[],9]]
|
||||||
|
|
||||||
|
[[],[[[2],[0,4],6],4,[[1,8],8]],[[],10]]
|
||||||
|
[[[],[5],10,[[10,5,0,7],[],1,[],7]],[3,[]],[],[2,[[8],9],[3,0,1],[[3,5],[9,2]]],[]]
|
||||||
|
|
||||||
|
[[5,[[10],6,[3]],7],[3,10,[1]],[[[7,6,8,8,10],[5,5,2],[7,1,2],[]]],[3,9,[0,3]],[7]]
|
||||||
|
[[2,[[6]],10,[9,[8],[],[1,10,4,4,9],[5]],[8]],[10],[],[3,[10,3],2,[[4,10,5,6,7],[5,7,7],6]],[10,7]]
|
||||||
|
|
||||||
|
[[[[],[5,2,9],10]],[[6,[],[2,0]],[[0,9,0],7,[]],[[9,3]],[]]]
|
||||||
|
[[10,[[1,1,8],7,3],[[8,6,10],4,0],9,6],[],[7,[],[3,[9,1,5],[10,4,1,8,1],0],[[3,2,1],4],[[8,10]]]]
|
||||||
|
|
||||||
|
[[],[],[[[10,3,7,10]],0,0,6,[[6,3,4,8]]],[9,[[],[2,10]]],[[8,[],[3,10,5,8,10],6,[9,6]],6]]
|
||||||
|
[[[],[9,3,[10,7],[6],7],[[6,10,10],[3],[10,7,0,5,0],7],6],[[[7,9,4,9,4],3,7,[7,1,7,4]],8,[9,7,[6,2,3,9,1]]],[4,[],3]]
|
||||||
|
|
||||||
|
[[5,5,9],[[5,[8,9,7,2],[5,7],[5,1,4,3,4],4],[0,[],3],1,3,3],[5,5],[[2,[2,9,4],[1,3,4],[5,6,9],[1,2]],9]]
|
||||||
|
[[[[8,6,9,9]],[[8,3,7,9],[10,1,0,3],8,[0,3,10,7]],[4,5,[3,4,3,2,6]],[[10]],9],[[[]],2],[8,10]]
|
||||||
|
|
||||||
|
[[[0,1,[7]],8,[[3],4,0],[[]]],[[0,1],[[5],10,1,[4,6,0,10,0],[5,6,10,10]],4,[1,[1,8],[4,9,9,10,5]],[8,3,1,[],9]],[6],[[],[[2],9,[7,1,6,5],[9],[10,9]]],[[[0],[9,3]],[2,5,[8,1,7],[]],[],[],5]]
|
||||||
|
[[2,[[4,3,5,5,2],4,[9,6],2,9],9,[3,2]],[[]],[[[10,9],[2],10,4,4],3,[[3,7,3],[0,2,1,9,0]],[9,6,5]]]
|
||||||
|
|
||||||
|
[[],[[[8,7,10],6,[3,8],5],[2,1,[1,5,4,3]],9,[[],[],[8,3],6,[10]],2],[2,0,[[],3,2,5,[0,7,8]]],[[[5,5,6],[1,9],[6],[10],7],8,[[8,7,3],0]]]
|
||||||
|
[[8,[],5,0],[],[10,[[],9,4,[7]],[]],[9],[4,10,0]]
|
||||||
|
|
||||||
|
[[5,9],[[[10,8,5,6],5,9,7,[]],[],[0]],[[1,4]],[[[5,9,4,1],[10,7,5,9],[6],0,7],[4,8],4,10,4],[6,9,[8],1]]
|
||||||
|
[[],[9,6,[6],7,0],[6]]
|
||||||
|
|
||||||
|
[[3,1,3,5,[]]]
|
||||||
|
[[3,[[0,8,2,10,3],[5,1,3,4,0],10,9],0,6,1],[6],[0,3,8,[2,7]],[10,2,5,[7,10],[2,3,[],[2]]]]
|
||||||
|
|
||||||
|
[[3,8,5,[7,[5,2],4],[3]],[[1,[1,0,5,1],7],4],[[8],[[1,5,9,0,9],2,[]],7,[[4],[7],[0,10,2,5,5],8],[10,[1]]],[[10],[7,[5],5,[4,3,9],[]]]]
|
||||||
|
[[],[[6],[2]],[[2,[1,9],[8,3],1],10,0],[[10,1,[5],7,2],[4,3],[[6,4,9,1,4]]],[[5,[2,6,9],[4,7,9,6,3],[1,6,0,6,0]]]]
|
||||||
|
|
||||||
|
[[[[0],7,[0]],[],[10,3,[5,9],6,[2,7,10]]],[],[[[5,7,3,3],[3]],0,[7,9],[7,4,[9],8,8],[7]],[10,7,10,0,5]]
|
||||||
|
[[[],[],[[],8,0,[8]],0,[]],[6,3,9,5,9],[],[[],7,7,[4],[[0],[6,3,6,0,9],9]]]
|
||||||
|
|
||||||
|
[[5,2,[[8,0,0],8,8]]]
|
||||||
|
[[6],[[4,[9,4],[3,1]],[6,2,0,[3]],0,7]]
|
||||||
|
|
||||||
|
[[],[[],[]],[],[10,[],[[7,4,1,3,5],9,0],[],7],[]]
|
||||||
|
[[[8,7]],[1,[0,[9],2,[]],9],[[[10,3,9,5,8],[],[]],7,[9,[3,0,3,8,9]],[[2,1],[7,2,0,2,9]]],[]]
|
||||||
|
|
||||||
|
[[[],[[7,7],[4]],6,[[],7],[]],[[[3,0,0,1],[1,9,10,4,10]],2,[10,[],[5,0],3],1,[[7,6,2],5,10,0,[7,8]]],[]]
|
||||||
|
[[[1,[2,0,9,0,8]],[[],1,0],6,[5]],[[],10,[8,[1,2]],[]]]
|
||||||
|
|
||||||
|
[[2,7,[[3,4,4,2],1,[9],5,3],[[2],8,[3,7,5],9]],[7],[[3,4,[],[]]],[4,[],5,[10,5,[4,4,5,0],1]]]
|
||||||
|
[[[0],2,7],[]]
|
||||||
|
|
||||||
|
[[2],[[2,7],5,[[9],10,0],[[1,5,2,7],3,10,6,[6]],[[2,0,9,4],6]],[[[10,8,7,4,9],[10],[5,1,4],9],[[10,3,10],[],[5,9,9],[10,3,2,5,9]],[[0,7,3,10],8,3,[9,7],[3,4,9,8]],7],[[1,10,6,0],5,6]]
|
||||||
|
[[[]],[[0,2,[4,1,9]],[],5,[[10,4,5,4,2],[10,3,0,1,3]]],[3,0]]
|
||||||
|
|
||||||
|
[[8,4,4,[[],[7,9,2,8],8,6],8],[[[9],[10]],[[5,7,5],[],[4,6,0,5,5]]]]
|
||||||
|
[[2,[[6,6,0,2,5],6,[7,1,7,9],7],[[9,3],5,[9,2,7],[9,8,3],0],2],[[[3,8,3],[3,1,5],[0,0,0,6],[5,5,4,1],[3]],[0],6,[0,[]]]]
|
||||||
|
|
||||||
|
[[2,[3],[]],[2,[[10,4,6,10,5],3,4,8]],[[[],5,1,10],[9,[8,0,2,5],9,8,[6,10,5,9,1]],[3]]]
|
||||||
|
[[4,[[7,10],9],[7,1]],[[[8],1,9,[1,10,5]],[[9]],[[4,1,3]],10,[4,2,[9],[7,8,2,1,1],5]],[[[],0,6,2],[2,[],1,[2,9,0,8,7]],[[8]],4],[[[6,3],[],5,8,[10,3,5]],6,0,6],[[[1,1,0],0,[10]]]]
|
||||||
|
|
||||||
|
[[3,[[1,1,9],9,[6],8,4],[]]]
|
||||||
|
[[],[6,[7,1],[6,10,[0,2,1,3],[],[8,4]],10,2],[[[6,10]],8,6,[10,[0,2,3],1]],[0,5,4,6,[]]]
|
||||||
|
|
||||||
|
[[9,[[1,8,3,2],[3],[8,2,9,3],[6,8,7]]]]
|
||||||
|
[[],[6,[[10,1,9]]],[10],[6,[[4]],[[2,8,10],[5,10],[2,8,3]],0],[7,5,1,[[7,10,3,1,9]],[[0,1,0,0,3],[]]]]
|
||||||
|
|
||||||
|
[[1,7],[0,[],2]]
|
||||||
|
[[[[2,0,0,5,1],3,[5,6]]]]
|
||||||
|
|
||||||
|
[[8,[[0,8],2,3],10,[[6,5,0,1,6],10,8,[10,4,5]],5],[1,4,2,6,[[9,7,10,7,9],2,5]],[5,[[6,0,4,8]],7,[[2,3,2,7]]],[[4,[],7,7,5],[[],10,[],8],[[1,6,5],2,0,8,[]],[[0,9,7,1,3],9,[7,2,9,8]],[[],[1,7],2,2]],[1,8]]
|
||||||
|
[[10,[]],[9,[]],[[4,[4],3],7,[[4,2,4],10]],[[5,[5,5,4,3],4,6,[6]],9,[[5,8,7,4,6],[],10,2,[1]]],[]]
|
||||||
|
|
||||||
|
[[6,9],[0,2,[[9],0,[8,10,9,7]],7,[4,4,2,[]]],[[9],[7,[8,4],[8,2],0],[[4,2],[5],[4,6],[0,6]],[5]],[[[9,2],8,[0],9,[1,9,4]],[[7,0,2,5,5],1,[6,8,2],6,7]],[[10],9,3,5,[]]]
|
||||||
|
[[[[4],0],[],[5,9,[9,3,4,9,7],8],3,9],[7,8,2,3,0],[4,[5,[7,2,3,9],6,[0,4,0,3],8]]]
|
||||||
|
|
||||||
|
[[[[2,4,0,1],[2,10,7,6,1],7,[7,1,10],7],[],[[8],1,[9,6,5,2],4,[4]]],[[4,1,[5,9,7],[4],6],4,3,[[8,2,8,8,9],[7,0,10]]],[[]],[[],[[0,0,1,3],5],9],[1]]
|
||||||
|
[[[[]],[9],[[6,5,0,0],[8,8,9,2],[10,10,10,8,2],[7,2,4,0,0]]],[8,[3,[6,1,5,7,4],5,0,4],3]]
|
||||||
|
|
||||||
|
[[4,[]],[9,2,[0],[3,2,[2,6,7,5,6]]],[[[3],[],[4,5,9,0,2],[5,3,0,1],[2,7,7]],10,9,3,[[3,4,6,8,10],3,1,2]],[]]
|
||||||
|
[[[8,[3,2,2],10,10,[8,7,8]],[[7,2,2],[1,8,2,7],[0,2,1,2,7]],[8],7],[10,0]]
|
||||||
|
|
||||||
|
[[[[6,6,3,4,0],5],[6,7,9],5,[[4,9,1],[9,2],0,6],[7]],[7]]
|
||||||
|
[[[0]]]
|
||||||
|
|
||||||
|
[[[],8,[]],[1],[]]
|
||||||
|
[[6,[]],[3,4],[[7,[9],3,4,7],[10,[3,10],0,3,[1,9]],[0,5,[6,3,6,7],2,9]]]
|
||||||
|
|
||||||
|
[7,6,8,6]
|
||||||
|
[7,6,8,6,4]
|
||||||
|
|
||||||
|
[[[5,[10],[6,2,2],3],7,[],[],7],[[2,[7,5,3],1,7,10],6,[[],4,9],[6,[4,8]],1],[],[[[2,4,3,6,3],[0,10,8],[2,2,7]],6,[[5,7],2,5,10],[9,[0,8,0,9,7]]]]
|
||||||
|
[[10],[3,[[3,5,5],[5,2,10],[2,9,10],[1,3,3,0,7],1],[[7,2,4,3],1,[0,8]]],[5,0,[[3],5,8],[[],9,[4,10,1],7]]]
|
||||||
|
|
||||||
|
[[9,[[],1,1,4],[10,4,[5,3,1,6],10,[]],0,0],[8,7,4],[6,[3,[9,9,6,3,3],[10,0]],[[],4,[10,0,9],1]],[[4,[6,3],[0,10,8,5,5],1,7],[[]],2,3,1]]
|
||||||
|
[[[3,[3,8],[4,9,3,8,1]]],[],[[3,[],[4,3,9],8],4,1,2,2],[],[[[5,3,8,7]]]]
|
||||||
|
|
||||||
|
[[[[8,9,3,6,4],[9,10,3],[],6],[4,1,[0,2,3]],4,[[9,6],10,9,0]],[[[9,8,1,0],[8,9,5,4,6]]],[[]],[[3],6,[2,6,8,[2,1,3,3,6],[4,7,5,1]]],[2]]
|
||||||
|
[[],[10],[[4],10,[8]]]
|
||||||
|
|
||||||
|
[[3,[[9,9],[4,4,5,8,3],0,4],9,[[1,9,0],4,1,0,8]]]
|
||||||
|
[[2,2,[6,4],[],7],[0],[10,8]]
|
||||||
|
|
||||||
|
[[[[]],6,[[3,8,6,3,9]],9,6],[5,[[0,9,8,7],1,8],9,7],[4,[2,[4,8,3,6]],5,[0,8,[3,9,6,3,10]],7]]
|
||||||
|
[[0,[],8]]
|
||||||
|
|
||||||
|
[[[[6,8],[10,1,5,1,5]],[[]],[[4,0,10,6],4,[10,5,1],9],[10],[10,[],[10,2],[10,4,3,7],[3]]],[10,2,[10,[],8],[8,[1,5,0,7,5],[],[4,9,10]],9]]
|
||||||
|
[[[],10,[],8,10],[[[],7,0,[10,0,1,10,4]],5],[8,[4,3],[[10,10,9,1],[3,0,6]],4],[[]],[]]
|
||||||
2
data/day14/example01.txt
Normal file
2
data/day14/example01.txt
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
498,4 -> 498,6 -> 496,6
|
||||||
|
503,4 -> 502,4 -> 502,9 -> 494,9
|
||||||
179
data/day14/input.txt
Normal file
179
data/day14/input.txt
Normal file
|
|
@ -0,0 +1,179 @@
|
||||||
|
496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35
|
||||||
|
501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48
|
||||||
|
551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158
|
||||||
|
568,139 -> 573,139
|
||||||
|
496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35
|
||||||
|
517,81 -> 517,84 -> 509,84 -> 509,92 -> 524,92 -> 524,84 -> 522,84 -> 522,81
|
||||||
|
501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48
|
||||||
|
496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35
|
||||||
|
501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48
|
||||||
|
531,98 -> 531,102 -> 526,102 -> 526,109 -> 540,109 -> 540,102 -> 535,102 -> 535,98
|
||||||
|
551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158
|
||||||
|
561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171
|
||||||
|
501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48
|
||||||
|
501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48
|
||||||
|
534,78 -> 539,78
|
||||||
|
513,78 -> 518,78
|
||||||
|
561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171
|
||||||
|
561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171
|
||||||
|
531,98 -> 531,102 -> 526,102 -> 526,109 -> 540,109 -> 540,102 -> 535,102 -> 535,98
|
||||||
|
553,133 -> 558,133
|
||||||
|
496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35
|
||||||
|
511,53 -> 515,53
|
||||||
|
496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35
|
||||||
|
551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158
|
||||||
|
561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171
|
||||||
|
561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171
|
||||||
|
543,144 -> 543,145 -> 560,145 -> 560,144
|
||||||
|
522,69 -> 527,69
|
||||||
|
551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158
|
||||||
|
560,133 -> 565,133
|
||||||
|
561,139 -> 566,139
|
||||||
|
518,94 -> 518,95 -> 532,95 -> 532,94
|
||||||
|
497,13 -> 497,17 -> 489,17 -> 489,22 -> 502,22 -> 502,17 -> 501,17 -> 501,13
|
||||||
|
531,98 -> 531,102 -> 526,102 -> 526,109 -> 540,109 -> 540,102 -> 535,102 -> 535,98
|
||||||
|
553,118 -> 553,120 -> 549,120 -> 549,124 -> 561,124 -> 561,120 -> 557,120 -> 557,118
|
||||||
|
561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171
|
||||||
|
501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48
|
||||||
|
496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35
|
||||||
|
517,53 -> 521,53
|
||||||
|
501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48
|
||||||
|
518,94 -> 518,95 -> 532,95 -> 532,94
|
||||||
|
520,78 -> 525,78
|
||||||
|
501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48
|
||||||
|
501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48
|
||||||
|
501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48
|
||||||
|
546,114 -> 546,115 -> 554,115 -> 554,114
|
||||||
|
496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35
|
||||||
|
522,63 -> 527,63
|
||||||
|
561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171
|
||||||
|
551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158
|
||||||
|
564,136 -> 569,136
|
||||||
|
501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48
|
||||||
|
534,111 -> 534,112 -> 549,112 -> 549,111
|
||||||
|
551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158
|
||||||
|
561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171
|
||||||
|
496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35
|
||||||
|
497,13 -> 497,17 -> 489,17 -> 489,22 -> 502,22 -> 502,17 -> 501,17 -> 501,13
|
||||||
|
553,118 -> 553,120 -> 549,120 -> 549,124 -> 561,124 -> 561,120 -> 557,120 -> 557,118
|
||||||
|
526,72 -> 531,72
|
||||||
|
501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48
|
||||||
|
561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171
|
||||||
|
533,66 -> 538,66
|
||||||
|
551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158
|
||||||
|
527,78 -> 532,78
|
||||||
|
551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158
|
||||||
|
561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171
|
||||||
|
551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158
|
||||||
|
496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35
|
||||||
|
561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171
|
||||||
|
517,81 -> 517,84 -> 509,84 -> 509,92 -> 524,92 -> 524,84 -> 522,84 -> 522,81
|
||||||
|
517,81 -> 517,84 -> 509,84 -> 509,92 -> 524,92 -> 524,84 -> 522,84 -> 522,81
|
||||||
|
496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35
|
||||||
|
553,118 -> 553,120 -> 549,120 -> 549,124 -> 561,124 -> 561,120 -> 557,120 -> 557,118
|
||||||
|
551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158
|
||||||
|
497,13 -> 497,17 -> 489,17 -> 489,22 -> 502,22 -> 502,17 -> 501,17 -> 501,13
|
||||||
|
561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171
|
||||||
|
501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48
|
||||||
|
550,136 -> 555,136
|
||||||
|
561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171
|
||||||
|
556,130 -> 561,130
|
||||||
|
517,81 -> 517,84 -> 509,84 -> 509,92 -> 524,92 -> 524,84 -> 522,84 -> 522,81
|
||||||
|
496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35
|
||||||
|
547,139 -> 552,139
|
||||||
|
505,57 -> 509,57
|
||||||
|
497,13 -> 497,17 -> 489,17 -> 489,22 -> 502,22 -> 502,17 -> 501,17 -> 501,13
|
||||||
|
551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158
|
||||||
|
496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35
|
||||||
|
567,133 -> 572,133
|
||||||
|
501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48
|
||||||
|
520,55 -> 524,55
|
||||||
|
517,81 -> 517,84 -> 509,84 -> 509,92 -> 524,92 -> 524,84 -> 522,84 -> 522,81
|
||||||
|
543,144 -> 543,145 -> 560,145 -> 560,144
|
||||||
|
553,118 -> 553,120 -> 549,120 -> 549,124 -> 561,124 -> 561,120 -> 557,120 -> 557,118
|
||||||
|
497,13 -> 497,17 -> 489,17 -> 489,22 -> 502,22 -> 502,17 -> 501,17 -> 501,13
|
||||||
|
575,139 -> 580,139
|
||||||
|
551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158
|
||||||
|
511,57 -> 515,57
|
||||||
|
496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35
|
||||||
|
501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48
|
||||||
|
551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158
|
||||||
|
551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158
|
||||||
|
497,13 -> 497,17 -> 489,17 -> 489,22 -> 502,22 -> 502,17 -> 501,17 -> 501,13
|
||||||
|
551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158
|
||||||
|
496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35
|
||||||
|
517,81 -> 517,84 -> 509,84 -> 509,92 -> 524,92 -> 524,84 -> 522,84 -> 522,81
|
||||||
|
551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158
|
||||||
|
553,118 -> 553,120 -> 549,120 -> 549,124 -> 561,124 -> 561,120 -> 557,120 -> 557,118
|
||||||
|
551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158
|
||||||
|
531,98 -> 531,102 -> 526,102 -> 526,109 -> 540,109 -> 540,102 -> 535,102 -> 535,98
|
||||||
|
551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158
|
||||||
|
496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35
|
||||||
|
514,55 -> 518,55
|
||||||
|
546,114 -> 546,115 -> 554,115 -> 554,114
|
||||||
|
557,136 -> 562,136
|
||||||
|
571,136 -> 576,136
|
||||||
|
546,114 -> 546,115 -> 554,115 -> 554,114
|
||||||
|
497,13 -> 497,17 -> 489,17 -> 489,22 -> 502,22 -> 502,17 -> 501,17 -> 501,13
|
||||||
|
496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35
|
||||||
|
551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158
|
||||||
|
561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171
|
||||||
|
553,118 -> 553,120 -> 549,120 -> 549,124 -> 561,124 -> 561,120 -> 557,120 -> 557,118
|
||||||
|
551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158
|
||||||
|
561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171
|
||||||
|
525,60 -> 530,60
|
||||||
|
559,127 -> 564,127
|
||||||
|
551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158
|
||||||
|
517,81 -> 517,84 -> 509,84 -> 509,92 -> 524,92 -> 524,84 -> 522,84 -> 522,81
|
||||||
|
561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171
|
||||||
|
561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171
|
||||||
|
551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158
|
||||||
|
529,63 -> 534,63
|
||||||
|
526,66 -> 531,66
|
||||||
|
561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171
|
||||||
|
501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48
|
||||||
|
508,55 -> 512,55
|
||||||
|
501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48
|
||||||
|
534,111 -> 534,112 -> 549,112 -> 549,111
|
||||||
|
561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171
|
||||||
|
496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35
|
||||||
|
531,98 -> 531,102 -> 526,102 -> 526,109 -> 540,109 -> 540,102 -> 535,102 -> 535,98
|
||||||
|
516,75 -> 521,75
|
||||||
|
501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48
|
||||||
|
523,75 -> 528,75
|
||||||
|
523,57 -> 527,57
|
||||||
|
519,66 -> 524,66
|
||||||
|
496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35
|
||||||
|
561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171
|
||||||
|
554,139 -> 559,139
|
||||||
|
543,144 -> 543,145 -> 560,145 -> 560,144
|
||||||
|
561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171
|
||||||
|
551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158
|
||||||
|
551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158
|
||||||
|
553,118 -> 553,120 -> 549,120 -> 549,124 -> 561,124 -> 561,120 -> 557,120 -> 557,118
|
||||||
|
501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48
|
||||||
|
514,51 -> 518,51
|
||||||
|
551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158
|
||||||
|
517,57 -> 521,57
|
||||||
|
531,98 -> 531,102 -> 526,102 -> 526,109 -> 540,109 -> 540,102 -> 535,102 -> 535,98
|
||||||
|
501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48
|
||||||
|
551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158
|
||||||
|
561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171
|
||||||
|
518,94 -> 518,95 -> 532,95 -> 532,94
|
||||||
|
496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35
|
||||||
|
496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35
|
||||||
|
530,75 -> 535,75
|
||||||
|
561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171
|
||||||
|
561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171
|
||||||
|
519,72 -> 524,72
|
||||||
|
551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158
|
||||||
|
563,130 -> 568,130
|
||||||
|
551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158
|
||||||
|
561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171
|
||||||
|
501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48
|
||||||
|
531,98 -> 531,102 -> 526,102 -> 526,109 -> 540,109 -> 540,102 -> 535,102 -> 535,98
|
||||||
|
534,111 -> 534,112 -> 549,112 -> 549,111
|
||||||
|
501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48
|
||||||
|
561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171
|
||||||
|
501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48
|
||||||
|
551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158
|
||||||
15
data/day15/example01.txt
Normal file
15
data/day15/example01.txt
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
10
|
||||||
|
Sensor at x=2, y=18: closest beacon is at x=-2, y=15
|
||||||
|
Sensor at x=9, y=16: closest beacon is at x=10, y=16
|
||||||
|
Sensor at x=13, y=2: closest beacon is at x=15, y=3
|
||||||
|
Sensor at x=12, y=14: closest beacon is at x=10, y=16
|
||||||
|
Sensor at x=10, y=20: closest beacon is at x=10, y=16
|
||||||
|
Sensor at x=14, y=17: closest beacon is at x=10, y=16
|
||||||
|
Sensor at x=8, y=7: closest beacon is at x=2, y=10
|
||||||
|
Sensor at x=2, y=0: closest beacon is at x=2, y=10
|
||||||
|
Sensor at x=0, y=11: closest beacon is at x=2, y=10
|
||||||
|
Sensor at x=20, y=14: closest beacon is at x=25, y=17
|
||||||
|
Sensor at x=17, y=20: closest beacon is at x=21, y=22
|
||||||
|
Sensor at x=16, y=7: closest beacon is at x=15, y=3
|
||||||
|
Sensor at x=14, y=3: closest beacon is at x=15, y=3
|
||||||
|
Sensor at x=20, y=1: closest beacon is at x=15, y=3
|
||||||
32
data/day15/input.txt
Normal file
32
data/day15/input.txt
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
2000000
|
||||||
|
Sensor at x=3859432, y=2304903: closest beacon is at x=3677247, y=3140958
|
||||||
|
Sensor at x=2488890, y=2695345: closest beacon is at x=1934788, y=2667279
|
||||||
|
Sensor at x=3901948, y=701878: closest beacon is at x=4095477, y=368031
|
||||||
|
Sensor at x=2422190, y=1775708: closest beacon is at x=1765036, y=2000000
|
||||||
|
Sensor at x=2703846, y=3282799: closest beacon is at x=2121069, y=3230302
|
||||||
|
Sensor at x=172003, y=2579074: closest beacon is at x=-77667, y=3197309
|
||||||
|
Sensor at x=1813149, y=1311283: closest beacon is at x=1765036, y=2000000
|
||||||
|
Sensor at x=1704453, y=2468117: closest beacon is at x=1934788, y=2667279
|
||||||
|
Sensor at x=1927725, y=2976002: closest beacon is at x=1934788, y=2667279
|
||||||
|
Sensor at x=3176646, y=1254463: closest beacon is at x=2946873, y=2167634
|
||||||
|
Sensor at x=2149510, y=3722117: closest beacon is at x=2121069, y=3230302
|
||||||
|
Sensor at x=3804434, y=251015: closest beacon is at x=4095477, y=368031
|
||||||
|
Sensor at x=2613561, y=3932220: closest beacon is at x=2121069, y=3230302
|
||||||
|
Sensor at x=3997794, y=3291220: closest beacon is at x=3677247, y=3140958
|
||||||
|
Sensor at x=98328, y=3675176: closest beacon is at x=-77667, y=3197309
|
||||||
|
Sensor at x=2006541, y=2259601: closest beacon is at x=1934788, y=2667279
|
||||||
|
Sensor at x=663904, y=122919: closest beacon is at x=1618552, y=-433244
|
||||||
|
Sensor at x=1116472, y=3349728: closest beacon is at x=2121069, y=3230302
|
||||||
|
Sensor at x=2810797, y=2300748: closest beacon is at x=2946873, y=2167634
|
||||||
|
Sensor at x=1760767, y=2024355: closest beacon is at x=1765036, y=2000000
|
||||||
|
Sensor at x=3098487, y=2529092: closest beacon is at x=2946873, y=2167634
|
||||||
|
Sensor at x=1716839, y=634872: closest beacon is at x=1618552, y=-433244
|
||||||
|
Sensor at x=9323, y=979154: closest beacon is at x=-245599, y=778791
|
||||||
|
Sensor at x=1737623, y=2032367: closest beacon is at x=1765036, y=2000000
|
||||||
|
Sensor at x=26695, y=3049071: closest beacon is at x=-77667, y=3197309
|
||||||
|
Sensor at x=3691492, y=3766350: closest beacon is at x=3677247, y=3140958
|
||||||
|
Sensor at x=730556, y=1657010: closest beacon is at x=1765036, y=2000000
|
||||||
|
Sensor at x=506169, y=3958647: closest beacon is at x=-77667, y=3197309
|
||||||
|
Sensor at x=2728744, y=23398: closest beacon is at x=1618552, y=-433244
|
||||||
|
Sensor at x=3215227, y=3077078: closest beacon is at x=3677247, y=3140958
|
||||||
|
Sensor at x=2209379, y=3030851: closest beacon is at x=2121069, y=3230302
|
||||||
|
|
@ -22,6 +22,10 @@ impl<T> Pos<T>
|
||||||
where
|
where
|
||||||
T: Num + Copy,
|
T: Num + Copy,
|
||||||
{
|
{
|
||||||
|
pub fn splat(v: T) -> Pos<T> {
|
||||||
|
Pos(v, v)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn x(&self) -> T {
|
pub fn x(&self) -> T {
|
||||||
self.0
|
self.0
|
||||||
}
|
}
|
||||||
|
|
@ -259,3 +263,16 @@ where
|
||||||
Pos::mul(*self, *rhs)
|
Pos::mul(*self, *rhs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T> Pos<T>
|
||||||
|
where
|
||||||
|
T: Num + Signed + Copy,
|
||||||
|
{
|
||||||
|
pub fn taxicab_origin(&self) -> T {
|
||||||
|
self.0.abs() + self.1.abs()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn taxicab(&self, other: &Pos<T>) -> T {
|
||||||
|
(self.0 - other.0).abs() + (self.1 - other.1).abs()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -215,7 +215,7 @@ mod test {
|
||||||
fn test_part2() -> Result<()> {
|
fn test_part2() -> Result<()> {
|
||||||
let day = Day {};
|
let day = Day {};
|
||||||
let lines = read_lines(day.get_day_number(), "example01.txt")?;
|
let lines = read_lines(day.get_day_number(), "example01.txt")?;
|
||||||
let expected = ResultType::Nothing;
|
let expected = ResultType::Integer(12);
|
||||||
let result = day.part2(&lines)?;
|
let result = day.part2(&lines)?;
|
||||||
assert_eq!(result, expected);
|
assert_eq!(result, expected);
|
||||||
|
|
||||||
|
|
|
||||||
341
src/days/day07/mod.rs
Normal file
341
src/days/day07/mod.rs
Normal file
|
|
@ -0,0 +1,341 @@
|
||||||
|
use std::{
|
||||||
|
cell::{Cell, RefCell},
|
||||||
|
num::ParseIntError,
|
||||||
|
rc::{Rc, Weak},
|
||||||
|
};
|
||||||
|
|
||||||
|
use super::template::{DayTrait, ResultType};
|
||||||
|
use thiserror::Error;
|
||||||
|
|
||||||
|
const DAY_NUMBER: usize = 7;
|
||||||
|
|
||||||
|
pub struct Day;
|
||||||
|
|
||||||
|
impl DayTrait for Day {
|
||||||
|
fn get_day_number(&self) -> usize {
|
||||||
|
DAY_NUMBER
|
||||||
|
}
|
||||||
|
|
||||||
|
fn part1(&self, lines: &[String]) -> anyhow::Result<ResultType> {
|
||||||
|
let root = Directory::parse(lines)?;
|
||||||
|
let result = root
|
||||||
|
.iter()
|
||||||
|
.filter_map(|dir| {
|
||||||
|
let size = dir.size();
|
||||||
|
if size <= 100000 {
|
||||||
|
Some(size)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.sum();
|
||||||
|
Ok(ResultType::Integer(result))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn part2(&self, lines: &[String]) -> anyhow::Result<ResultType> {
|
||||||
|
const AVAIL: i64 = 70_000_000;
|
||||||
|
const REQUIRED: i64 = 30_000_000;
|
||||||
|
let root = Directory::parse(lines)?;
|
||||||
|
let to_free = REQUIRED - (AVAIL - root.size());
|
||||||
|
let result = root
|
||||||
|
.iter()
|
||||||
|
.filter_map(|dir| {
|
||||||
|
let size = dir.size();
|
||||||
|
if size >= to_free {
|
||||||
|
Some(size)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.min()
|
||||||
|
.unwrap_or(0);
|
||||||
|
Ok(ResultType::Integer(result))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Error)]
|
||||||
|
enum DirectoryError {
|
||||||
|
#[error("Directory does not exist: {0}")]
|
||||||
|
NoSuchDirectory(String),
|
||||||
|
|
||||||
|
#[error("Directory has no parent")]
|
||||||
|
NoParentDirectory,
|
||||||
|
|
||||||
|
#[error("Illegal command: {0}")]
|
||||||
|
IllegalCommand(String),
|
||||||
|
|
||||||
|
#[error("No a legal Number")]
|
||||||
|
IllegalNumber(#[from] ParseIntError),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
struct Node {
|
||||||
|
parent: Option<Weak<RefCell<Node>>>,
|
||||||
|
name: String,
|
||||||
|
sub_dirs: Vec<Rc<RefCell<Node>>>,
|
||||||
|
file_size: i64,
|
||||||
|
size: Cell<Option<i64>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Node {
|
||||||
|
fn root() -> Node {
|
||||||
|
Node {
|
||||||
|
parent: None,
|
||||||
|
name: "/".to_owned(),
|
||||||
|
sub_dirs: vec![],
|
||||||
|
file_size: 0,
|
||||||
|
size: Cell::new(None),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn add_subdir(&mut self, subdir: Rc<RefCell<Node>>) {
|
||||||
|
self.sub_dirs.push(subdir);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn add_file(&mut self, _name: &str, size: i64) {
|
||||||
|
self.file_size += size;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn size(&self) -> i64 {
|
||||||
|
self.size.get().unwrap_or_else(|| {
|
||||||
|
let subsize: i64 = self.sub_dirs.iter().map(|sub| sub.borrow().size()).sum();
|
||||||
|
let size = subsize + self.file_size;
|
||||||
|
|
||||||
|
self.size.set(Some(size));
|
||||||
|
size
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
struct Directory {
|
||||||
|
node: Rc<RefCell<Node>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Directory {
|
||||||
|
pub fn root() -> Directory {
|
||||||
|
Directory {
|
||||||
|
node: Rc::new(RefCell::new(Node::root())),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn create(node: Rc<RefCell<Node>>) -> Directory {
|
||||||
|
Directory { node }
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub fn name(&self) -> String {
|
||||||
|
self.node.borrow().name.to_string()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn size(&self) -> i64 {
|
||||||
|
self.node.borrow().size()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub fn file_size(&self) -> i64 {
|
||||||
|
self.node.borrow().file_size
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn add_subdir(&mut self, name: &str) {
|
||||||
|
let subdir = Rc::new(RefCell::new(Node {
|
||||||
|
parent: Some(Rc::downgrade(&self.node)),
|
||||||
|
name: name.to_owned(),
|
||||||
|
sub_dirs: vec![],
|
||||||
|
file_size: 0,
|
||||||
|
size: Cell::new(None),
|
||||||
|
}));
|
||||||
|
self.node.borrow_mut().add_subdir(subdir);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn add_file(&mut self, name: &str, size: i64) {
|
||||||
|
self.node.borrow_mut().add_file(name, size)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn parent(&self) -> Option<Directory> {
|
||||||
|
self.node
|
||||||
|
.borrow()
|
||||||
|
.parent
|
||||||
|
.as_ref()
|
||||||
|
.and_then(|node| node.upgrade())
|
||||||
|
.map(|node| Directory { node })
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_subdir(&self, name: &str) -> Option<Directory> {
|
||||||
|
let node = self.node.borrow();
|
||||||
|
let sub_node = node.sub_dirs.iter().find(|node| node.borrow().name == name);
|
||||||
|
sub_node.map(|node| Directory::create(node.clone()))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn parse(lines: &[String]) -> Result<Directory, DirectoryError> {
|
||||||
|
let root = Directory::root();
|
||||||
|
let mut current = root.clone();
|
||||||
|
for line in lines {
|
||||||
|
match line.split_whitespace().collect::<Vec<&str>>()[..] {
|
||||||
|
["$", "cd", dir] => {
|
||||||
|
current = match dir {
|
||||||
|
"/" => root.clone(),
|
||||||
|
".." => {
|
||||||
|
let Some(next) = current.parent() else {
|
||||||
|
return Err(DirectoryError::NoParentDirectory);
|
||||||
|
};
|
||||||
|
next
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
let Some(next) = current.get_subdir(dir) else {
|
||||||
|
return Err(DirectoryError::NoSuchDirectory(dir.to_owned()))
|
||||||
|
};
|
||||||
|
next
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
["$", "ls"] => {} // Command can safely be ignored
|
||||||
|
["dir", name] => {
|
||||||
|
current.add_subdir(name);
|
||||||
|
}
|
||||||
|
[size, name] => {
|
||||||
|
let size = size.parse::<i64>()?;
|
||||||
|
current.add_file(name, size);
|
||||||
|
}
|
||||||
|
_ => return Err(DirectoryError::IllegalCommand(line.to_owned())),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(root)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn iter(&self) -> DirectoryIterator {
|
||||||
|
DirectoryIterator::create(self.node.clone())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
struct DirectoryIterator {
|
||||||
|
directory: Rc<RefCell<Node>>,
|
||||||
|
subdirectory: Option<(usize, Box<DirectoryIterator>)>,
|
||||||
|
finished: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl DirectoryIterator {
|
||||||
|
pub fn create(directory: Rc<RefCell<Node>>) -> DirectoryIterator {
|
||||||
|
DirectoryIterator {
|
||||||
|
directory,
|
||||||
|
subdirectory: None,
|
||||||
|
finished: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Iterator for DirectoryIterator {
|
||||||
|
type Item = Directory;
|
||||||
|
|
||||||
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
|
if self.finished {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
if let Some((subdirectory, sub_iterator)) = self.subdirectory.as_mut() {
|
||||||
|
if let Some(next) = sub_iterator.next() {
|
||||||
|
Some(next)
|
||||||
|
} else {
|
||||||
|
let dir = self.directory.borrow();
|
||||||
|
let subdirectory = *subdirectory + 1;
|
||||||
|
if subdirectory < dir.sub_dirs.len() {
|
||||||
|
let subdir = dir.sub_dirs[subdirectory].clone();
|
||||||
|
let mut sub_iterator = DirectoryIterator::create(subdir);
|
||||||
|
let result = sub_iterator.next();
|
||||||
|
self.subdirectory = Some((subdirectory, Box::new(sub_iterator)));
|
||||||
|
result
|
||||||
|
} else {
|
||||||
|
self.finished = true;
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
let dir = self.directory.borrow();
|
||||||
|
if !dir.sub_dirs.is_empty() {
|
||||||
|
let subdir = dir.sub_dirs[0].clone();
|
||||||
|
let sub_iterator = DirectoryIterator::create(subdir);
|
||||||
|
self.subdirectory = Some((0, Box::new(sub_iterator)));
|
||||||
|
} else {
|
||||||
|
self.finished = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Some(Directory {
|
||||||
|
node: self.directory.clone(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod test {
|
||||||
|
use super::*;
|
||||||
|
use crate::common::file::read_lines;
|
||||||
|
use anyhow::Result;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_create_directory() {
|
||||||
|
let directory = Directory::root();
|
||||||
|
assert_eq!(directory.name(), "/");
|
||||||
|
assert_eq!(directory.size(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_create_and_get_subdir() {
|
||||||
|
let mut root = Directory::root();
|
||||||
|
root.add_file("file1", 100);
|
||||||
|
root.add_file("file2", 200);
|
||||||
|
root.add_subdir("subdir");
|
||||||
|
let mut subdir = root.get_subdir("subdir").unwrap();
|
||||||
|
subdir.add_file("file3", 300);
|
||||||
|
subdir.add_file("file4", 400);
|
||||||
|
|
||||||
|
assert_eq!(subdir.name(), "subdir");
|
||||||
|
assert_eq!(subdir.size(), 700);
|
||||||
|
assert_eq!(root.size(), 1000);
|
||||||
|
assert_eq!(root.file_size(), 300);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_total_size() -> Result<()> {
|
||||||
|
let day = Day {};
|
||||||
|
let lines = read_lines(day.get_day_number(), "example01.txt")?;
|
||||||
|
let dir = Directory::parse(&lines)?;
|
||||||
|
assert_eq!(dir.size(), 48381165);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_iterator() -> Result<()> {
|
||||||
|
let day = Day {};
|
||||||
|
let lines = read_lines(day.get_day_number(), "example01.txt")?;
|
||||||
|
let expected = vec!["/", "a", "e", "d"];
|
||||||
|
let dir = Directory::parse(&lines)?;
|
||||||
|
let result: Vec<_> = dir.iter().map(|dir| dir.name()).collect();
|
||||||
|
assert_eq!(result, expected);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_part1() -> Result<()> {
|
||||||
|
let day = Day {};
|
||||||
|
let lines = read_lines(day.get_day_number(), "example01.txt")?;
|
||||||
|
let expected = ResultType::Integer(95437);
|
||||||
|
let result = day.part1(&lines)?;
|
||||||
|
assert_eq!(result, expected);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_part2() -> Result<()> {
|
||||||
|
let day = Day {};
|
||||||
|
let lines = read_lines(day.get_day_number(), "example01.txt")?;
|
||||||
|
let expected = ResultType::Integer(24933642);
|
||||||
|
let result = day.part2(&lines)?;
|
||||||
|
assert_eq!(result, expected);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
232
src/days/day08/mod.rs
Normal file
232
src/days/day08/mod.rs
Normal file
|
|
@ -0,0 +1,232 @@
|
||||||
|
use super::template::{DayTrait, ResultType};
|
||||||
|
use itertools::{iproduct, FoldWhile, Itertools};
|
||||||
|
use thiserror::Error;
|
||||||
|
|
||||||
|
const DAY_NUMBER: usize = 8;
|
||||||
|
|
||||||
|
pub struct Day;
|
||||||
|
|
||||||
|
impl DayTrait for Day {
|
||||||
|
fn get_day_number(&self) -> usize {
|
||||||
|
DAY_NUMBER
|
||||||
|
}
|
||||||
|
|
||||||
|
fn part1(&self, lines: &[String]) -> anyhow::Result<ResultType> {
|
||||||
|
let forest = Forest::parse(lines)?;
|
||||||
|
let result = forest.count_visible();
|
||||||
|
Ok(ResultType::Integer(result))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn part2(&self, lines: &[String]) -> anyhow::Result<ResultType> {
|
||||||
|
let forest = Forest::parse(lines)?;
|
||||||
|
let result = forest.best_score();
|
||||||
|
Ok(ResultType::Integer(result))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Error)]
|
||||||
|
enum ForestError {
|
||||||
|
#[error("Not a legal digit: {0}")]
|
||||||
|
NoLegalDigit(char),
|
||||||
|
|
||||||
|
#[error("The Forst is not a rectangle")]
|
||||||
|
NonRectangleForest,
|
||||||
|
|
||||||
|
#[error("Zero Sized Forest not allowed")]
|
||||||
|
NoZeroSizedForest,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
struct Forest {
|
||||||
|
trees: Vec<Vec<u32>>,
|
||||||
|
width: usize,
|
||||||
|
height: usize,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Forest {
|
||||||
|
pub fn create(trees: Vec<Vec<u32>>) -> Result<Self, ForestError> {
|
||||||
|
let height = trees.len();
|
||||||
|
if height == 0 {
|
||||||
|
return Err(ForestError::NoZeroSizedForest);
|
||||||
|
}
|
||||||
|
let width = trees[0].len();
|
||||||
|
if width == 0 {
|
||||||
|
return Err(ForestError::NoZeroSizedForest);
|
||||||
|
}
|
||||||
|
|
||||||
|
for row in trees.iter() {
|
||||||
|
if row.len() != width {
|
||||||
|
return Err(ForestError::NonRectangleForest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(Forest {
|
||||||
|
trees,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn parse(lines: &[String]) -> Result<Forest, ForestError> {
|
||||||
|
lines
|
||||||
|
.iter()
|
||||||
|
.map(|line| {
|
||||||
|
line.chars()
|
||||||
|
.map(|height| height.to_digit(10).ok_or(ForestError::NoLegalDigit(height)))
|
||||||
|
.collect::<Result<Vec<_>, _>>()
|
||||||
|
})
|
||||||
|
.collect::<Result<Vec<_>, _>>()
|
||||||
|
.and_then(Forest::create)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn count_visible(&self) -> i64 {
|
||||||
|
let mut vis_count = 2 * (self.width + self.height - 2) as i64;
|
||||||
|
let mut visible = vec![vec![false; self.width - 2]; self.height - 2];
|
||||||
|
|
||||||
|
for y in 1..self.height - 1 {
|
||||||
|
let mut talest_seen = self.trees[y][0];
|
||||||
|
for x in 1..self.width - 1 {
|
||||||
|
let tree = self.trees[y][x];
|
||||||
|
if tree > talest_seen {
|
||||||
|
vis_count += 1;
|
||||||
|
visible[y - 1][x - 1] = true;
|
||||||
|
talest_seen = self.trees[y][x];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut talest_seen = self.trees[y][self.width - 1];
|
||||||
|
for x in (1..self.width - 1).rev() {
|
||||||
|
let tree = self.trees[y][x];
|
||||||
|
if tree > talest_seen {
|
||||||
|
if !visible[y - 1][x - 1] {
|
||||||
|
vis_count += 1;
|
||||||
|
visible[y - 1][x - 1] = true;
|
||||||
|
}
|
||||||
|
talest_seen = self.trees[y][x];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for x in 1..self.width - 1 {
|
||||||
|
let mut talest_seen = self.trees[0][x];
|
||||||
|
for y in 1..self.height - 1 {
|
||||||
|
let tree = self.trees[y][x];
|
||||||
|
if tree > talest_seen {
|
||||||
|
if !visible[y - 1][x - 1] {
|
||||||
|
vis_count += 1;
|
||||||
|
visible[y - 1][x - 1] = true;
|
||||||
|
}
|
||||||
|
talest_seen = self.trees[y][x];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut talest_seen = self.trees[self.height - 1][x];
|
||||||
|
for y in (1..self.height - 1).rev() {
|
||||||
|
let tree = self.trees[y][x];
|
||||||
|
if tree > talest_seen {
|
||||||
|
if !visible[y - 1][x - 1] {
|
||||||
|
vis_count += 1;
|
||||||
|
visible[y - 1][x - 1] = true;
|
||||||
|
}
|
||||||
|
talest_seen = self.trees[y][x];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vis_count
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn best_score(&self) -> i64 {
|
||||||
|
iproduct!(1..self.width - 1, 1..self.height - 1)
|
||||||
|
.map(|(x, y)| self.score(x, y))
|
||||||
|
.max()
|
||||||
|
// None can only happen when we have a forrest with no inner trees.
|
||||||
|
// In that case 0 is the correct solution.
|
||||||
|
// We already forbid zero height and zero width forests during create.
|
||||||
|
.unwrap_or(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn score(&self, x: usize, y: usize) -> i64 {
|
||||||
|
let tree = self.trees[y][x];
|
||||||
|
let left = (0..x)
|
||||||
|
.rev()
|
||||||
|
.fold_while(0, |acc, x| {
|
||||||
|
if self.trees[y][x] < tree {
|
||||||
|
FoldWhile::Continue(acc + 1)
|
||||||
|
} else {
|
||||||
|
FoldWhile::Done(acc + 1)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.into_inner();
|
||||||
|
let right = (x + 1..self.width)
|
||||||
|
.fold_while(0, |acc, x| {
|
||||||
|
if self.trees[y][x] < tree {
|
||||||
|
FoldWhile::Continue(acc + 1)
|
||||||
|
} else {
|
||||||
|
FoldWhile::Done(acc + 1)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.into_inner();
|
||||||
|
let up = (0..y)
|
||||||
|
.rev()
|
||||||
|
.fold_while(0, |acc, y| {
|
||||||
|
if self.trees[y][x] < tree {
|
||||||
|
FoldWhile::Continue(acc + 1)
|
||||||
|
} else {
|
||||||
|
FoldWhile::Done(acc + 1)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.into_inner();
|
||||||
|
let down = (y + 1..self.height)
|
||||||
|
.fold_while(0, |acc, y| {
|
||||||
|
if self.trees[y][x] < tree {
|
||||||
|
FoldWhile::Continue(acc + 1)
|
||||||
|
} else {
|
||||||
|
FoldWhile::Done(acc + 1)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.into_inner();
|
||||||
|
|
||||||
|
left * right * up * down
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod test {
|
||||||
|
use super::*;
|
||||||
|
use crate::common::file::read_lines;
|
||||||
|
use anyhow::Result;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_parse() -> Result<()> {
|
||||||
|
let day = Day {};
|
||||||
|
let lines = read_lines(day.get_day_number(), "example01.txt")?;
|
||||||
|
let forest = Forest::parse(&lines)?;
|
||||||
|
assert_eq!(forest.width, 5);
|
||||||
|
assert_eq!(forest.height, 5);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_part1() -> Result<()> {
|
||||||
|
let day = Day {};
|
||||||
|
let lines = read_lines(day.get_day_number(), "example01.txt")?;
|
||||||
|
let expected = ResultType::Integer(21);
|
||||||
|
let result = day.part1(&lines)?;
|
||||||
|
assert_eq!(result, expected);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_part2() -> Result<()> {
|
||||||
|
let day = Day {};
|
||||||
|
let lines = read_lines(day.get_day_number(), "example01.txt")?;
|
||||||
|
let expected = ResultType::Integer(8);
|
||||||
|
let result = day.part2(&lines)?;
|
||||||
|
assert_eq!(result, expected);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
152
src/days/day09/mod.rs
Normal file
152
src/days/day09/mod.rs
Normal file
|
|
@ -0,0 +1,152 @@
|
||||||
|
use super::template::{DayTrait, ResultType};
|
||||||
|
use crate::common::{direction::Direction, pos::Pos};
|
||||||
|
use std::{collections::HashSet, num::ParseIntError};
|
||||||
|
use thiserror::Error;
|
||||||
|
|
||||||
|
const DAY_NUMBER: usize = 9;
|
||||||
|
|
||||||
|
pub struct Day;
|
||||||
|
|
||||||
|
impl DayTrait for Day {
|
||||||
|
fn get_day_number(&self) -> usize {
|
||||||
|
DAY_NUMBER
|
||||||
|
}
|
||||||
|
|
||||||
|
fn part1(&self, lines: &[String]) -> anyhow::Result<ResultType> {
|
||||||
|
let commands = parse_commands(lines)?;
|
||||||
|
let mut rope = Rope::create(2);
|
||||||
|
let result = rope.run(&commands);
|
||||||
|
Ok(ResultType::Integer(result))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn part2(&self, lines: &[String]) -> anyhow::Result<ResultType> {
|
||||||
|
let commands = parse_commands(lines)?;
|
||||||
|
let mut rope = Rope::create(10);
|
||||||
|
let result = rope.run(&commands);
|
||||||
|
Ok(ResultType::Integer(result))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Error)]
|
||||||
|
enum RopeError {
|
||||||
|
#[error("Not a legal command {0}")]
|
||||||
|
CommandUnknown(String),
|
||||||
|
|
||||||
|
#[error["not a legal Direction {0}"]]
|
||||||
|
DirectionUnknown(String),
|
||||||
|
|
||||||
|
#[error("Not a legal Integer")]
|
||||||
|
StepParseError(#[from] ParseIntError),
|
||||||
|
}
|
||||||
|
|
||||||
|
fn parse_commands(lines: &[String]) -> Result<Vec<(Direction, usize)>, RopeError> {
|
||||||
|
lines.iter().map(parse_line).collect::<Result<_, _>>()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn parse_line(line: &String) -> Result<(Direction, usize), RopeError> {
|
||||||
|
match line.split_whitespace().collect::<Vec<_>>()[..] {
|
||||||
|
[direction, steps] => {
|
||||||
|
let direction = match direction {
|
||||||
|
"U" => Direction::North,
|
||||||
|
"D" => Direction::South,
|
||||||
|
"R" => Direction::East,
|
||||||
|
"L" => Direction::West,
|
||||||
|
_ => {
|
||||||
|
return Err(RopeError::DirectionUnknown(direction.to_owned()));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let steps = steps.parse()?;
|
||||||
|
Ok((direction, steps))
|
||||||
|
}
|
||||||
|
_ => Err(RopeError::CommandUnknown(line.to_owned())),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_closer(first: Pos<i32>, second: Pos<i32>) -> Option<Pos<i32>> {
|
||||||
|
let diff = second - first;
|
||||||
|
if diff.x().abs() <= 1 && diff.y().abs() <= 1 {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(Pos::new(diff.x().signum(), diff.y().signum()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
struct Rope {
|
||||||
|
head: Pos<i32>,
|
||||||
|
knots: Vec<Pos<i32>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Rope {
|
||||||
|
pub fn create(length: usize) -> Self {
|
||||||
|
assert!(length >= 2);
|
||||||
|
Rope {
|
||||||
|
head: Pos::new(0, 0),
|
||||||
|
knots: vec![Pos::new(0, 0); length - 1],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Moves the head one step into the given direction
|
||||||
|
* returns true if the whole rope moved, otherwise false
|
||||||
|
*/
|
||||||
|
pub fn move_rope(&mut self, head_direction: Direction) -> bool {
|
||||||
|
self.head = self.head + head_direction;
|
||||||
|
let mut prev = self.head;
|
||||||
|
let mut knots_unmoved = self.knots.len();
|
||||||
|
|
||||||
|
for knot in self.knots.iter_mut() {
|
||||||
|
if let Some(diff) = get_closer(*knot, prev) {
|
||||||
|
*knot = *knot + diff;
|
||||||
|
prev = *knot;
|
||||||
|
knots_unmoved -= 1;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
knots_unmoved == 0
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn run(&mut self, commands: &[(Direction, usize)]) -> i64 {
|
||||||
|
let mut tail_visited = HashSet::new();
|
||||||
|
tail_visited.insert(self.knots.last().copied().unwrap());
|
||||||
|
|
||||||
|
for (direction, steps) in commands {
|
||||||
|
for _ in 0..*steps {
|
||||||
|
if self.move_rope(*direction) {
|
||||||
|
tail_visited.insert(self.knots.last().copied().unwrap());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tail_visited.len() as i64
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod test {
|
||||||
|
use super::*;
|
||||||
|
use crate::common::file::read_lines;
|
||||||
|
use anyhow::Result;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_part1() -> Result<()> {
|
||||||
|
let day = Day {};
|
||||||
|
let lines = read_lines(day.get_day_number(), "example01.txt")?;
|
||||||
|
let expected = ResultType::Integer(13);
|
||||||
|
let result = day.part1(&lines)?;
|
||||||
|
assert_eq!(result, expected);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_part2() -> Result<()> {
|
||||||
|
let day = Day {};
|
||||||
|
let lines = read_lines(day.get_day_number(), "example02.txt")?;
|
||||||
|
let expected = ResultType::Integer(36);
|
||||||
|
let result = day.part2(&lines)?;
|
||||||
|
assert_eq!(result, expected);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
165
src/days/day10/mod.rs
Normal file
165
src/days/day10/mod.rs
Normal file
|
|
@ -0,0 +1,165 @@
|
||||||
|
use super::template::{DayTrait, ResultType};
|
||||||
|
use std::{num::ParseIntError, slice::Iter};
|
||||||
|
use thiserror::Error;
|
||||||
|
|
||||||
|
const DAY_NUMBER: usize = 10;
|
||||||
|
|
||||||
|
pub struct Day;
|
||||||
|
|
||||||
|
impl DayTrait for Day {
|
||||||
|
fn get_day_number(&self) -> usize {
|
||||||
|
DAY_NUMBER
|
||||||
|
}
|
||||||
|
|
||||||
|
fn part1(&self, lines: &[String]) -> anyhow::Result<ResultType> {
|
||||||
|
let instructions = lines
|
||||||
|
.iter()
|
||||||
|
.map(|line| Instruction::parse(line))
|
||||||
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
|
let result = CpuCycles::signal_strength(&instructions, &[20, 60, 100, 140, 180, 220]);
|
||||||
|
Ok(ResultType::Integer(result as i64))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn part2(&self, lines: &[String]) -> anyhow::Result<ResultType> {
|
||||||
|
let instructions = lines
|
||||||
|
.iter()
|
||||||
|
.map(|line| Instruction::parse(line))
|
||||||
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
|
let result = CpuCycles::draw(&instructions);
|
||||||
|
Ok(ResultType::Lines(result))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Error)]
|
||||||
|
enum CpuError {
|
||||||
|
#[error("unknown instruction: {0}")]
|
||||||
|
UnknownInstruction(String),
|
||||||
|
|
||||||
|
#[error("could not parse Number")]
|
||||||
|
InvalidInteger(#[from] ParseIntError),
|
||||||
|
}
|
||||||
|
|
||||||
|
enum Instruction {
|
||||||
|
Add(i32),
|
||||||
|
Noop,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Instruction {
|
||||||
|
pub fn parse(line: &str) -> Result<Self, CpuError> {
|
||||||
|
if line == "noop" {
|
||||||
|
Ok(Instruction::Noop)
|
||||||
|
} else if line.starts_with("addx") {
|
||||||
|
let value = line[5..].parse()?;
|
||||||
|
Ok(Instruction::Add(value))
|
||||||
|
} else {
|
||||||
|
Err(CpuError::UnknownInstruction(line.to_owned()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct CpuCycles<'a> {
|
||||||
|
register: i32,
|
||||||
|
instructions: Iter<'a, Instruction>,
|
||||||
|
current: Option<i32>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> CpuCycles<'a> {
|
||||||
|
pub fn create(instructions: &'a [Instruction]) -> Self {
|
||||||
|
Self {
|
||||||
|
instructions: instructions.iter(),
|
||||||
|
register: 1,
|
||||||
|
current: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn signal_strength(instructions: &'a [Instruction], to_collect: &[usize]) -> i32 {
|
||||||
|
CpuCycles::create(instructions)
|
||||||
|
.enumerate()
|
||||||
|
.filter_map(|(cycle, register)| {
|
||||||
|
if to_collect.contains(&(cycle + 1)) {
|
||||||
|
Some(register * (cycle + 1) as i32)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.sum()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn draw(instructions: &'a [Instruction]) -> Vec<String> {
|
||||||
|
let mut result = Vec::new();
|
||||||
|
let mut line = "".to_owned();
|
||||||
|
for (cycle, sprite) in CpuCycles::create(instructions).enumerate() {
|
||||||
|
let cycle = (cycle % 40) as i32;
|
||||||
|
if (sprite - cycle).abs() <= 1 {
|
||||||
|
line.push('#');
|
||||||
|
} else {
|
||||||
|
line.push(' ');
|
||||||
|
}
|
||||||
|
if cycle == 39 {
|
||||||
|
result.push(line.to_owned());
|
||||||
|
line = "".to_owned();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> Iterator for CpuCycles<'a> {
|
||||||
|
type Item = i32;
|
||||||
|
|
||||||
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
|
if let Some(value) = self.current {
|
||||||
|
let start_register = self.register;
|
||||||
|
self.register += value;
|
||||||
|
self.current = None;
|
||||||
|
Some(start_register)
|
||||||
|
} else if let Some(instruction) = self.instructions.next() {
|
||||||
|
match instruction {
|
||||||
|
Instruction::Add(value) => self.current = Some(*value),
|
||||||
|
Instruction::Noop => {}
|
||||||
|
}
|
||||||
|
Some(self.register)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod test {
|
||||||
|
use super::*;
|
||||||
|
use crate::common::file::read_lines;
|
||||||
|
use anyhow::Result;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_simple() -> Result<()> {
|
||||||
|
let instructions = vec![Instruction::Noop, Instruction::Add(3), Instruction::Add(-5)];
|
||||||
|
let expected = vec![1, 1, 1, 4, 4];
|
||||||
|
let result = CpuCycles::create(&instructions).collect::<Vec<_>>();
|
||||||
|
assert_eq!(result, expected);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_part1() -> Result<()> {
|
||||||
|
let day = Day {};
|
||||||
|
let lines = read_lines(day.get_day_number(), "example01.txt")?;
|
||||||
|
let expected = ResultType::Integer(13140);
|
||||||
|
let result = day.part1(&lines)?;
|
||||||
|
assert_eq!(result, expected);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_part2() -> Result<()> {
|
||||||
|
let day = Day {};
|
||||||
|
let lines = read_lines(day.get_day_number(), "example01.txt")?;
|
||||||
|
let expected = ResultType::Lines(read_lines(day.get_day_number(), "expected01.txt")?);
|
||||||
|
let result = day.part2(&lines)?;
|
||||||
|
assert_eq!(result, expected);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
246
src/days/day11/mod.rs
Normal file
246
src/days/day11/mod.rs
Normal file
|
|
@ -0,0 +1,246 @@
|
||||||
|
use super::template::{DayTrait, ResultType};
|
||||||
|
use lazy_static::lazy_static;
|
||||||
|
use regex::Regex;
|
||||||
|
use std::{iter::zip, num::ParseIntError};
|
||||||
|
use thiserror::Error;
|
||||||
|
|
||||||
|
const DAY_NUMBER: usize = 11;
|
||||||
|
|
||||||
|
pub struct Day;
|
||||||
|
|
||||||
|
impl DayTrait for Day {
|
||||||
|
fn get_day_number(&self) -> usize {
|
||||||
|
DAY_NUMBER
|
||||||
|
}
|
||||||
|
|
||||||
|
fn part1(&self, lines: &[String]) -> anyhow::Result<ResultType> {
|
||||||
|
let troop = Troop::parse(lines)?;
|
||||||
|
Ok(ResultType::Integer(troop.play(20)))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn part2(&self, lines: &[String]) -> anyhow::Result<ResultType> {
|
||||||
|
let troop = Troop::parse(lines)?;
|
||||||
|
Ok(ResultType::Integer(troop.play_again(10_000)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Error)]
|
||||||
|
enum MonkeyError {
|
||||||
|
#[error("Not an Integer")]
|
||||||
|
NotAnInteger(#[from] ParseIntError),
|
||||||
|
|
||||||
|
#[error("Can't parse line: {0}")]
|
||||||
|
UnknownLine(String),
|
||||||
|
|
||||||
|
#[error("Did not expect end of Input")]
|
||||||
|
PrematureEndOfInput,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
|
enum Operation {
|
||||||
|
Plus(i64),
|
||||||
|
Times(i64),
|
||||||
|
Squared,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Operation {
|
||||||
|
pub fn parse(line: &str) -> Operation {
|
||||||
|
match line.split_whitespace().collect::<Vec<_>>()[..] {
|
||||||
|
["*", "old"] => Operation::Squared,
|
||||||
|
["*", value] => Operation::Times(value.parse().unwrap()),
|
||||||
|
["+", value] => Operation::Plus(value.parse().unwrap()),
|
||||||
|
_ => unreachable!(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn calc(&self, old: i64) -> i64 {
|
||||||
|
match self {
|
||||||
|
Operation::Plus(value) => old + *value,
|
||||||
|
Operation::Times(value) => old * value,
|
||||||
|
Operation::Squared => old.pow(2),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
|
struct Monkey {
|
||||||
|
number: usize,
|
||||||
|
items: Vec<i64>,
|
||||||
|
operation: Operation,
|
||||||
|
divisor: i64,
|
||||||
|
good_monkey: usize,
|
||||||
|
bad_monkey: usize,
|
||||||
|
}
|
||||||
|
|
||||||
|
lazy_static! {
|
||||||
|
static ref MONKEY: Regex = Regex::new(r"Monkey (\d+)").unwrap();
|
||||||
|
static ref STARTING: Regex = Regex::new(r"Starting items: (\d+(?:, \d+)*)").unwrap();
|
||||||
|
static ref OP: Regex = Regex::new(r"Operation: new = old ([+*] \d+|\* old)").unwrap();
|
||||||
|
static ref TEST: Regex = Regex::new(r"Test: divisible by (\d+)").unwrap();
|
||||||
|
static ref NEXT: Regex = Regex::new(r"If (?:true|false): throw to monkey (\d+)").unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Monkey {
|
||||||
|
fn parse_line<'a>(re: &Regex, line: &'a str) -> Result<&'a str, MonkeyError> {
|
||||||
|
let caps = re
|
||||||
|
.captures(line)
|
||||||
|
.ok_or(MonkeyError::UnknownLine(line.to_owned()))?;
|
||||||
|
Ok(caps.get(1).unwrap().as_str())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn parse_one(
|
||||||
|
iterator: &mut dyn Iterator<Item = &String>,
|
||||||
|
) -> Result<Option<Monkey>, MonkeyError> {
|
||||||
|
if let Some(line) = iterator.next() {
|
||||||
|
let number: usize = Monkey::parse_line(&MONKEY, line)?.parse()?;
|
||||||
|
|
||||||
|
let line = iterator.next().ok_or(MonkeyError::PrematureEndOfInput)?;
|
||||||
|
let start = Monkey::parse_line(&STARTING, line)?;
|
||||||
|
let items = start
|
||||||
|
.split(", ")
|
||||||
|
.map(|item| item.parse::<i64>())
|
||||||
|
.collect::<Result<Vec<i64>, _>>()?;
|
||||||
|
|
||||||
|
let line = iterator.next().ok_or(MonkeyError::PrematureEndOfInput)?;
|
||||||
|
let operation = Operation::parse(Monkey::parse_line(&OP, line)?);
|
||||||
|
|
||||||
|
let line = iterator.next().ok_or(MonkeyError::PrematureEndOfInput)?;
|
||||||
|
let divisor: i64 = Monkey::parse_line(&TEST, line)?.parse()?;
|
||||||
|
|
||||||
|
let line = iterator.next().ok_or(MonkeyError::PrematureEndOfInput)?;
|
||||||
|
let good_monkey: usize = Monkey::parse_line(&NEXT, line)?.parse()?;
|
||||||
|
|
||||||
|
let line = iterator.next().ok_or(MonkeyError::PrematureEndOfInput)?;
|
||||||
|
let bad_monkey: usize = Monkey::parse_line(&NEXT, line)?.parse()?;
|
||||||
|
|
||||||
|
iterator.next();
|
||||||
|
|
||||||
|
Ok(Some(Monkey {
|
||||||
|
number,
|
||||||
|
items,
|
||||||
|
operation,
|
||||||
|
divisor,
|
||||||
|
good_monkey,
|
||||||
|
bad_monkey,
|
||||||
|
}))
|
||||||
|
} else {
|
||||||
|
Ok(None)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn process(&self, value: i64) -> i64 {
|
||||||
|
self.operation.calc(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn check(&self, value: i64) -> bool {
|
||||||
|
value % self.divisor == 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Troop {
|
||||||
|
monkeys: Vec<Monkey>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Troop {
|
||||||
|
pub fn parse(lines: &[String]) -> Result<Troop, MonkeyError> {
|
||||||
|
let mut iter = lines.iter();
|
||||||
|
let mut monkeys = Vec::new();
|
||||||
|
while let Some(monkey) = Monkey::parse_one(&mut iter)? {
|
||||||
|
monkeys.push(monkey);
|
||||||
|
}
|
||||||
|
Ok(Troop { monkeys })
|
||||||
|
}
|
||||||
|
|
||||||
|
fn do_play<F>(&self, rounds: usize, alter: F) -> i64
|
||||||
|
where
|
||||||
|
F: Fn(i64) -> i64,
|
||||||
|
{
|
||||||
|
let mut holding = vec![Vec::new(); self.monkeys.len()];
|
||||||
|
let mut inspected = vec![0i64; self.monkeys.len()];
|
||||||
|
for (holding, monkey) in zip(&mut holding, &self.monkeys) {
|
||||||
|
holding.extend(&monkey.items);
|
||||||
|
}
|
||||||
|
for _ in 0..rounds {
|
||||||
|
for (pos, monkey) in self.monkeys.iter().enumerate() {
|
||||||
|
let (good, bad): (Vec<_>, Vec<_>) = holding[pos]
|
||||||
|
.iter()
|
||||||
|
.map(|value| alter(monkey.process(*value)))
|
||||||
|
.partition(|value| monkey.check(*value));
|
||||||
|
inspected[pos] += holding[pos].len() as i64;
|
||||||
|
holding.get_mut(pos).unwrap().clear();
|
||||||
|
holding.get_mut(monkey.good_monkey).unwrap().extend(&good);
|
||||||
|
holding.get_mut(monkey.bad_monkey).unwrap().extend(&bad);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inspected.sort_by(|a, b| b.cmp(a));
|
||||||
|
inspected.iter().take(2).product()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn play(&self, rounds: usize) -> i64 {
|
||||||
|
self.do_play(rounds, |v| v / 3)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn play_again(&self, rounds: usize) -> i64 {
|
||||||
|
let divisor: i64 = self.monkeys.iter().map(|monkey| monkey.divisor).product();
|
||||||
|
self.do_play(rounds, |v| v % divisor)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod test {
|
||||||
|
use super::*;
|
||||||
|
use crate::common::file::read_lines;
|
||||||
|
use anyhow::Result;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_parse() -> Result<()> {
|
||||||
|
let day = Day {};
|
||||||
|
let lines = read_lines(day.get_day_number(), "example01.txt")?;
|
||||||
|
let expected = Monkey {
|
||||||
|
number: 0,
|
||||||
|
items: vec![79, 98],
|
||||||
|
operation: Operation::Times(19),
|
||||||
|
divisor: 23,
|
||||||
|
good_monkey: 2,
|
||||||
|
bad_monkey: 3,
|
||||||
|
};
|
||||||
|
let result = Monkey::parse_one(&mut lines.iter())?.unwrap();
|
||||||
|
assert_eq!(result, expected);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_parse_all() -> Result<()> {
|
||||||
|
let day = Day {};
|
||||||
|
let lines = read_lines(day.get_day_number(), "example01.txt")?;
|
||||||
|
let expected = 4;
|
||||||
|
let result = Troop::parse(&lines)?;
|
||||||
|
assert_eq!(result.monkeys.len(), expected);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_part1() -> Result<()> {
|
||||||
|
let day = Day {};
|
||||||
|
let lines = read_lines(day.get_day_number(), "example01.txt")?;
|
||||||
|
let expected = ResultType::Integer(10605);
|
||||||
|
let result = day.part1(&lines)?;
|
||||||
|
assert_eq!(result, expected);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_part2() -> Result<()> {
|
||||||
|
let day = Day {};
|
||||||
|
let lines = read_lines(day.get_day_number(), "example01.txt")?;
|
||||||
|
let expected = ResultType::Integer(2713310158);
|
||||||
|
let result = day.part2(&lines)?;
|
||||||
|
assert_eq!(result, expected);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
294
src/days/day12/mod.rs
Normal file
294
src/days/day12/mod.rs
Normal file
|
|
@ -0,0 +1,294 @@
|
||||||
|
use std::collections::{BinaryHeap, HashSet};
|
||||||
|
|
||||||
|
use crate::common::pos::Pos;
|
||||||
|
|
||||||
|
use super::template::{DayTrait, ResultType};
|
||||||
|
use thiserror::Error;
|
||||||
|
|
||||||
|
const DAY_NUMBER: usize = 12;
|
||||||
|
|
||||||
|
pub struct Day;
|
||||||
|
|
||||||
|
impl DayTrait for Day {
|
||||||
|
fn get_day_number(&self) -> usize {
|
||||||
|
DAY_NUMBER
|
||||||
|
}
|
||||||
|
|
||||||
|
fn part1(&self, lines: &[String]) -> anyhow::Result<ResultType> {
|
||||||
|
let valley = Valley::parse(lines)?;
|
||||||
|
Ok(ResultType::Integer(valley.walk()? as i64))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn part2(&self, lines: &[String]) -> anyhow::Result<ResultType> {
|
||||||
|
let valley = Valley::parse(lines)?;
|
||||||
|
Ok(ResultType::Integer(valley.walk_short()? as i64))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Error)]
|
||||||
|
enum ValleyError {
|
||||||
|
#[error("Not a legal terrain char: {0}")]
|
||||||
|
NotALegalCharacter(char),
|
||||||
|
#[error("Valley needs to be rectangle")]
|
||||||
|
NotAReactangleValley,
|
||||||
|
#[error("Valley map conatins no data")]
|
||||||
|
EmptyValley,
|
||||||
|
#[error("Could not find start point")]
|
||||||
|
NoStartFound,
|
||||||
|
#[error("Could not find exit point")]
|
||||||
|
NoExitFound,
|
||||||
|
#[error("No path found")]
|
||||||
|
NoPathFound,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
|
struct Path {
|
||||||
|
length: usize,
|
||||||
|
height: char,
|
||||||
|
pos: Pos<usize>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PartialOrd for Path {
|
||||||
|
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
|
||||||
|
match other.length.partial_cmp(&self.length) {
|
||||||
|
Some(core::cmp::Ordering::Equal) => {}
|
||||||
|
ord => return ord,
|
||||||
|
}
|
||||||
|
match other.height.partial_cmp(&self.height) {
|
||||||
|
Some(core::cmp::Ordering::Equal) => {}
|
||||||
|
ord => return ord,
|
||||||
|
}
|
||||||
|
match self.pos.x().partial_cmp(&other.pos.x()) {
|
||||||
|
Some(core::cmp::Ordering::Equal) => {}
|
||||||
|
ord => return ord,
|
||||||
|
}
|
||||||
|
self.pos.y().partial_cmp(&other.pos.y())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Ord for Path {
|
||||||
|
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
|
||||||
|
other
|
||||||
|
.length
|
||||||
|
.cmp(&self.length)
|
||||||
|
.then_with(|| other.height.cmp(&self.height))
|
||||||
|
.then_with(|| self.pos.x().cmp(&other.pos.x()))
|
||||||
|
.then_with(|| self.pos.y().cmp(&other.pos.y()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Path {
|
||||||
|
pub fn new(length: usize, height: char, pos: Pos<usize>) -> Self {
|
||||||
|
Path {
|
||||||
|
length,
|
||||||
|
height,
|
||||||
|
pos,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn next_path<'a>(&'a self, valley: &'a Valley) -> Neighbors<'a> {
|
||||||
|
Neighbors::new(self, valley)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Neighbors<'a> {
|
||||||
|
path: &'a Path,
|
||||||
|
valley: &'a Valley,
|
||||||
|
state: usize,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> Neighbors<'a> {
|
||||||
|
pub fn new(path: &'a Path, valley: &'a Valley) -> Self {
|
||||||
|
Neighbors {
|
||||||
|
path,
|
||||||
|
state: 0,
|
||||||
|
valley,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn next_pos(&mut self) -> Option<Pos<usize>> {
|
||||||
|
while self.state < 4 {
|
||||||
|
self.state += 1;
|
||||||
|
match self.state {
|
||||||
|
1 => {
|
||||||
|
if self.path.pos.x() < self.valley.width() - 1 {
|
||||||
|
return Some(Pos::new(self.path.pos.x() + 1, self.path.pos.y()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
2 => {
|
||||||
|
if self.path.pos.y() > 0 {
|
||||||
|
return Some(Pos::new(self.path.pos.x(), self.path.pos.y() - 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
3 => {
|
||||||
|
if self.path.pos.x() > 0 {
|
||||||
|
return Some(Pos::new(self.path.pos.x() - 1, self.path.pos.y()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
4 => {
|
||||||
|
if self.path.pos.y() < self.valley.height() - 1 {
|
||||||
|
return Some(Pos::new(self.path.pos.x(), self.path.pos.y() + 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Iterator for Neighbors<'_> {
|
||||||
|
type Item = Path;
|
||||||
|
|
||||||
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
|
while let Some(pos) = self.next_pos() {
|
||||||
|
let height = self.valley.get_height(pos);
|
||||||
|
if height as u32 + 1 >= self.path.height as u32 {
|
||||||
|
return Some(Path::new(self.path.length + 1, height, pos));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Valley {
|
||||||
|
map: Vec<Vec<char>>,
|
||||||
|
start: Pos<usize>,
|
||||||
|
exit: Pos<usize>,
|
||||||
|
width: usize,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Valley {
|
||||||
|
pub fn parse(lines: &[String]) -> Result<Valley, ValleyError> {
|
||||||
|
let mut map = Vec::new();
|
||||||
|
let mut start = None;
|
||||||
|
let mut exit = None;
|
||||||
|
let mut valley_width = None;
|
||||||
|
for (y, row) in lines.iter().enumerate() {
|
||||||
|
let mut height_row = Vec::new();
|
||||||
|
for (x, height_char) in row.chars().enumerate() {
|
||||||
|
match height_char {
|
||||||
|
'S' => {
|
||||||
|
start = Some(Pos::new(x, y));
|
||||||
|
height_row.push('a')
|
||||||
|
}
|
||||||
|
'E' => {
|
||||||
|
exit = Some(Pos::new(x, y));
|
||||||
|
height_row.push('z')
|
||||||
|
}
|
||||||
|
'a'..='z' => height_row.push(height_char),
|
||||||
|
_ => return Err(ValleyError::NotALegalCharacter(height_char)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if let Some(width) = valley_width {
|
||||||
|
if width != height_row.len() {
|
||||||
|
return Err(ValleyError::NotAReactangleValley);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
valley_width = Some(height_row.len());
|
||||||
|
}
|
||||||
|
map.push(height_row);
|
||||||
|
}
|
||||||
|
let Some(width) = valley_width else {
|
||||||
|
return Err(ValleyError::EmptyValley);
|
||||||
|
};
|
||||||
|
let Some(start) = start else {
|
||||||
|
return Err(ValleyError::NoStartFound);
|
||||||
|
};
|
||||||
|
let Some(exit) = exit else {
|
||||||
|
return Err(ValleyError::NoExitFound);
|
||||||
|
};
|
||||||
|
Ok(Valley {
|
||||||
|
map,
|
||||||
|
start,
|
||||||
|
exit,
|
||||||
|
width,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_height(&self, pos: Pos<usize>) -> char {
|
||||||
|
self.map[pos.y()][pos.x()]
|
||||||
|
}
|
||||||
|
|
||||||
|
fn do_walk<F>(&self, check: F) -> Result<usize, ValleyError>
|
||||||
|
where
|
||||||
|
F: Fn(Pos<usize>) -> bool,
|
||||||
|
{
|
||||||
|
let mut shortest = HashSet::with_capacity(self.width * self.map.len());
|
||||||
|
let mut queue = BinaryHeap::new();
|
||||||
|
queue.push(Path::new(0, 'z', self.exit));
|
||||||
|
while let Some(current) = queue.pop() {
|
||||||
|
if check(current.pos) {
|
||||||
|
return Ok(current.length);
|
||||||
|
}
|
||||||
|
if shortest.contains(¤t.pos) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
shortest.insert(current.pos);
|
||||||
|
for next in current.next_path(self) {
|
||||||
|
queue.push(next);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Err(ValleyError::NoPathFound)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn walk(&self) -> Result<usize, ValleyError> {
|
||||||
|
self.do_walk(|pos| pos == self.start)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn walk_short(&self) -> Result<usize, ValleyError> {
|
||||||
|
self.do_walk(|pos| self.get_height(pos) == 'a')
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn width(&self) -> usize {
|
||||||
|
self.width
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn height(&self) -> usize {
|
||||||
|
self.map.len()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod test {
|
||||||
|
use super::*;
|
||||||
|
use crate::common::file::read_lines;
|
||||||
|
use anyhow::Result;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_parse() -> Result<()> {
|
||||||
|
let day = Day {};
|
||||||
|
let lines = read_lines(day.get_day_number(), "example01.txt")?;
|
||||||
|
let valley = Valley::parse(&lines)?;
|
||||||
|
assert_eq!(valley.width, 8);
|
||||||
|
assert_eq!(valley.start, Pos::new(0, 0));
|
||||||
|
assert_eq!(valley.exit, Pos::new(5, 2));
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_part1() -> Result<()> {
|
||||||
|
let day = Day {};
|
||||||
|
let lines = read_lines(day.get_day_number(), "example01.txt")?;
|
||||||
|
let expected = ResultType::Integer(31);
|
||||||
|
let result = day.part1(&lines)?;
|
||||||
|
assert_eq!(result, expected);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_part2() -> Result<()> {
|
||||||
|
let day = Day {};
|
||||||
|
let lines = read_lines(day.get_day_number(), "example01.txt")?;
|
||||||
|
let expected = ResultType::Integer(29);
|
||||||
|
let result = day.part2(&lines)?;
|
||||||
|
assert_eq!(result, expected);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
220
src/days/day13/mod.rs
Normal file
220
src/days/day13/mod.rs
Normal file
|
|
@ -0,0 +1,220 @@
|
||||||
|
use std::cmp::Ordering;
|
||||||
|
|
||||||
|
use super::template::{DayTrait, ResultType};
|
||||||
|
use itertools::Itertools;
|
||||||
|
use thiserror::Error;
|
||||||
|
|
||||||
|
const DAY_NUMBER: usize = 13;
|
||||||
|
|
||||||
|
pub struct Day;
|
||||||
|
|
||||||
|
impl DayTrait for Day {
|
||||||
|
fn get_day_number(&self) -> usize {
|
||||||
|
DAY_NUMBER
|
||||||
|
}
|
||||||
|
|
||||||
|
fn part1(&self, lines: &[String]) -> anyhow::Result<ResultType> {
|
||||||
|
let packets = Packets::parse_all(lines)?;
|
||||||
|
let result: i64 = packets
|
||||||
|
.iter()
|
||||||
|
.tuples()
|
||||||
|
.enumerate()
|
||||||
|
.filter_map(|(pos, (first, second))| {
|
||||||
|
if first < second {
|
||||||
|
Some(pos as i64 + 1)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.sum();
|
||||||
|
Ok(ResultType::Integer(result))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn part2(&self, lines: &[String]) -> anyhow::Result<ResultType> {
|
||||||
|
let small = Packets::parse("[[2]]")?;
|
||||||
|
let large = Packets::parse("[[6]]")?;
|
||||||
|
let mut pos_small = 1;
|
||||||
|
let mut pos_large = 2;
|
||||||
|
let packets = Packets::parse_all(lines)?;
|
||||||
|
for packet in packets {
|
||||||
|
if packet < small {
|
||||||
|
pos_small += 1;
|
||||||
|
pos_large += 1;
|
||||||
|
} else if packet < large {
|
||||||
|
pos_large += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(ResultType::Integer(pos_small * pos_large))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Error)]
|
||||||
|
enum PacketError {
|
||||||
|
#[error("Empty Packet not allowed")]
|
||||||
|
EmptyPacketNotAllowed,
|
||||||
|
#[error("Packtet must start with a [ was: {0}")]
|
||||||
|
ExpectedSquare(char),
|
||||||
|
#[error("Unknown char: {0}")]
|
||||||
|
UnknownChar(char),
|
||||||
|
#[error("End of input reached to early")]
|
||||||
|
PrematureEndOfInput,
|
||||||
|
#[error("Number was not terminated correctly")]
|
||||||
|
UnfinishedNumber,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||||
|
enum Packets {
|
||||||
|
Number(u32),
|
||||||
|
List(Vec<Packets>),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PartialOrd for Packets {
|
||||||
|
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||||
|
match (self, other) {
|
||||||
|
(Packets::Number(first), Packets::Number(second)) => first.partial_cmp(second),
|
||||||
|
(Packets::List(first), Packets::List(second)) => {
|
||||||
|
for pair in first.iter().zip_longest(second.iter()) {
|
||||||
|
let result = match pair {
|
||||||
|
itertools::EitherOrBoth::Left(_) => Some(Ordering::Greater),
|
||||||
|
itertools::EitherOrBoth::Right(_) => Some(Ordering::Less),
|
||||||
|
itertools::EitherOrBoth::Both(first, second) => first.partial_cmp(second),
|
||||||
|
};
|
||||||
|
if !matches!(result, Some(Ordering::Equal)) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Some(Ordering::Equal)
|
||||||
|
}
|
||||||
|
(Packets::Number(_), Packets::List(_)) => self.as_list().partial_cmp(other),
|
||||||
|
(Packets::List(_), Packets::Number(_)) => self.partial_cmp(&other.as_list()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Packets {
|
||||||
|
pub fn as_list(&self) -> Packets {
|
||||||
|
match self {
|
||||||
|
Packets::Number(_) => Packets::List(vec![self.clone()]),
|
||||||
|
Packets::List(_) => self.clone(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn parse(line: &str) -> Result<Packets, PacketError> {
|
||||||
|
let mut chars = line.chars();
|
||||||
|
let Some(start) = chars.next() else {
|
||||||
|
return Err(PacketError::EmptyPacketNotAllowed);
|
||||||
|
};
|
||||||
|
if start != '[' {
|
||||||
|
return Err(PacketError::ExpectedSquare(start));
|
||||||
|
}
|
||||||
|
let packet = Packets::parse_one(&mut chars)?;
|
||||||
|
Ok(packet)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn parse_one(chars: &mut dyn Iterator<Item = char>) -> Result<Packets, PacketError> {
|
||||||
|
let mut list = Vec::new();
|
||||||
|
let mut number = None;
|
||||||
|
while let Some(next) = chars.next() {
|
||||||
|
match next {
|
||||||
|
'[' => {
|
||||||
|
if number.is_some() {
|
||||||
|
return Err(PacketError::UnfinishedNumber);
|
||||||
|
}
|
||||||
|
list.push(Packets::parse_one(chars)?);
|
||||||
|
}
|
||||||
|
']' => {
|
||||||
|
if let Some(number) = number {
|
||||||
|
list.push(Packets::Number(number));
|
||||||
|
}
|
||||||
|
return Ok(Packets::List(list));
|
||||||
|
}
|
||||||
|
',' => {
|
||||||
|
if let Some(number) = number {
|
||||||
|
list.push(Packets::Number(number));
|
||||||
|
}
|
||||||
|
number = None;
|
||||||
|
}
|
||||||
|
'0'..='9' => match number {
|
||||||
|
None => number = Some(next.to_digit(10).unwrap()),
|
||||||
|
Some(prev) => number = Some(prev * 10 + next.to_digit(10).unwrap()),
|
||||||
|
},
|
||||||
|
_ => return Err(PacketError::UnknownChar(next)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(PacketError::PrematureEndOfInput)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn parse_all(lines: &[String]) -> Result<Vec<Packets>, PacketError> {
|
||||||
|
lines
|
||||||
|
.iter()
|
||||||
|
.filter(|line| !line.is_empty())
|
||||||
|
.map(|line| Packets::parse(line))
|
||||||
|
.collect::<Result<Vec<_>, _>>()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod test {
|
||||||
|
use super::*;
|
||||||
|
use crate::common::file::read_lines;
|
||||||
|
use anyhow::Result;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_parse() -> Result<()> {
|
||||||
|
let input = "[[1],[2,3]]";
|
||||||
|
let expected = Packets::List(vec![
|
||||||
|
Packets::List(vec![Packets::Number(1)]),
|
||||||
|
Packets::List(vec![Packets::Number(2), Packets::Number(3)]),
|
||||||
|
]);
|
||||||
|
let result = Packets::parse(input)?;
|
||||||
|
assert_eq!(result, expected);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_parse_all() -> Result<()> {
|
||||||
|
let day = Day {};
|
||||||
|
let lines = read_lines(day.get_day_number(), "example01.txt")?;
|
||||||
|
let result = Packets::parse_all(&lines)?;
|
||||||
|
assert_eq!(result.len(), 16);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_compare_all() -> Result<()> {
|
||||||
|
let day = Day {};
|
||||||
|
let lines = read_lines(day.get_day_number(), "example01.txt")?;
|
||||||
|
let expected = vec![true, true, false, true, false, true, false, false];
|
||||||
|
let result = Packets::parse_all(&lines)?;
|
||||||
|
let compare = result
|
||||||
|
.iter()
|
||||||
|
.tuples()
|
||||||
|
.map(|(first, second)| first < second)
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
assert_eq!(compare, expected);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_part1() -> Result<()> {
|
||||||
|
let day = Day {};
|
||||||
|
let lines = read_lines(day.get_day_number(), "example01.txt")?;
|
||||||
|
let expected = ResultType::Integer(13);
|
||||||
|
let result = day.part1(&lines)?;
|
||||||
|
assert_eq!(result, expected);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_part2() -> Result<()> {
|
||||||
|
let day = Day {};
|
||||||
|
let lines = read_lines(day.get_day_number(), "example01.txt")?;
|
||||||
|
let expected = ResultType::Integer(140);
|
||||||
|
let result = day.part2(&lines)?;
|
||||||
|
assert_eq!(result, expected);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
292
src/days/day14/mod.rs
Normal file
292
src/days/day14/mod.rs
Normal file
|
|
@ -0,0 +1,292 @@
|
||||||
|
use itertools::Itertools;
|
||||||
|
use std::{collections::HashSet, num::ParseIntError};
|
||||||
|
use thiserror::Error;
|
||||||
|
|
||||||
|
use crate::common::pos::Pos;
|
||||||
|
|
||||||
|
use super::template::{DayTrait, ResultType};
|
||||||
|
|
||||||
|
const DAY_NUMBER: usize = 14;
|
||||||
|
|
||||||
|
pub struct Day;
|
||||||
|
|
||||||
|
impl DayTrait for Day {
|
||||||
|
fn get_day_number(&self) -> usize {
|
||||||
|
DAY_NUMBER
|
||||||
|
}
|
||||||
|
|
||||||
|
fn part1(&self, lines: &[String]) -> anyhow::Result<ResultType> {
|
||||||
|
let cave = Cave::parse(lines)?;
|
||||||
|
Ok(ResultType::Integer(cave.drop_bottomless() as i64))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn part2(&self, lines: &[String]) -> anyhow::Result<ResultType> {
|
||||||
|
let cave = Cave::parse(lines)?;
|
||||||
|
Ok(ResultType::Integer(cave.drop_floor()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Error)]
|
||||||
|
enum CaveError {
|
||||||
|
#[error("Could not parse")]
|
||||||
|
ParseError,
|
||||||
|
|
||||||
|
#[error("Error, while paring int")]
|
||||||
|
NotAValidInteger(#[from] ParseIntError),
|
||||||
|
|
||||||
|
#[error("Not a valid Pos {0}")]
|
||||||
|
NotAValidPos(String),
|
||||||
|
|
||||||
|
#[error("Found an empty path")]
|
||||||
|
EmptyPath,
|
||||||
|
|
||||||
|
#[error("Found an empty cave")]
|
||||||
|
EmptyCave,
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Cave {
|
||||||
|
map: Vec<Vec<bool>>,
|
||||||
|
min_x: i32,
|
||||||
|
max_x: i32,
|
||||||
|
height: i32,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Cave {
|
||||||
|
fn get(&self, map: &[Vec<bool>], pos: Pos<i32>) -> bool {
|
||||||
|
if pos.y() >= self.height || pos.x() < self.min_x || pos.x() > self.max_x {
|
||||||
|
false
|
||||||
|
} else {
|
||||||
|
map[pos.y() as usize][(pos.x() - self.min_x) as usize]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set(&self, map: &mut [Vec<bool>], pos: Pos<i32>) {
|
||||||
|
map[pos.y() as usize][(pos.x() - self.min_x) as usize] = true
|
||||||
|
}
|
||||||
|
|
||||||
|
fn walk(from: Pos<i32>, to: Pos<i32>) -> Result<Vec<Pos<i32>>, CaveError> {
|
||||||
|
if from == to {
|
||||||
|
return Ok(vec![from]);
|
||||||
|
}
|
||||||
|
if from.x() == to.x() {
|
||||||
|
if from.y() < to.y() {
|
||||||
|
Ok((from.y()..to.y()).map(|y| Pos::new(from.x(), y)).collect())
|
||||||
|
} else {
|
||||||
|
Ok(((to.y() + 1)..=from.y())
|
||||||
|
.map(|y| Pos::new(from.x(), y))
|
||||||
|
.collect())
|
||||||
|
}
|
||||||
|
} else if from.y() == to.y() {
|
||||||
|
if from.x() < to.x() {
|
||||||
|
Ok((from.x()..to.x()).map(|x| Pos::new(x, from.y())).collect())
|
||||||
|
} else {
|
||||||
|
Ok(((to.x() + 1)..=from.x())
|
||||||
|
.map(|x| Pos::new(x, from.y()))
|
||||||
|
.collect())
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Err(CaveError::ParseError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn parse_one(line: &str) -> Result<HashSet<Pos<i32>>, CaveError> {
|
||||||
|
let corners = line
|
||||||
|
.split("->")
|
||||||
|
.map(|coord| match coord.split(',').collect::<Vec<_>>()[..] {
|
||||||
|
[first, second] => {
|
||||||
|
let x: i32 = first.trim().parse()?;
|
||||||
|
let y = second.trim().parse()?;
|
||||||
|
Ok(Pos::new(x, y))
|
||||||
|
}
|
||||||
|
_ => Err(CaveError::NotAValidPos(coord.to_owned())),
|
||||||
|
})
|
||||||
|
.collect::<Result<Vec<_>, CaveError>>()?;
|
||||||
|
|
||||||
|
if corners.is_empty() {
|
||||||
|
return Err(CaveError::EmptyPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
let blocks = corners
|
||||||
|
.iter()
|
||||||
|
.tuple_windows()
|
||||||
|
.map(|(first, second)| Cave::walk(*first, *second))
|
||||||
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
|
|
||||||
|
let mut blocks = blocks.iter().flatten().copied().collect::<HashSet<_>>();
|
||||||
|
blocks.insert(*corners.last().unwrap());
|
||||||
|
|
||||||
|
Ok(blocks)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn parse(lines: &[String]) -> Result<Cave, CaveError> {
|
||||||
|
let mut cave: HashSet<Pos<i32>> = HashSet::new();
|
||||||
|
for line in lines {
|
||||||
|
cave.extend(Cave::parse_one(line)?.iter());
|
||||||
|
}
|
||||||
|
if cave.is_empty() {
|
||||||
|
Err(CaveError::EmptyCave)
|
||||||
|
} else {
|
||||||
|
let mut max_x = i32::MIN;
|
||||||
|
let mut min_x = i32::MAX;
|
||||||
|
let mut max_y = i32::MIN;
|
||||||
|
for block in &cave {
|
||||||
|
if block.x() < min_x {
|
||||||
|
min_x = block.x();
|
||||||
|
}
|
||||||
|
if block.x() > max_x {
|
||||||
|
max_x = block.x();
|
||||||
|
}
|
||||||
|
if block.y() > max_y {
|
||||||
|
max_y = block.y()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let mut map = vec![vec![false; (max_x - min_x + 1) as usize]; (max_y + 1) as usize];
|
||||||
|
for block in cave {
|
||||||
|
map[block.y() as usize][(block.x() - min_x) as usize] = true;
|
||||||
|
}
|
||||||
|
Ok(Cave {
|
||||||
|
map,
|
||||||
|
min_x,
|
||||||
|
max_x,
|
||||||
|
height: max_y + 1,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn drop_bottomless(&self) -> u32 {
|
||||||
|
let mut drops = 0;
|
||||||
|
let mut filled_map = self.map.to_vec();
|
||||||
|
|
||||||
|
while let Some(next) = self.drop_one(&filled_map) {
|
||||||
|
if next.y() <= self.height {
|
||||||
|
drops += 1;
|
||||||
|
self.set(&mut filled_map, next);
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
drops
|
||||||
|
}
|
||||||
|
|
||||||
|
fn drop_one(&self, map: &[Vec<bool>]) -> Option<Pos<i32>> {
|
||||||
|
let mut drop = Pos::new(500, 0);
|
||||||
|
loop {
|
||||||
|
let next_y = drop.y() + 1;
|
||||||
|
if next_y > self.height {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
let mut stuck = true;
|
||||||
|
for dx in [0, -1, 1] {
|
||||||
|
let next = Pos::new(drop.x() + dx, next_y);
|
||||||
|
if !self.get(map, next) {
|
||||||
|
drop = next;
|
||||||
|
stuck = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if stuck {
|
||||||
|
if drop.y() == 0 {
|
||||||
|
return None;
|
||||||
|
} else {
|
||||||
|
return Some(drop);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn drop_floor(&self) -> i64 {
|
||||||
|
let last_row = self.height + 1;
|
||||||
|
let mut drops = 1;
|
||||||
|
let mut row = vec![500];
|
||||||
|
let mut left_exceed = None;
|
||||||
|
let mut right_exceed = None;
|
||||||
|
for y in 1..last_row {
|
||||||
|
let mut next_row = Vec::new();
|
||||||
|
for x in row {
|
||||||
|
for dx in [-1, 0, 1] {
|
||||||
|
let x = x + dx;
|
||||||
|
if x < self.min_x {
|
||||||
|
left_exceed = left_exceed.or(Some(y));
|
||||||
|
} else if x > self.max_x {
|
||||||
|
right_exceed = right_exceed.or(Some(y));
|
||||||
|
} else if !next_row.contains(&x)
|
||||||
|
&& (y >= self.height || !self.map[y as usize][(x - self.min_x) as usize])
|
||||||
|
{
|
||||||
|
next_row.push(x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if let Some(left_exceed) = left_exceed {
|
||||||
|
if !next_row.contains(&self.min_x) && (y >= self.height || !self.map[y as usize][0])
|
||||||
|
{
|
||||||
|
next_row.push(self.min_x);
|
||||||
|
}
|
||||||
|
drops += (y - left_exceed + 1) as i64;
|
||||||
|
}
|
||||||
|
if let Some(right_exceed) = right_exceed {
|
||||||
|
if !next_row.contains(&self.max_x)
|
||||||
|
&& (y >= self.height
|
||||||
|
|| !self.map[y as usize][(self.max_x - self.min_x) as usize])
|
||||||
|
{
|
||||||
|
next_row.push(self.max_x);
|
||||||
|
}
|
||||||
|
drops += (y - right_exceed + 1) as i64;
|
||||||
|
}
|
||||||
|
drops += next_row.len() as i64;
|
||||||
|
row = next_row
|
||||||
|
}
|
||||||
|
drops
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod test {
|
||||||
|
use super::*;
|
||||||
|
use crate::{common::file::read_lines, hashset};
|
||||||
|
use anyhow::Result;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_parse() -> Result<()> {
|
||||||
|
let input = "498,4 -> 498,6 -> 496,6";
|
||||||
|
let expected = hashset! {Pos::new(498, 4), Pos::new(498, 5), Pos::new(498, 6), Pos::new(497, 6), Pos::new(496, 6)};
|
||||||
|
let result = Cave::parse_one(input)?;
|
||||||
|
assert_eq!(result, expected);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_parse_all() -> Result<()> {
|
||||||
|
let day = Day {};
|
||||||
|
let lines = read_lines(day.get_day_number(), "example01.txt")?;
|
||||||
|
let result = Cave::parse(&lines)?;
|
||||||
|
assert_eq!(result.min_x, 494);
|
||||||
|
assert_eq!(result.max_x, 503);
|
||||||
|
assert_eq!(result.height, 10);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_part1() -> Result<()> {
|
||||||
|
let day = Day {};
|
||||||
|
let lines = read_lines(day.get_day_number(), "example01.txt")?;
|
||||||
|
let expected = ResultType::Integer(24);
|
||||||
|
let result = day.part1(&lines)?;
|
||||||
|
assert_eq!(result, expected);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_part2() -> Result<()> {
|
||||||
|
let day = Day {};
|
||||||
|
let lines = read_lines(day.get_day_number(), "example01.txt")?;
|
||||||
|
let expected = ResultType::Integer(93);
|
||||||
|
let result = day.part2(&lines)?;
|
||||||
|
assert_eq!(result, expected);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
317
src/days/day15/mod.rs
Normal file
317
src/days/day15/mod.rs
Normal file
|
|
@ -0,0 +1,317 @@
|
||||||
|
use super::template::{DayTrait, ResultType};
|
||||||
|
use crate::common::pos::Pos;
|
||||||
|
use itertools::Itertools;
|
||||||
|
use lazy_static::lazy_static;
|
||||||
|
use regex::Regex;
|
||||||
|
use std::{collections::HashSet, num::ParseIntError};
|
||||||
|
use thiserror::Error;
|
||||||
|
|
||||||
|
const DAY_NUMBER: usize = 15;
|
||||||
|
|
||||||
|
pub struct Day;
|
||||||
|
|
||||||
|
impl DayTrait for Day {
|
||||||
|
fn get_day_number(&self) -> usize {
|
||||||
|
DAY_NUMBER
|
||||||
|
}
|
||||||
|
|
||||||
|
fn part1(&self, lines: &[String]) -> anyhow::Result<ResultType> {
|
||||||
|
let row = lines[0].parse()?;
|
||||||
|
let (sensors, beacons) = Day::parse_all(&lines[1..])?;
|
||||||
|
let result = Day::count_coverage_at(&sensors, &beacons, row);
|
||||||
|
Ok(ResultType::Integer(result))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn part2(&self, lines: &[String]) -> anyhow::Result<ResultType> {
|
||||||
|
let (sensors, _) = Day::parse_all(&lines[1..])?;
|
||||||
|
let mid_lines = Day::dividing_lines(&sensors);
|
||||||
|
let points = mid_lines
|
||||||
|
.iter()
|
||||||
|
.tuple_combinations()
|
||||||
|
.filter_map(|(first, second)| first.cross(second))
|
||||||
|
.filter(|pos| sensors.iter().all(|sensor| !sensor.contains(pos)))
|
||||||
|
.dedup()
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
if points.len() != 1 {
|
||||||
|
Err(SensorError::NotExactlyOneResult(points.len()))?;
|
||||||
|
}
|
||||||
|
|
||||||
|
let point = points.first().unwrap();
|
||||||
|
Ok(ResultType::Integer(point.x() * 4000000 + point.y()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Day {
|
||||||
|
fn parse_all(lines: &[String]) -> Result<(HashSet<Sensor>, HashSet<Pos<i64>>), SensorError> {
|
||||||
|
let mut sensors = HashSet::new();
|
||||||
|
let mut beacons = HashSet::new();
|
||||||
|
for line in lines {
|
||||||
|
let (sensor, beacon) = Sensor::parse(line)?;
|
||||||
|
sensors.insert(sensor);
|
||||||
|
beacons.insert(beacon);
|
||||||
|
}
|
||||||
|
Ok((sensors, beacons))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn count_coverage_at(sensors: &HashSet<Sensor>, beacons: &HashSet<Pos<i64>>, row: i64) -> i64 {
|
||||||
|
let ranges = sensors
|
||||||
|
.iter()
|
||||||
|
.filter_map(|sensor| sensor.range_at(row))
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
let merged: i64 = Range::merge_all(&ranges)
|
||||||
|
.iter()
|
||||||
|
.map(|range| range.width())
|
||||||
|
.sum();
|
||||||
|
let sensors = sensors
|
||||||
|
.iter()
|
||||||
|
.filter(|sensor| sensor.pos.y() == row)
|
||||||
|
.count() as i64;
|
||||||
|
let beacons = beacons.iter().filter(|beacons| beacons.y() == row).count() as i64;
|
||||||
|
|
||||||
|
merged - (sensors + beacons)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn dividing_lines(sensors: &HashSet<Sensor>) -> Vec<Line> {
|
||||||
|
sensors
|
||||||
|
.iter()
|
||||||
|
.tuple_combinations()
|
||||||
|
.filter_map(|(first, second)| Line::create(first, second))
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Error)]
|
||||||
|
enum SensorError {
|
||||||
|
#[error("Not an Integer")]
|
||||||
|
NotAnInt(#[from] ParseIntError),
|
||||||
|
|
||||||
|
#[error("Unknown line: {0}")]
|
||||||
|
UnknownLine(String),
|
||||||
|
|
||||||
|
#[error("Did not find exactly one point for the sensor: {0}")]
|
||||||
|
NotExactlyOneResult(usize),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
struct Line {
|
||||||
|
start: Pos<i64>,
|
||||||
|
is_up: bool,
|
||||||
|
steps: i64,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Line {
|
||||||
|
pub fn create(first: &Sensor, second: &Sensor) -> Option<Line> {
|
||||||
|
if first.border_distance(second) != 2 {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
|
let (one, two) = if first.pos.x() < second.pos.x() {
|
||||||
|
(first, second)
|
||||||
|
} else {
|
||||||
|
(second, first)
|
||||||
|
};
|
||||||
|
|
||||||
|
let start;
|
||||||
|
let is_up;
|
||||||
|
if one.pos.y() < two.pos.y() {
|
||||||
|
is_up = true;
|
||||||
|
if one.pos.y() + one.radius <= two.pos.y() {
|
||||||
|
start = Pos::new(one.pos.x(), one.pos.y() + one.radius + 1);
|
||||||
|
} else {
|
||||||
|
start = Pos::new(two.pos.x() - two.radius - 1, two.pos.y());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
is_up = false;
|
||||||
|
if one.pos.y() - one.radius >= two.pos.y() {
|
||||||
|
start = Pos::new(one.pos.x(), one.pos.y() - one.radius - 1);
|
||||||
|
} else {
|
||||||
|
start = Pos::new(two.pos.x() - two.radius - 1, two.pos.y());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let steps = two.pos.x().min(one.pos.x() + one.radius) - start.x();
|
||||||
|
|
||||||
|
Some(Line {
|
||||||
|
start,
|
||||||
|
is_up,
|
||||||
|
steps,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn cross(&self, other: &Line) -> Option<Pos<i64>> {
|
||||||
|
if self.is_up == other.is_up {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
let (bottom_up, top_down) = if self.is_up {
|
||||||
|
(self, other)
|
||||||
|
} else {
|
||||||
|
(other, self)
|
||||||
|
};
|
||||||
|
|
||||||
|
let r2 =
|
||||||
|
bottom_up.start.x() + bottom_up.start.y() - (top_down.start.x() + top_down.start.y());
|
||||||
|
if r2 % 2 != 0 {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
|
let r = r2 / 2;
|
||||||
|
if r < 0 || r > top_down.steps {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
|
let pos = top_down.start + Pos::splat(r);
|
||||||
|
Some(pos)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
|
||||||
|
struct Range(i64, i64);
|
||||||
|
|
||||||
|
impl Range {
|
||||||
|
fn overlaps(&self, other: &Range) -> bool {
|
||||||
|
self.0 <= other.1 && other.0 <= self.1
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn width(&self) -> i64 {
|
||||||
|
self.1 - self.0 + 1
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn merge_all(ranges: &[Range]) -> Vec<Range> {
|
||||||
|
let mut ranges: Vec<Range> = ranges.iter().sorted().copied().collect();
|
||||||
|
assert!(!ranges.is_empty());
|
||||||
|
loop {
|
||||||
|
let mut next = vec![];
|
||||||
|
let mut merged = false;
|
||||||
|
let mut current = ranges[0];
|
||||||
|
for range in &ranges[1..] {
|
||||||
|
if current.overlaps(range) {
|
||||||
|
current = Range(current.0, current.1.max(range.1));
|
||||||
|
merged = true;
|
||||||
|
} else {
|
||||||
|
next.push(current);
|
||||||
|
current = *range;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
next.push(current);
|
||||||
|
|
||||||
|
if merged {
|
||||||
|
ranges = next;
|
||||||
|
} else {
|
||||||
|
return next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq, Eq, Copy, Clone, Hash)]
|
||||||
|
struct Sensor {
|
||||||
|
pos: Pos<i64>,
|
||||||
|
radius: i64,
|
||||||
|
}
|
||||||
|
|
||||||
|
lazy_static! {
|
||||||
|
static ref SENSOR: Regex = Regex::new(r"x=(-?\d+), y=(-?\d+).*x=(-?\d+), y=(-?\d+)").unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Sensor {
|
||||||
|
pub fn parse(line: &str) -> Result<(Sensor, Pos<i64>), SensorError> {
|
||||||
|
let caps = SENSOR
|
||||||
|
.captures(line)
|
||||||
|
.ok_or(SensorError::UnknownLine(line.to_owned()))?;
|
||||||
|
let sensor_x = caps.get(1).unwrap().as_str().parse()?;
|
||||||
|
let sensor_y = caps.get(2).unwrap().as_str().parse()?;
|
||||||
|
let beacon_x = caps.get(3).unwrap().as_str().parse()?;
|
||||||
|
let beacon_y = caps.get(4).unwrap().as_str().parse()?;
|
||||||
|
let sensor = Pos::new(sensor_x, sensor_y);
|
||||||
|
let beacon = Pos::new(beacon_x, beacon_y);
|
||||||
|
let radius = sensor.taxicab(&beacon);
|
||||||
|
Ok((
|
||||||
|
Sensor {
|
||||||
|
pos: sensor,
|
||||||
|
radius,
|
||||||
|
},
|
||||||
|
beacon,
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn range_at(&self, y: i64) -> Option<Range> {
|
||||||
|
let distance = (self.pos.y() - y).abs();
|
||||||
|
if distance > self.radius {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
let extent = self.radius - distance;
|
||||||
|
Some(Range(self.pos.x() - extent, self.pos.x() + extent))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn border_distance(&self, other: &Sensor) -> i64 {
|
||||||
|
let distance = self.pos.taxicab(&other.pos);
|
||||||
|
distance - self.radius - other.radius
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn contains(&self, pos: &Pos<i64>) -> bool {
|
||||||
|
self.pos.taxicab(pos) <= self.radius
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod test {
|
||||||
|
use super::*;
|
||||||
|
use crate::common::file::read_lines;
|
||||||
|
use anyhow::Result;
|
||||||
|
#[test]
|
||||||
|
fn test_parse() -> Result<()> {
|
||||||
|
let input = "Sensor at x=2, y=18: closest beacon is at x=-2, y=15";
|
||||||
|
let expected = (
|
||||||
|
Sensor {
|
||||||
|
pos: Pos::new(2, 18),
|
||||||
|
radius: 7,
|
||||||
|
},
|
||||||
|
Pos::new(-2, 15),
|
||||||
|
);
|
||||||
|
let result = Sensor::parse(input)?;
|
||||||
|
assert_eq!(result, expected);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_width() {
|
||||||
|
let sensor = Sensor {
|
||||||
|
pos: Pos::new(8, 7),
|
||||||
|
radius: 9,
|
||||||
|
};
|
||||||
|
assert_eq!(sensor.range_at(17), None);
|
||||||
|
assert_eq!(sensor.range_at(7), Some(Range(-1, 17)));
|
||||||
|
assert_eq!(sensor.range_at(10), Some(Range(2, 14)));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_merge() {
|
||||||
|
let input = vec![Range(4, 10), Range(1, 3), Range(5, 9), Range(8, 12)];
|
||||||
|
let expected = vec![Range(1, 3), Range(4, 12)];
|
||||||
|
assert_eq!(Range::merge_all(&input), expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_part1() -> Result<()> {
|
||||||
|
let day = Day {};
|
||||||
|
let lines = read_lines(day.get_day_number(), "example01.txt")?;
|
||||||
|
let expected = ResultType::Integer(26);
|
||||||
|
let result = day.part1(&lines)?;
|
||||||
|
assert_eq!(result, expected);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_part2() -> Result<()> {
|
||||||
|
let day = Day {};
|
||||||
|
let lines = read_lines(day.get_day_number(), "example01.txt")?;
|
||||||
|
let expected = ResultType::Integer(56000011);
|
||||||
|
let result = day.part2(&lines)?;
|
||||||
|
assert_eq!(result, expected);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -4,6 +4,15 @@ mod day03;
|
||||||
mod day04;
|
mod day04;
|
||||||
mod day05;
|
mod day05;
|
||||||
mod day06;
|
mod day06;
|
||||||
|
mod day07;
|
||||||
|
mod day08;
|
||||||
|
mod day09;
|
||||||
|
mod day10;
|
||||||
|
mod day11;
|
||||||
|
mod day12;
|
||||||
|
mod day13;
|
||||||
|
mod day14;
|
||||||
|
mod day15;
|
||||||
mod template;
|
mod template;
|
||||||
|
|
||||||
pub use template::DayTrait;
|
pub use template::DayTrait;
|
||||||
|
|
@ -13,7 +22,7 @@ pub mod day_provider {
|
||||||
use super::*;
|
use super::*;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
const MAX_DAY: usize = 6;
|
const MAX_DAY: usize = 15;
|
||||||
|
|
||||||
pub fn get_day(day_num: usize) -> Result<Box<dyn DayTrait>, ProviderError> {
|
pub fn get_day(day_num: usize) -> Result<Box<dyn DayTrait>, ProviderError> {
|
||||||
match day_num {
|
match day_num {
|
||||||
|
|
@ -23,6 +32,15 @@ pub mod day_provider {
|
||||||
4 => Ok(Box::new(day04::Day)),
|
4 => Ok(Box::new(day04::Day)),
|
||||||
5 => Ok(Box::new(day05::Day)),
|
5 => Ok(Box::new(day05::Day)),
|
||||||
6 => Ok(Box::new(day06::Day)),
|
6 => Ok(Box::new(day06::Day)),
|
||||||
|
7 => Ok(Box::new(day07::Day)),
|
||||||
|
8 => Ok(Box::new(day08::Day)),
|
||||||
|
9 => Ok(Box::new(day09::Day)),
|
||||||
|
10 => Ok(Box::new(day10::Day)),
|
||||||
|
11 => Ok(Box::new(day11::Day)),
|
||||||
|
12 => Ok(Box::new(day12::Day)),
|
||||||
|
13 => Ok(Box::new(day13::Day)),
|
||||||
|
14 => Ok(Box::new(day14::Day)),
|
||||||
|
15 => Ok(Box::new(day15::Day)),
|
||||||
_ => Err(ProviderError::InvalidNumber(day_num)),
|
_ => Err(ProviderError::InvalidNumber(day_num)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ fn output(day: usize, part: usize, result: ResultType, time: Duration) {
|
||||||
time.as_secs_f32()
|
time.as_secs_f32()
|
||||||
);
|
);
|
||||||
for line in &value[1..] {
|
for line in &value[1..] {
|
||||||
println!(" part : {line}");
|
println!(" {line}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ResultType::Nothing => {}
|
ResultType::Nothing => {}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue