diff --git a/advent-of-code-2021.csproj b/advent-of-code-2021.csproj
index 5706de0..27831fd 100644
--- a/advent-of-code-2021.csproj
+++ b/advent-of-code-2021.csproj
@@ -81,6 +81,9 @@
PreserveNewest
+
+ PreserveNewest
+
diff --git a/inputs/22.txt b/inputs/22.txt
new file mode 100644
index 0000000..b856ab6
--- /dev/null
+++ b/inputs/22.txt
@@ -0,0 +1,420 @@
+on x=-25..22,y=-37..17,z=-38..8
+on x=-1..45,y=-43..11,z=-22..28
+on x=-20..26,y=-29..24,z=-16..29
+on x=-49..4,y=-9..40,z=-3..47
+on x=-36..10,y=-30..18,z=-14..30
+on x=-45..2,y=-32..16,z=-33..18
+on x=-7..39,y=-7..47,z=-31..17
+on x=-13..35,y=-41..13,z=-8..39
+on x=-20..27,y=-11..42,z=-2..48
+on x=-16..32,y=-9..42,z=-18..30
+off x=-11..5,y=-35..-25,z=15..30
+on x=-27..17,y=-9..39,z=-45..2
+off x=-40..-25,y=21..35,z=-24..-10
+on x=-12..38,y=-30..19,z=-38..11
+off x=8..19,y=25..37,z=6..23
+on x=-17..34,y=-10..43,z=-45..4
+off x=-44..-31,y=-22..-5,z=-22..-13
+on x=-8..43,y=-6..41,z=-25..25
+off x=-17..0,y=28..47,z=19..34
+on x=-45..0,y=-44..6,z=-33..15
+on x=-7874..5506,y=-20379..-3039,z=59810..88971
+on x=-21433..-6261,y=-46900..-34324,z=50271..88746
+on x=38450..68609,y=-7656..11913,z=-72939..-50513
+on x=10810..32231,y=62915..80230,z=27306..45793
+on x=16240..33178,y=-69605..-65010,z=23182..41140
+on x=74585..88021,y=-33713..-11811,z=8878..14352
+on x=8952..26425,y=-5524..18862,z=-92382..-59599
+on x=-5011..17567,y=-62318..-50559,z=47882..72780
+on x=74303..97592,y=-15251..3184,z=-10887..11253
+on x=-71741..-56752,y=-14773..-2871,z=44590..48159
+on x=7145..26216,y=-73908..-47204,z=45148..72408
+on x=3353..11909,y=70884..90962,z=-42418..-30798
+on x=-86705..-60907,y=-13957..4192,z=-47576..-27852
+on x=45879..55901,y=-64766..-35760,z=-50770..-23619
+on x=43802..76492,y=43658..54364,z=-29093..-11590
+on x=10370..26860,y=45297..57854,z=38221..70721
+on x=-63998..-46603,y=-20267..-6000,z=-59847..-56863
+on x=-18630..18378,y=40771..60137,z=62275..69541
+on x=55671..80730,y=-27426..-12642,z=-60454..-41374
+on x=-34693..-14417,y=-79191..-69262,z=-26703..3282
+on x=-38261..-30043,y=-31904..-3317,z=60552..74101
+on x=-63295..-41017,y=-66142..-47664,z=17578..31398
+on x=-13577..1488,y=54526..61735,z=-65440..-38952
+on x=48354..70605,y=14703..31697,z=-65071..-40580
+on x=62691..92710,y=3173..42903,z=-27555..-15004
+on x=-34060..-14740,y=-80185..-57343,z=17703..26938
+on x=-88335..-73992,y=7675..23682,z=-29991..-17731
+on x=-64720..-47504,y=45814..72187,z=-26042..-1648
+on x=57030..64993,y=35410..49151,z=-13732..9894
+on x=-77291..-65322,y=-25591..-24178,z=26942..36225
+on x=-11274..13032,y=-60620..-45108,z=-82331..-52549
+on x=-88590..-60753,y=-7850..4911,z=23234..57969
+on x=26408..43629,y=49378..89017,z=5396..16841
+on x=69300..87125,y=-47624..-20717,z=-6957..27242
+on x=43326..53338,y=41342..68666,z=-29928..-8141
+on x=-69964..-57576,y=-44817..-7703,z=24558..49911
+on x=-5529..3405,y=-70486..-57793,z=38667..71794
+on x=72365..86627,y=-25567..-16003,z=-13583..-4327
+on x=9348..39319,y=-73553..-55808,z=-30116..-18951
+on x=20947..43924,y=68210..91134,z=-10996..26549
+on x=-80994..-60522,y=-17003..2655,z=-6840..18812
+on x=7928..33299,y=54071..62569,z=29146..61880
+on x=-73188..-48824,y=33993..63516,z=-25454..-8089
+on x=-82484..-65282,y=-9918..10639,z=20102..31437
+on x=53747..68021,y=-49346..-36316,z=-21310..-15842
+on x=-5298..6291,y=-56004..-49801,z=-59794..-43568
+on x=37703..55636,y=-48346..-37782,z=27178..43960
+on x=28973..48768,y=30630..54886,z=-48787..-38801
+on x=40085..42058,y=58803..86868,z=-7156..-3537
+on x=-5244..14514,y=-17017..4800,z=71648..82401
+on x=66637..87713,y=-28138..-11871,z=22841..29706
+on x=-73391..-56078,y=-42567..-24073,z=-34558..-8746
+on x=-46758..-10848,y=-37005..-29780,z=-83643..-48720
+on x=32265..48746,y=44256..70123,z=40711..65344
+on x=7095..34285,y=47014..76227,z=-58356..-43652
+on x=30778..34567,y=-75173..-60339,z=-50645..-26616
+on x=-95002..-66778,y=-6534..21540,z=9811..31414
+on x=-78525..-56832,y=-52209..-37537,z=-27987..-18272
+on x=34941..61589,y=-66061..-52884,z=16427..26746
+on x=26607..44757,y=56550..76152,z=9943..15669
+on x=65247..79688,y=-1198..18004,z=-38529..-28860
+on x=-39043..-33901,y=-41363..-15844,z=57226..73240
+on x=517..18030,y=72575..94894,z=-32607..-9450
+on x=-48138..-33957,y=-8725..23156,z=-74829..-64476
+on x=14674..40415,y=-10310..8599,z=55548..76889
+on x=5411..28795,y=39926..72819,z=43387..60574
+on x=-11735..1244,y=-81181..-73820,z=-28100..-4131
+on x=-94982..-74210,y=6396..18510,z=-2618..15316
+on x=-14012..-6314,y=-84572..-63156,z=31111..52228
+on x=-118..20059,y=34462..58751,z=-80546..-56745
+on x=-42424..-16763,y=-61392..-46124,z=40506..70305
+on x=-68200..-52902,y=-53715..-33370,z=500..10204
+on x=-78742..-74311,y=-749..26775,z=-17380..-1983
+on x=-45225..-18627,y=-10476..6301,z=71396..78161
+on x=-41962..-13258,y=5655..31861,z=48787..82853
+on x=-4287..23298,y=-39395..-12857,z=-89437..-61466
+on x=70684..81806,y=1617..22727,z=-9322..17632
+on x=60320..64982,y=-11794..2549,z=35758..64707
+on x=-50895..-17858,y=-34644..-9840,z=-85306..-64871
+on x=12118..28830,y=-73335..-43482,z=29166..45459
+on x=11184..43399,y=-84603..-53931,z=13762..37604
+on x=42155..53212,y=38257..63651,z=-39259..-31414
+on x=-80486..-58420,y=-37408..-30208,z=-27620..-6908
+on x=-12226..5972,y=-82320..-53208,z=30951..48037
+on x=-72814..-45894,y=-51715..-34510,z=-29165..-7498
+on x=4315..28593,y=-50405..-29388,z=-72958..-48216
+on x=7546..29936,y=-32734..-29248,z=-88518..-50920
+on x=26049..50278,y=-65601..-42011,z=-55923..-45671
+on x=-14665..5917,y=63952..90182,z=5320..26209
+on x=-64305..-32115,y=-67815..-54683,z=15642..41774
+on x=40402..72364,y=-48615..-32584,z=11970..43341
+on x=-36423..-21574,y=27425..31751,z=-86149..-56524
+on x=38326..62079,y=45689..52640,z=38903..56896
+on x=-18427..3353,y=6007..19691,z=-85062..-73139
+on x=-4191..20389,y=-47833..-14927,z=65632..75890
+on x=57372..78099,y=-2471..13074,z=50..19993
+on x=-30736..-13109,y=-67034..-52066,z=27271..58053
+on x=-71822..-41486,y=-69702..-55488,z=15902..29808
+on x=-31535..-20720,y=75586..92489,z=-26956..-1456
+on x=-80124..-61667,y=-47297..-19803,z=-2412..28939
+on x=-24308..1478,y=-79483..-76964,z=-34232..-15794
+on x=56194..75420,y=21437..47033,z=25529..49225
+on x=4079..40058,y=-24280..5057,z=65772..77187
+on x=-62180..-45533,y=-51608..-32908,z=30378..45483
+on x=-13480..28,y=-75291..-63119,z=16709..51335
+on x=58818..66910,y=-62369..-43633,z=8382..17832
+on x=-43387..-27774,y=28522..39561,z=45765..73429
+on x=-64923..-30680,y=-62106..-53157,z=28636..45166
+on x=54328..67007,y=-74271..-36618,z=-12995..3637
+on x=-77163..-45508,y=26641..51588,z=7513..28872
+on x=-87028..-61596,y=-23424..-6875,z=29267..57373
+on x=-32999..-2171,y=-51771..-28704,z=-80305..-51440
+on x=-1213..13360,y=62211..71724,z=-52865..-26389
+on x=-59595..-40976,y=608..38385,z=-67678..-39972
+on x=-51375..-40493,y=52834..78732,z=-32478..-20512
+on x=-59461..-51678,y=-57205..-51776,z=-18552..6908
+on x=-67103..-58469,y=2666..27721,z=-59857..-31316
+on x=-31553..-20945,y=-56604..-41792,z=46058..64858
+on x=-82863..-52103,y=1792..32261,z=13005..32987
+on x=-53436..-31839,y=31585..55069,z=50592..61674
+on x=41525..49552,y=-25674..-19103,z=52676..72349
+on x=65926..70611,y=-37803..-18555,z=20771..41361
+on x=64024..83956,y=-37756..-22888,z=21054..36415
+on x=41255..70996,y=-60030..-36048,z=12729..25474
+on x=40757..43045,y=34970..56717,z=-44253..-30030
+on x=-58784..-42274,y=-73761..-50142,z=11208..29144
+on x=-34430..-8005,y=57336..71214,z=18509..46142
+on x=224..27032,y=-40856..-23310,z=-73458..-63394
+on x=-94313..-58262,y=-36381..-23880,z=-12765..10563
+on x=-3922..21855,y=22784..35285,z=56549..82919
+on x=-25358..1966,y=-82528..-76828,z=-13146..-10953
+on x=34104..47312,y=44304..79133,z=-48368..-24337
+on x=39991..75751,y=-46352..-19595,z=44418..52968
+on x=-39306..-16416,y=-26164..-186,z=61105..74914
+on x=55569..75595,y=24301..43891,z=-47519..-35261
+on x=26093..41420,y=57621..71127,z=-51351..-25437
+on x=35996..57167,y=-64743..-46879,z=-1650..7206
+on x=-28855..-11320,y=76234..80807,z=2935..13504
+on x=-67054..-36441,y=-63873..-43786,z=-28254..8947
+on x=-14509..3328,y=-73695..-39712,z=-55836..-51258
+on x=68827..93867,y=3505..11168,z=18139..41193
+on x=-62902..-53742,y=-62316..-29660,z=20939..50463
+on x=-49675..-30208,y=45417..70955,z=-37743..-14049
+on x=46586..53764,y=-33379..-5171,z=-72062..-39028
+on x=-20911..-1427,y=49674..65860,z=-63296..-37531
+on x=-54985..-36111,y=37281..62377,z=30172..45519
+on x=-4397..18030,y=-84894..-61794,z=10830..21585
+on x=11750..38443,y=-82567..-66253,z=13438..29233
+on x=59514..67757,y=-51804..-35103,z=7019..24467
+on x=27432..50977,y=-42003..-30595,z=-63979..-42141
+on x=-15819..-5759,y=-61346..-42796,z=-54195..-34015
+on x=-76984..-52460,y=28797..64073,z=-7149..25332
+on x=-52158..-26040,y=11304..26896,z=-80266..-51382
+on x=-9558..1461,y=72523..94866,z=-43893..-23592
+on x=-66298..-44000,y=25979..47853,z=-53578..-42707
+on x=6988..18659,y=51164..69431,z=33837..57752
+on x=-38858..-13161,y=-56417..-38120,z=-69115..-48732
+on x=40312..77361,y=42382..59137,z=20671..36281
+on x=-37374..-16194,y=-6138..22213,z=57535..93920
+on x=4822..17630,y=-78489..-55730,z=31282..65954
+on x=-51269..-21808,y=51723..72289,z=31278..65239
+on x=67584..92800,y=-7980..-46,z=-37946..-5803
+on x=-11191..7756,y=50336..65372,z=60030..68673
+on x=-35391..-26531,y=6204..17520,z=61001..78026
+on x=-28728..1160,y=-84803..-59728,z=-54020..-32667
+on x=59337..65724,y=33773..45079,z=21264..50548
+on x=-64482..-40710,y=47616..59937,z=8139..31218
+on x=-16863..13681,y=-30676..-9757,z=-92073..-59935
+on x=-24997..-9374,y=17287..40966,z=-84648..-60166
+on x=-25337..-3767,y=-74787..-62296,z=-35829..-10718
+on x=63697..85710,y=953..32652,z=20768..32117
+on x=-44147..-19389,y=-60163..-35869,z=-83248..-50697
+on x=-57894..-53539,y=48553..53550,z=26409..38273
+on x=48679..55245,y=15109..50451,z=35152..65388
+on x=25604..62419,y=-20961..7848,z=-79350..-64190
+on x=-22084..-10836,y=12754..33323,z=-83535..-61512
+on x=21009..43671,y=-32733..-5575,z=65432..73204
+on x=-7178..29385,y=-48608..-17272,z=-80620..-69880
+on x=25772..50009,y=65383..86566,z=-32131..-5636
+on x=634..12760,y=52120..69063,z=48427..64000
+on x=-5534..7408,y=57575..74937,z=-38916..-22273
+on x=-32741..-17540,y=-40077..-31838,z=-76144..-56680
+on x=40310..65131,y=-47993..-25612,z=40235..71257
+on x=44408..77248,y=13423..34189,z=-53040..-34392
+on x=70803..96452,y=9302..24010,z=-11413..9911
+on x=15449..37539,y=48012..67955,z=46095..64173
+on x=7151..40444,y=-25065..6244,z=-91166..-75247
+on x=-90737..-75720,y=-5475..16668,z=4153..29576
+on x=-33261..-13080,y=55167..75616,z=24910..40299
+on x=-65599..-40401,y=-18178..-728,z=-78145..-51418
+on x=-58978..-34779,y=-59342..-42300,z=-191..21488
+on x=18497..38363,y=-21451..-14602,z=-92202..-55994
+on x=-73368..-42678,y=45965..58851,z=-35584..-25807
+on x=68712..81585,y=-27605..-8858,z=20493..44638
+on x=-49956..-15982,y=-34609..-16081,z=52125..71155
+on x=-72367..-47140,y=32980..52447,z=22136..36531
+on x=-41906..-21763,y=-60745..-33327,z=-74200..-40503
+on x=74281..82455,y=-24387..-3961,z=-20290..15753
+on x=-6850..14006,y=29406..50293,z=-79525..-70587
+on x=-19273..13527,y=32325..50356,z=-76866..-55145
+on x=-58958..-39262,y=-12206..10909,z=59320..69684
+off x=52775..62708,y=-22725..-18131,z=-64772..-51042
+off x=-7316..18889,y=-9236..18079,z=75734..84988
+off x=-68904..-56803,y=7963..21320,z=28299..44607
+off x=56738..81745,y=-33655..-19734,z=27734..54876
+off x=-26307..-4399,y=-90257..-66498,z=-8368..6190
+on x=-63424..-48935,y=51182..61255,z=-35303..-9366
+off x=-59497..-39391,y=-48595..-21538,z=-65637..-43222
+off x=10314..35649,y=5352..24478,z=66042..95448
+on x=66990..86515,y=-26082..-17705,z=-18769..-11276
+off x=37208..65114,y=-31814..-16425,z=50870..76166
+off x=-6163..11246,y=-77431..-59123,z=-61149..-39103
+off x=-65580..-57918,y=-42189..-20880,z=-49370..-41832
+off x=-68181..-47291,y=-43131..-24122,z=-52032..-39969
+on x=-28183..-20075,y=55733..67672,z=-45712..-26158
+off x=-20854..-3684,y=10595..33536,z=62130..75618
+on x=-1550..8093,y=64709..84232,z=-13210..4539
+on x=-14584..8934,y=-89926..-70898,z=10403..26190
+off x=-23968..-2269,y=55599..70257,z=46101..49355
+on x=63447..78212,y=-1665..5767,z=-49492..-33869
+on x=-76609..-63970,y=11730..33874,z=-31397..-933
+off x=-81830..-56014,y=-53112..-33489,z=1528..28062
+off x=-8280..-4015,y=47133..68418,z=-64354..-42733
+off x=48414..73285,y=-28088..-1338,z=48697..64341
+off x=38375..56868,y=-75954..-47951,z=-13590..9529
+on x=43124..69757,y=45938..57740,z=-28736..-4974
+on x=-9344..-3482,y=55482..85763,z=-39420..-38492
+on x=-43081..-29483,y=9548..30431,z=61108..88470
+on x=-37982..-17628,y=48715..75366,z=36941..48193
+off x=-8331..2546,y=-78987..-61305,z=-30626..-2011
+off x=-81700..-62256,y=-10742..6586,z=722..26440
+off x=-24912..-11729,y=-25032..-3413,z=-88232..-75563
+on x=58167..74001,y=15467..21830,z=-37657..-16140
+on x=9988..37527,y=-48291..-30477,z=54921..80713
+on x=62474..73375,y=-17054..1407,z=35366..53946
+off x=-83614..-64521,y=29149..33522,z=-38377..-14053
+off x=-53987..-32165,y=11117..19957,z=-75785..-68730
+on x=42103..70775,y=-73724..-54732,z=-5872..7872
+on x=20494..44429,y=11307..21039,z=-76857..-61050
+on x=-20646..11084,y=62264..88883,z=26886..41113
+off x=-88900..-69393,y=1605..20025,z=-36353..-23657
+off x=-5057..19004,y=63779..92275,z=-19254..13570
+on x=-57000..-34567,y=-71407..-61402,z=-25281..-23453
+on x=-3652..25227,y=-26409..-7375,z=-78623..-67258
+off x=53792..79784,y=-46089..-39765,z=8293..18162
+off x=-76199..-59669,y=-45245..-28456,z=-13993..15531
+off x=12995..45491,y=56914..91086,z=-30682..-5699
+off x=15637..32089,y=-59007..-37524,z=-75718..-52527
+off x=-73386..-49956,y=-39740..-16542,z=-69266..-46619
+off x=-19602..6141,y=-6868..8551,z=67012..92514
+on x=21642..48389,y=-64658..-42774,z=34948..63725
+on x=-20429..-2111,y=9416..26675,z=71825..81116
+off x=-2501..21349,y=49578..64417,z=51184..71703
+off x=46241..68960,y=-27030..3257,z=-60862..-44951
+on x=-27054..-11006,y=59976..79200,z=5931..18842
+on x=-24276..-2701,y=-66183..-52326,z=-49472..-34192
+off x=-68877..-53836,y=-28126..-15302,z=-46581..-34719
+off x=-73359..-34792,y=13665..36009,z=-56369..-46033
+on x=32103..49141,y=-79415..-57451,z=-40343..-18996
+on x=73069..82323,y=-9569..9367,z=-14857..7647
+off x=-56161..-38162,y=29352..48859,z=43169..72145
+on x=-66774..-55959,y=-65235..-30961,z=13584..33678
+off x=27548..45916,y=-26792..283,z=-75012..-66571
+on x=-80711..-66751,y=-29628..-15357,z=-41564..-15914
+off x=71552..81414,y=-7863..9193,z=-14213..10187
+on x=36611..56676,y=45719..53058,z=-57614..-36899
+off x=62768..88220,y=-49020..-30531,z=138..22494
+on x=15720..31386,y=-31469..-20942,z=-79951..-69439
+off x=20888..41231,y=-64104..-39191,z=-58681..-44918
+on x=64912..75468,y=22232..45193,z=-29893..2078
+on x=361..31325,y=63314..77907,z=-54330..-28730
+on x=-19404..15732,y=73142..90411,z=25581..35682
+on x=61748..71694,y=19771..38115,z=13843..22810
+on x=-6187..8381,y=-42494..-25695,z=-86533..-60639
+on x=63798..82990,y=-40381..-13733,z=4229..28270
+on x=-81663..-57842,y=-666..22557,z=-68350..-41120
+off x=-47003..-20315,y=-62845..-55753,z=-52267..-35229
+on x=-94464..-67322,y=-40490..-19348,z=-5254..10478
+off x=43705..67726,y=-24299..-700,z=-75234..-57148
+off x=-41646..-12552,y=-68007..-46831,z=-43270..-39325
+on x=8135..18536,y=43749..52328,z=52189..74451
+off x=12530..45202,y=42121..58623,z=-64757..-34726
+on x=-38525..-6498,y=-85547..-69786,z=-3153..19751
+off x=28152..47986,y=57588..66161,z=25607..39999
+on x=-81199..-63920,y=-10524..3660,z=-1797..9134
+on x=-25334..-13304,y=58421..89837,z=-32681..-21215
+on x=-73427..-47035,y=26359..48721,z=-8616..13879
+on x=-35010..-13996,y=11972..23992,z=-91842..-56559
+off x=61555..72930,y=15378..28117,z=-45130..-33545
+on x=-76375..-71158,y=25706..30056,z=-5494..385
+off x=-32602..-6222,y=-79216..-72287,z=-9505..12380
+off x=-88346..-67085,y=-14944..7502,z=-27154..-10379
+off x=-31807..-5298,y=65364..79818,z=29230..47308
+on x=-57443..-23960,y=59901..70861,z=12729..28027
+off x=13199..37843,y=67820..79799,z=-5787..6066
+on x=-54982..-33556,y=56857..84194,z=-5511..17250
+on x=22920..41679,y=4390..24163,z=58350..76766
+on x=-59743..-28439,y=-84006..-54986,z=-7949..14308
+on x=61639..80928,y=16361..30223,z=2020..26391
+off x=-10984..10732,y=-89468..-59751,z=9884..41102
+off x=-79212..-64694,y=14128..32527,z=28460..47157
+off x=64235..86210,y=-42383..-17290,z=-28514..-12861
+off x=-1388..7043,y=61942..90427,z=-20381..-12457
+off x=63544..80468,y=-37417..-9915,z=36144..49273
+off x=-35734..-19033,y=53057..72367,z=-60953..-41489
+on x=35159..48100,y=-76380..-55607,z=-2127..3715
+on x=-75962..-58571,y=-54185..-42931,z=-7049..26522
+off x=40155..77172,y=-42052..-32487,z=37159..57286
+off x=28393..39783,y=-358..22551,z=-75711..-64727
+off x=-49182..-19539,y=-19313..11789,z=51776..88876
+off x=6323..22117,y=-66212..-50296,z=34106..55484
+off x=26923..57572,y=-84808..-57461,z=8216..22262
+off x=-55268..-27345,y=-34331..-26689,z=-66095..-50926
+off x=-16773..7149,y=40517..69874,z=57767..64060
+on x=-7644..5711,y=57323..80843,z=-46902..-23267
+on x=12990..46040,y=-85031..-65525,z=-14638..2525
+on x=36838..61816,y=43624..45798,z=-56805..-30128
+off x=-16625..-13438,y=15198..26225,z=56760..89970
+off x=-47586..-8125,y=38595..61503,z=-79954..-54733
+on x=68425..94332,y=-23770..-10888,z=-15853..-1516
+off x=45879..72720,y=10249..22803,z=31170..65673
+off x=-66838..-47717,y=22029..54053,z=17894..34996
+on x=-27131..-15091,y=-72018..-41671,z=-69529..-45135
+off x=49858..81214,y=-40371..-32977,z=12446..29253
+on x=-49045..-40498,y=35803..50496,z=-54698..-45453
+on x=37056..66261,y=-37677..-19546,z=49803..65703
+off x=-28190..-3348,y=-73123..-58301,z=30508..41418
+off x=-78271..-57241,y=-18397..11460,z=-41270..-21406
+off x=48500..57434,y=-15736..22263,z=55834..67267
+on x=-94862..-73351,y=-7423..9149,z=-27569..1987
+on x=43486..56652,y=39047..56815,z=17045..40948
+off x=-2337..16612,y=42633..69610,z=45684..73188
+on x=21127..49270,y=-30808..-25029,z=-81791..-62703
+on x=-30891..-21855,y=-28949..184,z=69030..89093
+on x=44543..50914,y=20954..34529,z=-70573..-46226
+on x=5780..19766,y=50550..70469,z=-48331..-34703
+off x=56501..93443,y=-4621..18563,z=11287..38665
+on x=42327..58505,y=-70210..-42337,z=-35047..-1223
+off x=18423..36939,y=-8454..6658,z=-91865..-58242
+off x=58609..79717,y=34512..43834,z=19543..51200
+on x=30744..40798,y=43451..74091,z=21225..50983
+off x=-16052..-514,y=-28879..585,z=67792..93741
+off x=-5109..4752,y=56092..80738,z=-56908..-27027
+on x=-91998..-65044,y=-497..38054,z=-22159..-5072
+off x=67089..80512,y=11116..39389,z=24842..41259
+off x=17874..33524,y=47720..80311,z=-53378..-23314
+on x=11894..29924,y=-80907..-60120,z=22583..34522
+off x=26908..30896,y=-78232..-56487,z=3888..26400
+on x=43517..74781,y=32409..38655,z=38475..57762
+on x=-33512..-10912,y=39239..68119,z=50194..76546
+on x=-31556..-23733,y=55040..76570,z=34651..56813
+on x=59734..87601,y=-46068..-27321,z=13508..43534
+off x=-28179..-2124,y=25183..50241,z=58671..87869
+on x=-69791..-45293,y=-74163..-44289,z=-17713..4452
+on x=-17404..695,y=45309..60367,z=-58557..-48788
+on x=-21736..-18077,y=68659..70975,z=21432..48567
+on x=23875..54273,y=-75359..-45864,z=-54931..-27989
+on x=-35409..-24375,y=-82394..-43946,z=31058..42523
+on x=-8343..13717,y=31327..58902,z=55577..83325
+off x=-48926..-32870,y=42263..59054,z=41809..53373
+off x=48808..87204,y=-57303..-27371,z=-32342..-7317
+on x=-67008..-39098,y=-51403..-26899,z=-54475..-39811
+on x=6581..35901,y=-85829..-56275,z=-41133..-19639
+off x=-88954..-64372,y=20411..33836,z=3213..34345
+on x=-7765..15787,y=59696..72865,z=46260..65892
+on x=-41030..-16419,y=72963..77043,z=793..25599
+on x=-34743..-14557,y=-71490..-52461,z=16977..35464
+on x=52820..76139,y=-16895..8754,z=-67504..-46523
+on x=26561..43699,y=35122..47583,z=-69853..-60751
+off x=53935..80807,y=-50668..-40940,z=-9088..11134
+on x=-9256..18245,y=-82833..-74237,z=-8555..9806
+off x=-54561..-36968,y=-16270..15979,z=49514..84021
+off x=-71537..-60947,y=-34759..-10335,z=16287..34069
+on x=62156..92714,y=71..22995,z=-2786..24138
+off x=-93224..-70481,y=-17263..-11214,z=-8572..14568
+off x=27687..38549,y=66418..78828,z=-26765..-1993
+off x=6373..44479,y=-20716..411,z=56296..85091
+off x=-10240..9238,y=76954..86558,z=-20574..-9567
+on x=59824..81660,y=42481..53777,z=12226..39439
+on x=10464..38714,y=-66090..-35600,z=-63269..-48994
+off x=10086..26680,y=-67885..-33884,z=-73115..-35932
+on x=46274..62715,y=-21783..14328,z=-66177..-46199
+on x=-45939..-26665,y=606..21920,z=47479..84070
+off x=67911..87660,y=-19150..18476,z=-7232..16762
+off x=-62714..-52605,y=-63367..-33979,z=-48407..-23827
+on x=55656..77456,y=-1928..20756,z=-59425..-29123
+on x=22311..52656,y=56599..78053,z=-8060..16138
+on x=-90012..-72349,y=-25411..-2567,z=-18968..1095
+off x=-75165..-59317,y=-35674..-8599,z=-42017..-25631
+on x=74039..92478,y=-4796..7717,z=-23856..-14498
+on x=37389..46931,y=50038..78098,z=-9817..5995
+off x=29297..54007,y=54429..66539,z=3163..26930
+on x=16320..36328,y=54585..75579,z=-30097..-3297
+on x=6120..22699,y=63678..70653,z=38784..45811
+on x=23070..32721,y=-41792..-30954,z=-66040..-45827
+off x=20355..29767,y=66334..89377,z=-28998..4344
+off x=5478..21486,y=-25991..5188,z=62514..90823
+off x=59573..72444,y=39402..64676,z=-17460..-4643
+on x=13708..27225,y=-57113..-21835,z=57734..67702
+on x=-67885..-35556,y=28851..63688,z=-56125..-21746
\ No newline at end of file
diff --git a/src/22.cs b/src/22.cs
new file mode 100644
index 0000000..e923fe6
--- /dev/null
+++ b/src/22.cs
@@ -0,0 +1,178 @@
+using System.Diagnostics;
+
+namespace aoc2021;
+
+internal class Day22 : Day
+{
+ [DebuggerDisplay("{(on ? \"On\" : \"Off\")}, {min} -> {max} ({NumInRange(min, max)})")]
+ private class Instruction
+ {
+ public bool On;
+ public (int x, int y, int z) Min;
+ public (int x, int y, int z) Max;
+
+ public Instruction(bool inOn, (int x, int y, int z) inMin, (int x, int y, int z) inMax)
+ {
+ On = inOn;
+ Min = inMin;
+ Max = inMax;
+ }
+
+ public Instruction(Instruction other)
+ : this(other.On, other.Min, other.Max)
+ {
+ }
+ }
+
+ internal override void Go()
+ {
+ var lines = Util.ReadAllLines("inputs/22.txt");
+ var instructions = new List();
+ foreach (var line in lines)
+ {
+ var instruction = line.Split(' ');
+ var coords = instruction[1].Split(',');
+ var min = (x: 0, y: 0, z: 0);
+ var max = (x: 0, y: 0, z: 0);
+ foreach (var coord in coords)
+ {
+ var pieces = coord.Split('=');
+ var range = pieces[1].Split("..");
+
+ if (pieces[0] == "x")
+ {
+ min.x = int.Parse(range[0]);
+ max.x = int.Parse(range[1]);
+ }
+ else if (pieces[0] == "y")
+ {
+ min.y = int.Parse(range[0]);
+ max.y = int.Parse(range[1]);
+ }
+ else if (pieces[0] == "z")
+ {
+ min.z = int.Parse(range[0]);
+ max.z = int.Parse(range[1]);
+ }
+ else
+ {
+ throw new Exception();
+ }
+ }
+
+ instructions.Add(new Instruction(instruction[0] == "on", min, max));
+ }
+
+ Part1(instructions);
+ Part2(instructions);
+ }
+
+ private static void Part1(IEnumerable instructions)
+ {
+ using var t = new Timer();
+
+ // keeping my original brute-force approach for posterity even though part 2 implements a much faster way to handle this
+ Dictionary<(int x, int y, int z), bool> states = new();
+ foreach (var inst in instructions)
+ {
+ if (inst.Min.x > 50 || inst.Min.y > 50 || inst.Min.z > 50 || inst.Max.x < -50 || inst.Max.y < -50 || inst.Max.z < -50)
+ {
+ continue;
+ }
+
+ for (int x = inst.Min.x; x <= inst.Max.x; x++)
+ {
+ if (x < -50 || x > 50)
+ {
+ continue;
+ }
+
+ for (int y = inst.Min.y; y <= inst.Max.y; y++)
+ {
+ if (y < -50 || y > 50)
+ {
+ continue;
+ }
+
+ for (int z = inst.Min.z; z <= inst.Max.z; z++)
+ {
+ if (z < -50 || z > 50)
+ {
+ continue;
+ }
+
+ states[(x, y, z)] = inst.On;
+ }
+ }
+ }
+ }
+
+ var count = states.LongCount(x => x.Value);
+
+ t.Stop();
+ Logger.Log($"<+black>> part1: <+white>{count}");
+ }
+
+ private static void Part2(IEnumerable instructions)
+ {
+ using var t = new Timer();
+
+ List modded = new();
+ long lightsOn = 0;
+ foreach (var inst in instructions)
+ {
+ foreach (var mod in modded.ToList())
+ {
+ var overlap = GetOverlapRange(mod, inst);
+ if (overlap != null)
+ {
+ modded.Add(new Instruction(!mod.On, overlap.min, overlap.max));
+ var overlapNum = NumInRange(overlap.min, overlap.max);
+ lightsOn += mod.On ? -overlapNum : overlapNum;
+ }
+ }
+
+ if (inst.On)
+ {
+ modded.Add(inst);
+ lightsOn += NumInRange(inst);
+ }
+ }
+
+ t.Stop();
+ Logger.Log($"<+black>> part2: <+white>{lightsOn}");
+ }
+
+ private static long NumInRange((int x, int y, int z) min, (int x, int y, int z) max)
+ {
+ long numX = max.x - min.x + 1;
+ long numY = max.y - min.y + 1;
+ long numZ = max.z - min.z + 1;
+ return numX * numY * numZ;
+ }
+
+ private static long NumInRange(Instruction inst) => NumInRange(inst.Min, inst.Max);
+
+ private static OverlapRange? GetOverlapRange(Instruction inst1, Instruction inst2)
+ {
+ if (inst1.Min.x > inst2.Max.x || inst1.Min.y > inst2.Max.y || inst1.Min.z > inst2.Max.z)
+ {
+ return null;
+ }
+ if (inst2.Min.x > inst1.Max.x || inst2.Min.y > inst1.Max.y || inst2.Min.z > inst1.Max.z)
+ {
+ return null;
+ }
+
+ var overlapMin = (x: Math.Max(inst1.Min.x, inst2.Min.x), y: Math.Max(inst1.Min.y, inst2.Min.y), z: Math.Max(inst1.Min.z, inst2.Min.z));
+ var overlapMax = (x: Math.Min(inst1.Max.x, inst2.Max.x), y: Math.Min(inst1.Max.y, inst2.Max.y), z: Math.Min(inst1.Max.z, inst2.Max.z));
+ return new OverlapRange() { min = overlapMin, max = overlapMax };
+ }
+
+ [DebuggerDisplay("{min} -> {max}")]
+ private class OverlapRange
+ {
+ public (int x, int y, int z) min;
+ public (int x, int y, int z) max;
+ }
+}
diff --git a/src/main.cs b/src/main.cs
index 472cb60..33534e7 100644
--- a/src/main.cs
+++ b/src/main.cs
@@ -20,7 +20,7 @@ else
Day? day = null;
if (string.IsNullOrEmpty(arg))
{
- day = new Day21();
+ day = new Day22();
}
else
{