~ihabunek/aoc2021

43a2188383ab6979828310d1254d32ff85900ebc — Ivan Habunek 2 years ago b989341 day22
Day 22 w/ bug
A resources/day22.example1.in => resources/day22.example1.in +4 -0
@@ 0,0 1,4 @@
on x=10..12,y=10..12,z=10..12
on x=11..13,y=11..13,z=11..13
off x=9..11,y=9..11,z=9..11
on x=10..10,y=10..10,z=10..10
\ No newline at end of file

A resources/day22.example2.in => resources/day22.example2.in +22 -0
@@ 0,0 1,22 @@
on x=-20..26,y=-36..17,z=-47..7
on x=-20..33,y=-21..23,z=-26..28
on x=-22..28,y=-29..23,z=-38..16
on x=-46..7,y=-6..46,z=-50..-1
on x=-49..1,y=-3..46,z=-24..28
on x=2..47,y=-22..22,z=-23..27
on x=-27..23,y=-28..26,z=-21..29
on x=-39..5,y=-6..47,z=-3..44
on x=-30..21,y=-8..43,z=-13..34
on x=-22..26,y=-27..20,z=-29..19
off x=-48..-32,y=26..41,z=-47..-37
on x=-12..35,y=6..50,z=-50..-2
off x=-48..-32,y=-32..-16,z=-15..-5
on x=-18..26,y=-33..15,z=-7..46
off x=-40..-22,y=-38..-28,z=23..41
on x=-16..35,y=-41..10,z=-47..6
off x=-32..-23,y=11..30,z=-14..3
on x=-49..-5,y=-3..45,z=-29..18
off x=18..30,y=-20..-8,z=-3..13
on x=-41..9,y=-7..43,z=-33..15
on x=-54112..-39298,y=-85059..-49293,z=-27449..7877
on x=967..23432,y=45373..81175,z=27513..53682
\ No newline at end of file

A resources/day22.in => resources/day22.in +420 -0
@@ 0,0 1,420 @@
on x=-29..23,y=-30..15,z=-3..49
on x=-15..38,y=-36..10,z=-43..7
on x=-35..17,y=-28..24,z=-43..2
on x=-39..5,y=1..45,z=-16..31
on x=-32..18,y=-41..6,z=2..46
on x=-11..40,y=-25..24,z=3..47
on x=-32..14,y=-27..17,z=-27..17
on x=-44..7,y=-13..36,z=-22..32
on x=-28..23,y=-37..17,z=-9..37
on x=-16..32,y=-33..11,z=-30..24
off x=8..22,y=7..17,z=-13..-2
on x=-18..36,y=-38..11,z=-10..37
off x=4..18,y=4..13,z=25..40
on x=-9..43,y=-42..8,z=-39..9
off x=-47..-36,y=9..21,z=-23..-12
on x=-16..28,y=-4..43,z=-2..44
off x=-5..14,y=-35..-23,z=1..11
on x=-42..8,y=-20..33,z=-6..38
off x=12..29,y=32..48,z=-16..-5
on x=-28..24,y=-38..6,z=-41..13
on x=-42598..-21332,y=57671..74335,z=-39141..-25199
on x=12842..18253,y=64991..95102,z=-1013..22011
on x=14292..35178,y=31846..56231,z=-69474..-32498
on x=48508..63424,y=40169..73083,z=-32461..-15478
on x=-53272..-39403,y=52253..74802,z=28484..44233
on x=-90886..-70618,y=11167..24324,z=-48298..-27186
on x=42864..69988,y=6494..14874,z=-61402..-48381
on x=32856..60908,y=-21220..2969,z=-82713..-51199
on x=-43236..-38687,y=-54974..-37533,z=43661..67516
on x=-73019..-54512,y=-40226..-19022,z=-47819..-18533
on x=-13374..-1755,y=35159..53318,z=54672..78571
on x=-72459..-49780,y=26623..39906,z=26734..50215
on x=36956..56777,y=49601..68568,z=11190..23931
on x=-8324..11418,y=-67208..-61172,z=30189..64858
on x=4923..22623,y=-57522..-28440,z=55907..86362
on x=-2277..15816,y=-19017..8562,z=71962..84058
on x=47682..78730,y=33432..54807,z=337..16255
on x=-64929..-27785,y=13758..36901,z=-64308..-58493
on x=-7211..15654,y=-82833..-66842,z=-24502..-2170
on x=59929..75054,y=-44675..-34097,z=23165..52720
on x=-73417..-61550,y=-53556..-38306,z=-25883..-4155
on x=8748..25265,y=73993..77417,z=-34445..771
on x=-14709..7230,y=-79004..-71019,z=28017..40892
on x=-80397..-72176,y=-3401..10828,z=31505..43394
on x=-18016..4193,y=-40013..-27336,z=-81455..-58863
on x=-31232..-15336,y=-20532..-17564,z=-82495..-69153
on x=25742..33213,y=46869..66164,z=-48859..-30510
on x=7390..36460,y=-40931..-17361,z=59597..86969
on x=11409..31804,y=-12424..5721,z=-76004..-57299
on x=29479..58120,y=32806..48292,z=43926..52327
on x=-14853..11617,y=-88695..-73267,z=12500..33934
on x=-82166..-59371,y=21068..51664,z=-15692..-9082
on x=-20999..-774,y=68606..93389,z=6118..22102
on x=54001..61244,y=43068..67093,z=-27102..-8664
on x=12628..27587,y=10127..44166,z=-86679..-68135
on x=18006..32413,y=4514..23542,z=-75716..-66524
on x=29306..45247,y=61649..77701,z=-41539..-23287
on x=17315..45470,y=-89034..-55798,z=7999..39105
on x=-14405..-7019,y=-90356..-67700,z=-2807..8810
on x=154..28376,y=-73243..-54031,z=-40410..-28481
on x=-34689..-1394,y=-24168..-11499,z=-74651..-60967
on x=9240..29751,y=39611..42228,z=56227..69266
on x=-31526..-7172,y=-86280..-56151,z=-44770..-20743
on x=5625..24547,y=57302..91433,z=15583..30327
on x=20703..48779,y=-72586..-67013,z=6679..21868
on x=20000..33974,y=23390..42408,z=-65104..-57239
on x=68776..85567,y=-51662..-16317,z=-3647..17523
on x=47026..80229,y=23764..39384,z=-40412..-33947
on x=62203..92353,y=25547..39281,z=-18029..-2580
on x=-38980..-8898,y=50592..62504,z=-53757..-49146
on x=-28219..-22356,y=19671..49819,z=54463..68834
on x=518..25370,y=34936..45165,z=-78491..-49138
on x=8424..23979,y=19495..47499,z=66713..82505
on x=-20637..-5528,y=54556..80890,z=30622..64798
on x=-6742..13867,y=41220..59369,z=-79548..-49878
on x=-15128..4689,y=28139..45103,z=-73047..-69004
on x=37018..61135,y=54878..74986,z=-30910..-21376
on x=-39789..-6449,y=-17149..1538,z=-92188..-75921
on x=9475..21893,y=-70741..-61713,z=30774..51889
on x=-13631..676,y=-81488..-66816,z=-25214..-13796
on x=-80249..-75138,y=-5349..11429,z=16995..36242
on x=-30514..-6269,y=-47818..-16702,z=-82519..-68990
on x=16783..41727,y=-80913..-72593,z=-18313..-11163
on x=71015..74983,y=-19187..544,z=-53014..-16616
on x=-78059..-50212,y=-34630..-14499,z=-33080..-4293
on x=-22855..16120,y=55974..84013,z=-52905..-35677
on x=-71401..-48954,y=28723..51324,z=-40859..-8754
on x=-38799..-14074,y=-26420..-11561,z=62449..71897
on x=-16836..4465,y=-79060..-65986,z=-37261..-8295
on x=-12273..8589,y=50129..81788,z=-61417..-40706
on x=58174..71556,y=31973..52333,z=-5377..26994
on x=-12996..13166,y=36173..63814,z=-75514..-49088
on x=-74909..-56934,y=15628..25602,z=16158..33831
on x=13588..39019,y=-14673..4457,z=63321..85769
on x=-31521..-109,y=-69589..-61824,z=-42821..-37529
on x=-68105..-32916,y=7885..28349,z=50559..80892
on x=-19626..6672,y=35580..68730,z=-62426..-48284
on x=37295..61514,y=59850..79048,z=-24398..-6065
on x=37362..51018,y=-64908..-44583,z=-8944..14098
on x=24714..37661,y=7904..17687,z=56631..86229
on x=-8129..21019,y=-72243..-57033,z=27781..55449
on x=-72599..-43887,y=43180..53479,z=14203..17374
on x=24432..38420,y=23306..33837,z=-71244..-59352
on x=-52392..-30501,y=-7598..9094,z=-76056..-58977
on x=26578..35513,y=22064..27406,z=60502..81068
on x=49084..66060,y=36947..74982,z=2648..23779
on x=-37675..-22629,y=-88211..-58713,z=10992..44192
on x=-20082..6332,y=-90839..-62924,z=-40208..-12610
on x=58819..78007,y=-8881..13951,z=6462..31052
on x=48929..70154,y=-39128..-24425,z=17469..43832
on x=62562..78164,y=-5485..20514,z=-38846..-27479
on x=33834..57381,y=37952..44957,z=-58938..-43355
on x=11532..35539,y=-6233..29190,z=-92820..-60137
on x=-8702..9366,y=-71945..-55135,z=-45238..-33732
on x=-62298..-47156,y=-46434..-27351,z=27377..50601
on x=66115..72332,y=-39287..-23799,z=-28158..-17614
on x=-28563..-5743,y=58050..80776,z=30413..54700
on x=15729..55121,y=65031..90861,z=-13870..12088
on x=48458..63564,y=-5773..1720,z=58337..72819
on x=-4214..13542,y=-26927..-949,z=-96300..-63334
on x=-77167..-54559,y=-1829..23345,z=-63479..-38779
on x=-50171..-23937,y=-85227..-57585,z=11139..35354
on x=53427..70272,y=-62647..-28874,z=-12974..4940
on x=-37882..-18803,y=737..25090,z=-70466..-61037
on x=-74558..-57729,y=18925..38221,z=25062..44432
on x=53490..76176,y=-50267..-37326,z=-39842..-17951
on x=-77464..-61148,y=21296..46249,z=8758..26261
on x=37788..44104,y=33289..56104,z=-58512..-33264
on x=71106..81930,y=11679..29037,z=-7264..14388
on x=69043..82331,y=14644..32539,z=13882..35992
on x=-65924..-30596,y=8636..35391,z=45782..61595
on x=7021..27738,y=-57337..-33648,z=-79241..-60107
on x=-83207..-69111,y=11959..25188,z=-27855..-12457
on x=46399..67247,y=31320..37405,z=-47704..-17044
on x=35231..45423,y=49195..84450,z=-32015..-6073
on x=-12197..18695,y=-46403..-12982,z=-87861..-53578
on x=35383..54774,y=-78362..-45162,z=-38609..-7500
on x=-4653..2303,y=68754..78362,z=-38630..-17996
on x=31023..46467,y=-52022..-28953,z=58620..66597
on x=-41381..-15642,y=-39619..-12319,z=51367..82244
on x=-41769..-33415,y=18183..31308,z=-65879..-48561
on x=-33215..-20187,y=58011..89854,z=8805..34442
on x=-41798..-15228,y=-87062..-66357,z=-3057..25498
on x=-92413..-72898,y=14994..39101,z=15619..31844
on x=16329..39903,y=-75428..-56096,z=-38620..-33883
on x=79080..83620,y=-3864..6515,z=-3049..20212
on x=-27270..10414,y=-17135..17086,z=65547..92149
on x=-74344..-45568,y=-8187..23667,z=47990..62904
on x=35616..64029,y=30080..47334,z=33222..59066
on x=-52390..-36901,y=18883..38111,z=45715..72458
on x=-10061..6679,y=23445..41514,z=-85392..-64299
on x=-61847..-40682,y=21132..25095,z=-75464..-57185
on x=57246..89466,y=21679..45282,z=-8358..452
on x=-47419..-31469,y=-10985..2796,z=72081..78765
on x=15371..32047,y=-6234..16299,z=-88554..-64063
on x=52578..87656,y=-52657..-27893,z=15093..27800
on x=-34621..-11390,y=-28502..-3309,z=65130..89026
on x=-53717..-33560,y=44788..58837,z=-40287..-19330
on x=-61627..-56938,y=-40406..-22148,z=-54113..-34016
on x=-87502..-55130,y=25684..53458,z=8057..35117
on x=48943..76495,y=34884..57491,z=12487..39055
on x=70551..87729,y=-40467..-10814,z=-34743..-19279
on x=6344..12999,y=-91011..-76248,z=1838..25023
on x=45139..66584,y=3560..25503,z=-52943..-32832
on x=-64384..-48753,y=-16135..3455,z=28853..61539
on x=-30399..-7678,y=26796..51898,z=54248..66438
on x=-79015..-49638,y=25572..60734,z=-15536..11410
on x=47039..79817,y=37705..47578,z=12556..38483
on x=-61633..-47220,y=-54862..-17065,z=42065..51388
on x=-41463..-8337,y=50615..75430,z=14994..42810
on x=71986..91348,y=-11503..15151,z=-26922..-14596
on x=-80195..-73575,y=-3804..12180,z=15582..35422
on x=-23796..3380,y=-68668..-51088,z=30165..68615
on x=59759..80646,y=-8011..11617,z=-39621..-18222
on x=-20614..-3254,y=-82238..-57008,z=10636..32393
on x=-15548..15113,y=-84744..-59171,z=15671..38142
on x=29654..49414,y=-64902..-42185,z=-71169..-34133
on x=-43838..-12460,y=35325..48378,z=-71170..-40821
on x=-15630..-4530,y=-27874..-10528,z=57854..76045
on x=74662..86891,y=-32082..-18178,z=-8178..15685
on x=-53306..-40329,y=62816..75586,z=21040..29776
on x=-83798..-61218,y=-23221..4995,z=-47176..-30129
on x=45422..69014,y=-9191..6819,z=44303..51332
on x=-38251..-19363,y=25620..51135,z=-63597..-57263
on x=-62395..-39886,y=-1399..17508,z=56965..68167
on x=4591..29524,y=-72227..-56480,z=26540..49703
on x=-53252..-34205,y=32899..45838,z=45145..68099
on x=-52921..-39160,y=-66428..-41298,z=-36368..-30003
on x=8316..33696,y=-11410..15237,z=74020..92162
on x=31038..35424,y=-40607..-19754,z=61054..75783
on x=-82083..-57641,y=-51496..-45668,z=-7146..14300
on x=-67847..-47411,y=21243..38940,z=-40171..-23675
on x=64420..77151,y=-27612..-4363,z=29104..43539
on x=13984..39657,y=-51129..-38586,z=58690..73680
on x=-24777..-15767,y=68581..89677,z=-3834..9482
on x=42538..63455,y=-12610..7033,z=48244..73996
on x=-43587..-14218,y=11548..22301,z=70721..76614
on x=-46743..-27475,y=6317..18146,z=55198..82732
on x=-5249..13930,y=-26267..-13542,z=73806..98126
on x=900..25350,y=-23187..-2554,z=76647..96140
on x=24194..45191,y=62774..87230,z=-37606..-14342
on x=62065..89759,y=16033..37418,z=-19793..-11412
on x=14695..26425,y=-62104..-46802,z=34567..53744
on x=-1686..26906,y=-10809..4657,z=78690..96980
on x=-15996..10448,y=-87400..-69885,z=-13457..7529
on x=43982..79584,y=27519..62806,z=-33118..-6755
on x=-27362..-5354,y=38834..72672,z=52950..61839
on x=-53994..-42137,y=-38807..-12340,z=58145..74653
on x=-42327..-23959,y=58027..87652,z=-125..8869
on x=47880..68361,y=24440..53734,z=18677..33429
on x=15811..26258,y=-10963..17618,z=71350..94305
on x=51662..69276,y=-51294..-14486,z=-53090..-33459
on x=28809..58054,y=-86093..-63292,z=-30779..-11212
on x=33842..58825,y=-21360..9866,z=65585..75277
on x=-41689..-37339,y=38459..53191,z=37126..63199
on x=45156..75894,y=-72882..-39142,z=5882..26977
on x=-36450..-31004,y=-78197..-57064,z=-22108..6516
on x=3..12037,y=37354..50039,z=58073..77746
on x=-5245..32153,y=-86763..-68422,z=-34002..-15840
on x=63443..68678,y=-61962..-39518,z=215..18368
on x=-50982..-24773,y=7023..24178,z=53588..84060
off x=-34412..-4521,y=-49332..-39640,z=-69637..-55805
off x=-17766..9929,y=-88294..-69135,z=3441..20570
on x=10017..39597,y=36369..57732,z=56535..70725
off x=2942..30140,y=23038..39773,z=60786..82928
off x=-66793..-49806,y=22474..52066,z=29617..37875
off x=16716..31481,y=-18904..7065,z=55943..78614
on x=-16675..5934,y=71861..84104,z=9981..33161
off x=-67557..-43713,y=25640..54041,z=31196..63706
off x=-15517..955,y=-92947..-76263,z=4303..9835
on x=-12053..14535,y=-8343..17134,z=76073..80929
on x=57461..87633,y=-42922..-27923,z=-24925..-18191
off x=21081..39100,y=57018..76751,z=-44695..-20149
off x=-64773..-54773,y=-66604..-36106,z=3192..25020
off x=-19271..8739,y=35202..66586,z=-76681..-48119
off x=-43470..-16154,y=59612..82040,z=-34688..-21787
on x=-23827..-6688,y=-32104..-9229,z=72625..89627
on x=-86299..-64157,y=-10114..22448,z=-57639..-39086
off x=-86811..-53261,y=2262..17892,z=-54567..-20796
on x=-50016..-31551,y=42360..58499,z=28526..64445
off x=60057..90274,y=-25448..-16290,z=-44960..-17547
off x=25611..29118,y=-80878..-58940,z=-24273..1331
off x=-61662..-43627,y=48400..63832,z=-16151..8688
on x=-13475..12984,y=-35274..-27790,z=58985..77186
on x=-43520..-10722,y=-1196..16063,z=-85796..-56058
off x=-5093..-1887,y=61160..83910,z=9937..12093
off x=19803..36621,y=-58122..-45810,z=-59923..-46560
off x=26364..48134,y=-54840..-41302,z=-45438..-32451
on x=-82927..-48971,y=-15658..-2181,z=-57955..-34475
off x=30315..57001,y=-60387..-38230,z=43319..61412
on x=39927..59376,y=59739..82232,z=-4388..21982
off x=56525..81138,y=-45787..-37492,z=-6455..19928
on x=-11394..9131,y=55316..90259,z=-38676..-14782
off x=49813..58479,y=-18741..-244,z=37826..74101
on x=6398..28126,y=39428..53823,z=40266..76312
on x=122..24738,y=-11590..12612,z=70392..91716
on x=-3790..17655,y=68249..91113,z=-13593..4920
off x=-49079..-36540,y=46179..77303,z=28015..43014
on x=-73718..-58862,y=-53011..-48192,z=-22924..11218
on x=16882..42374,y=-59119..-23485,z=59248..69475
on x=20107..46872,y=16988..31223,z=-83423..-60133
on x=-71772..-49909,y=26188..48153,z=24847..30981
off x=-30758..-13648,y=-54973..-45813,z=49744..64738
on x=9603..15459,y=10414..20739,z=67613..97687
off x=-19329..3027,y=-78082..-75515,z=-23744..-22172
off x=-3843..23898,y=-87251..-72451,z=1978..14514
off x=-12621..6056,y=63842..79086,z=34094..51625
off x=48718..77003,y=-36351..-6031,z=46276..61619
on x=-9893..5635,y=-86055..-63465,z=38438..51996
off x=64545..92938,y=3477..10243,z=-2713..35901
off x=-35396..-11839,y=-32137..-20786,z=-73457..-69715
on x=-8391..15701,y=-74468..-55515,z=-43587..-21409
off x=-27768..-11452,y=4989..44301,z=-82883..-65754
off x=22346..29256,y=-39389..-25430,z=57286..79560
off x=-50526..-28718,y=-37580..-25074,z=55399..69143
on x=-73313..-61823,y=32932..38659,z=-8267..12759
off x=30832..54093,y=-75157..-55669,z=-50883..-33183
off x=-26944..-10571,y=14470..25106,z=-81593..-74822
on x=-80603..-57337,y=-52906..-36817,z=-29898..-9825
on x=16579..44907,y=26613..52104,z=54853..67238
on x=25866..56133,y=-53162..-25767,z=49435..73553
off x=-68706..-48403,y=-61686..-37022,z=10202..33146
off x=32252..34208,y=21368..41850,z=-67187..-52340
on x=-2193..14259,y=45884..64288,z=44403..71872
off x=-19708..-7259,y=-91440..-68158,z=6890..21315
off x=-43763..-17056,y=40046..58025,z=47381..81361
on x=42537..57633,y=-70559..-53724,z=2627..20376
on x=-37747..-34491,y=55988..73487,z=14566..43910
on x=-89428..-64595,y=-27975..-17635,z=-8181..24597
on x=-73449..-41201,y=-11284..1691,z=-70789..-40399
on x=-78794..-48290,y=-28117..-1409,z=-49566..-23402
off x=-48603..-27149,y=-80118..-54681,z=-30695..-13597
on x=-824..26373,y=60155..89523,z=-55252..-29227
on x=-62197..-56835,y=-42624..-27526,z=33194..43696
on x=-35021..-21735,y=-32788..-12939,z=69619..76324
on x=-70632..-60899,y=31119..49847,z=-18924..7733
on x=-5308..11004,y=-64166..-37623,z=52669..71328
on x=28927..63875,y=54019..70308,z=22239..27616
on x=26894..44874,y=-80941..-69371,z=11229..15209
on x=46015..64903,y=30390..49672,z=4879..39338
off x=43311..62099,y=-27426..2815,z=64426..75819
off x=-31435..5268,y=-82996..-62110,z=32320..48849
off x=-61987..-39125,y=-75018..-55667,z=22758..44208
on x=25491..39445,y=50090..80146,z=8416..33605
on x=43932..69526,y=9419..33389,z=-56350..-50334
on x=-66779..-61803,y=33513..55045,z=-22051..-11500
off x=-23632..-17492,y=17040..23889,z=58957..80737
off x=-22501..2947,y=-58965..-51646,z=-67341..-46834
off x=37337..52342,y=-49981..-27626,z=-62244..-47310
on x=-56370..-21965,y=-27629..-6549,z=-73163..-50503
on x=-81359..-57111,y=-22780..886,z=-59294..-42398
off x=24388..43560,y=51240..71281,z=-36247..-35708
on x=-50996..-14444,y=45434..65191,z=40298..67556
on x=9828..29542,y=57759..89866,z=-229..26295
off x=-26658..-6306,y=-58617..-37499,z=60903..68390
on x=60017..76792,y=28810..60321,z=-39954..-10546
off x=45829..65292,y=47508..67219,z=-12496..7510
on x=-52240..-47221,y=53167..80504,z=-22488..487
on x=37047..59772,y=-23622..402,z=48496..83129
off x=-28532..-17597,y=63659..77466,z=8742..29992
on x=-20438..-5412,y=48742..65209,z=56298..64561
off x=-91805..-63544,y=-20224..-7105,z=-10583..13003
on x=4920..33457,y=61365..81465,z=13691..31772
off x=-18078..10153,y=-36283..-20807,z=-87889..-59000
on x=57212..79272,y=-8615..5463,z=-65399..-48431
off x=-72360..-55783,y=9755..37817,z=37349..58680
on x=-48856..-22520,y=45653..56480,z=48682..65031
on x=58860..82620,y=-57233..-32389,z=-12730..1442
off x=44252..65564,y=-61674..-42665,z=-12047..13866
off x=-64123..-47149,y=-16329..7761,z=-58612..-37520
on x=-63027..-43603,y=25678..62342,z=-58485..-34807
off x=-60183..-53127,y=-74569..-43502,z=16329..28616
on x=-56557..-38931,y=-42153..-18262,z=37872..58035
off x=-16186..9608,y=45535..73473,z=45529..49099
off x=-75243..-49730,y=-10478..298,z=-72548..-45716
on x=-29657..152,y=-45031..-39814,z=-67378..-47342
on x=15395..41950,y=-58508..-39803,z=54548..77836
on x=-1867..24908,y=-93364..-69360,z=23942..39716
off x=65283..86697,y=9393..16736,z=38674..42140
off x=-29251..-4179,y=59692..91308,z=11979..31405
off x=21567..38255,y=28611..31383,z=53421..74525
off x=-94938..-74105,y=-16556..19105,z=-29901..-7221
off x=39201..61564,y=-71995..-51601,z=14567..28012
off x=-39102..-13898,y=-68240..-46839,z=55105..69075
on x=3544..31340,y=-40004..-6242,z=-90900..-66610
on x=34867..60839,y=-72706..-44860,z=-33714..-6591
off x=-70151..-36113,y=-29927..-9504,z=-78515..-53678
off x=62502..88493,y=-23466..12196,z=-12767..1129
off x=-86365..-72906,y=-10947..15192,z=19620..31939
off x=38584..43539,y=-64492..-56186,z=-36934..-17399
on x=-64576..-48144,y=16853..22345,z=-67549..-47301
on x=3993..24061,y=-21829..-4139,z=63543..92484
off x=-27272..-22761,y=63998..68434,z=35008..53587
off x=-69091..-60481,y=32390..41609,z=-34104..-16235
on x=4210..22353,y=-43244..-7268,z=73658..77529
on x=-47646..-28329,y=29108..47560,z=-70582..-47688
off x=-11759..-1486,y=34646..49231,z=47279..66272
on x=-81702..-56211,y=-4276..13600,z=-39784..-11177
on x=-24886..-9862,y=32196..57998,z=45859..73283
off x=-63747..-31413,y=28263..39417,z=54249..61147
off x=68423..80888,y=10661..19925,z=25680..40307
off x=-67534..-29098,y=-67173..-51111,z=-27373..3539
on x=-164..10157,y=47682..57702,z=56057..66332
on x=-17939..-1857,y=-58516..-52401,z=49470..69520
off x=12758..39848,y=30659..52851,z=44815..75981
on x=24048..39953,y=26048..43186,z=46429..81870
off x=-75767..-53358,y=-9163..478,z=24220..51386
off x=-2172..8707,y=-78787..-60941,z=-20713..4633
on x=35313..59855,y=49443..59547,z=749..30434
on x=-43614..-19798,y=-151..17589,z=56231..89486
off x=3990..35574,y=-85096..-48786,z=-53481..-29353
off x=13206..33877,y=-87034..-53027,z=-45540..-20412
on x=-41236..-34123,y=-73648..-63231,z=-22202..-5192
off x=45527..60283,y=-73619..-43075,z=-20060..15652
on x=37033..48545,y=-52206..-38628,z=-68405..-45261
off x=-96312..-71421,y=-19454..-7636,z=-5992..26386
off x=-91830..-63949,y=-23924..225,z=26151..31508
off x=52305..80525,y=-31679..221,z=-50451..-34550
on x=-44098..-20184,y=-32946..-4660,z=68082..88278
on x=65295..92822,y=-14470..15433,z=-12641..13311
on x=22878..45977,y=36991..60962,z=-53948..-32419
on x=-32770..-22164,y=63936..72535,z=-44830..-7095
on x=-43727..-29433,y=-64364..-42940,z=-60679..-26890
on x=58815..82471,y=-20739..4326,z=-46814..-26029
on x=-3091..25799,y=73170..84920,z=-1320..29048
on x=-51821..-38372,y=33286..42157,z=46167..51799
off x=21810..40356,y=747..38933,z=-72473..-68637
off x=8493..21386,y=-58768..-37702,z=52806..73158
on x=-68421..-43786,y=-43066..-20163,z=43818..77074
on x=-73009..-60347,y=27497..57713,z=12693..28519
off x=-51096..-24943,y=-60365..-47719,z=-73167..-33904
on x=28409..42588,y=16778..39990,z=61930..76801
on x=51757..79079,y=-43118..-14163,z=-42963..-16219
on x=9408..33553,y=40598..59440,z=54878..78738
off x=-77562..-60225,y=-32859..-15094,z=-6841..19380
on x=9713..31155,y=-68359..-60231,z=-56227..-33381
off x=-19772..2102,y=-28901..-17458,z=-73937..-65423
off x=25622..33436,y=-83541..-56266,z=-47082..-20573
off x=-23851..-6335,y=-90481..-57236,z=17332..30872
on x=-80984..-49948,y=-28145..-17418,z=43404..47253
off x=28597..54612,y=62648..72342,z=-3953..4261
on x=-86016..-54464,y=-30599..-15736,z=-38961..-31111
on x=-4124..17282,y=74184..98136,z=-4348..12705
on x=-62867..-53998,y=28287..48650,z=-50744..-37242
off x=55769..82205,y=11875..18460,z=-57323..-28362
off x=17558..34533,y=-68875..-41433,z=34991..62182
off x=-67030..-35244,y=16185..29923,z=-69501..-39315
on x=7468..25005,y=74064..79470,z=-7919..20188
on x=-44380..-21718,y=-48828..-19849,z=-69435..-63699
off x=51202..78301,y=-68279..-41086,z=-14646..-7855
on x=37634..63347,y=-24203..-18581,z=46220..68675
off x=14891..39590,y=63529..90883,z=-27107..359
off x=-39078..-2699,y=36612..63620,z=49009..77815
off x=-80339..-60844,y=22909..43255,z=-27601..-12900
off x=-85078..-66348,y=15921..35556,z=-41102..-18552
off x=51685..64746,y=-60003..-40107,z=-32955..-3849
on x=-61806..-39349,y=4399..29880,z=-55712..-37178
on x=44297..63319,y=12992..24574,z=37764..65139
off x=20452..22744,y=-73174..-56753,z=-41696..-21933
on x=-50494..-27967,y=67270..81084,z=-18547..-1163
\ No newline at end of file

A src/aoc2021/day22.clj => src/aoc2021/day22.clj +88 -0
@@ 0,0 1,88 @@
; --- Day 22: Dirac Dice ---
; https://adventofcode.com/2021/day/22

(ns aoc2021.day22
  (:require [clojure.java.io :as io]
            [clojure.string :as str]
            [clojure.edn :as edn]
            [clojure.pprint :refer [pprint cl-format]]
            [aoc2021.utils :refer [transpose]]))

; (def input-file (-> "day22.in" io/resource io/file))
; (def input-file (-> "day22.example1.in" io/resource io/file))
(def input-file (-> "day22.example2.in" io/resource io/file))

(defn parse-line [line]
  (let [onoff (keyword (re-find #"^on|off" line))
        ranges (->> (re-seq #"[\d-]+" line)
                    (map edn/read-string)
                    (partition 2))]
    [onoff ranges]))

(defn get-input []
  (->> (slurp input-file)
       (str/split-lines)
       (map parse-line)))

; Determine which segments of line 1 are overlapped by line 2.
; Returns a list of segments tagged with `:in` for overlapped or `:out` for not.
(defn split-axes [[^long x1 ^long x2] [^long y1 ^long y2]]
  (if (or (> x1 x2) (> y1 y2)) (throw (Exception. "argh")))
  (cond
    (or (< y2 x1) (> y1 x2)) [[:out [x1 x2]]]                  ; fully outside
    (and (<= y1 x1) (>= y2 x2)) [[:in [x1 x2]]]                ; fully inside
    (and (< y1 x1) (<= x1 y2 x2)) [[:in [x1 y2]]               ; overlap left
                                   [:out [(inc y2) x2]]]
    (and (> y2 x2) (<= x1 y1 x2)) [[:out [x1 (dec y1)]]        ; overlap right
                                   [:in [y1 x2]]]
    (and (> y1 x1) (< y2 x2)) [[:out [x1 (dec y1)]]            ; overlap center
                               [:in [y1 y2]]
                               [:out [(inc y2) x2]]]))

; Returns a list of cubes representing volumes of cube-a not covered by cube-b
; TODO: this could be improved by merging contiguous volumes, but probably not
; necessary for this task
(defn remains-3d [cube-a cube-b]
  (let [[xsa ysa zsa] cube-a
        [xsb ysb zsb] cube-b]
    (for [xs (split-axes xsa xsb)
          ys (split-axes ysa ysb)
          zs (split-axes zsa zsb)
          :when (or (= (first xs) :out)
                    (= (first ys) :out)
                    (= (first zs) :out))]
      [(second xs) (second ys) (second zs)])))

(defn volume [[[^long x1 ^long x2] [^long y1 ^long y2] [^long z1 ^long z2]]]
  (* (inc (- x2 x1))
     (inc (- y2 y1))
     (inc (- z2 z1))))

(defn solve [commands]
  ; cubes holds volumes which are turned on
  (loop [commands commands cubes []]
    (println (count commands) (first commands) (reduce + (map volume cubes)))
    (if (empty? commands)
      (reduce + (map volume cubes))
      (let [[onoff cube] (first commands)
            next-cubes (mapcat #(remains-3d % cube) cubes)
            next-cubes (if (= onoff :on) (conj next-cubes cube) next-cubes)]
        (recur (rest commands) next-cubes)))))

(defn within? [[^long x1 ^long x2] [^long min ^long max]]
  (and (>= x1 min) (<= x2 max)))

(defn filter-within [commands vrange]
  (filter
    (fn [[onoff [xs ys zs]]]
      (and (within? xs vrange)
           (within? ys vrange)
           (within? zs vrange)))
    commands))

(defn part1 [commands]
  (solve (filter-within commands [-50 50])))

(defn main []
  (let [commands (get-input)]
    (println (str "Part 1: " (time (part1 commands))))))

A test/aoc2021/day22_test.clj => test/aoc2021/day22_test.clj +32 -0
@@ 0,0 1,32 @@
(ns aoc2021.day22-test
  (:require [clojure.test :refer :all]
            [aoc2021.day22 :refer [split-axes]]))

(deftest day01
  (testing "split-axes"
    ; fully outside
    (is (= (split-axes [0 5] [-5 -1]) [[:out [0 5]]]))
    (is (= (split-axes [0 5] [10 20]) [[:out [0 5]]]))

    ; fully inside
    (is (= (split-axes [0 5] [0 5]) [[:in [0 5]]]))
    (is (= (split-axes [0 5] [-1 6]) [[:in [0 5]]]))
    (is (= (split-axes [0 5] [-2 7]) [[:in [0 5]]]))

    ; overlap left
    (is (= (split-axes [0 5] [-5 0]) [[:in [0 0]] [:out [1 5]]]))
    (is (= (split-axes [0 5] [-5 1]) [[:in [0 1]] [:out [2 5]]]))
    (is (= (split-axes [0 5] [-5 2]) [[:in [0 2]] [:out [3 5]]]))
    (is (= (split-axes [0 5] [-5 3]) [[:in [0 3]] [:out [4 5]]]))
    (is (= (split-axes [0 5] [-5 4]) [[:in [0 4]] [:out [5 5]]]))

    ; overlap right
    (is (= (split-axes [0 5] [1 6]) [[:out [0 0]] [:in [1 5]]]))
    (is (= (split-axes [0 5] [2 6]) [[:out [0 1]] [:in [2 5]]]))
    (is (= (split-axes [0 5] [3 6]) [[:out [0 2]] [:in [3 5]]]))
    (is (= (split-axes [0 5] [4 6]) [[:out [0 3]] [:in [4 5]]]))
    (is (= (split-axes [0 5] [5 6]) [[:out [0 4]] [:in [5 5]]]))

    ; overlap center
    (is (= (split-axes [0 5] [1 4]) [[:out [0 0]] [:in [1 4]] [:out [5 5]]]))
    (is (= (split-axes [0 5] [2 3]) [[:out [0 1]] [:in [2 3]] [:out [4 5]]]))))