This commit is contained in:
zv0n 2022-12-03 20:21:21 +01:00
parent 571d2a9530
commit 22df76485a
3 changed files with 643 additions and 0 deletions

22
22/CMakeLists.txt Normal file
View File

@ -0,0 +1,22 @@
cmake_minimum_required(VERSION 3.10)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
enable_language(CXX)
project(AoC22)
if(APPLE)
include_directories(/usr/local/include)
link_directories(/usr/local/lib)
endif()
if(WIN32)
add_executable(${CMAKE_PROJECT_NAME} WIN32)
else()
add_executable(${CMAKE_PROJECT_NAME})
endif()
target_sources(${CMAKE_PROJECT_NAME}
PRIVATE main.cpp
)

420
22/input Normal file
View File

@ -0,0 +1,420 @@
on x=-3..43,y=-28..22,z=-6..38
on x=-12..41,y=-24..24,z=3..47
on x=-49..-4,y=-40..10,z=-5..44
on x=-31..19,y=-43..9,z=-24..27
on x=-30..22,y=-2..45,z=-40..9
on x=-35..16,y=-26..26,z=2..49
on x=-25..19,y=-43..9,z=-22..26
on x=-10..37,y=-32..19,z=-10..38
on x=-32..20,y=-9..43,z=-25..23
on x=-40..8,y=-48..-4,z=-14..38
off x=-40..-28,y=-8..1,z=-13..-3
on x=-8..43,y=-7..40,z=-1..44
off x=21..30,y=16..31,z=7..25
on x=-20..30,y=-45..4,z=-2..49
off x=-35..-26,y=-5..13,z=-9..3
on x=-40..9,y=-3..45,z=-13..38
off x=12..27,y=-47..-34,z=6..23
on x=-45..1,y=-41..6,z=-35..17
off x=13..29,y=-27..-12,z=13..31
on x=-6..48,y=-35..19,z=-44..3
on x=-16355..1561,y=60846..74613,z=25256..33728
on x=-26216..-17771,y=-87617..-57053,z=-5881..1043
on x=32231..47872,y=29811..64788,z=-56510..-47171
on x=28537..56537,y=20198..42041,z=57549..65845
on x=3953..21327,y=-78498..-57875,z=33392..50055
on x=-75306..-55874,y=-30746..-15392,z=6600..31621
on x=15058..28113,y=-67676..-53572,z=-63028..-29880
on x=-3644..10751,y=-61417..-44235,z=-56253..-43364
on x=33861..42671,y=19431..44131,z=-70081..-61667
on x=54475..82304,y=-32769..-20718,z=-36187..-19334
on x=55622..68239,y=26998..48609,z=21325..28010
on x=-92278..-56655,y=-9273..6608,z=-36285..-21302
on x=-2978..14790,y=57668..78864,z=23497..34835
on x=-5580..5650,y=12218..30635,z=68934..90364
on x=54741..69135,y=39458..47402,z=16672..37719
on x=43657..70330,y=-34453..-5338,z=-74550..-51059
on x=-79233..-49668,y=-48013..-31254,z=-35137..-27533
on x=29923..65243,y=4486..16031,z=62649..77071
on x=37522..44870,y=57761..75320,z=16283..28324
on x=8655..27156,y=-63197..-44196,z=-71418..-35987
on x=-47137..-40221,y=1595..10993,z=-84186..-55451
on x=-10888..22847,y=60358..78426,z=29965..40817
on x=-2989..9709,y=-604..24187,z=-87674..-73864
on x=-99378..-68678,y=-12086..-753,z=-8589..17698
on x=-75521..-61764,y=7184..20831,z=-41136..-15379
on x=-2381..25090,y=-22826..-17101,z=-85445..-67683
on x=23259..27867,y=60174..84099,z=37473..56107
on x=-10858..24672,y=-61477..-41760,z=-78989..-59782
on x=-70500..-43163,y=-37147..-25580,z=-61805..-29705
on x=31808..59377,y=-54061..-39851,z=-48033..-32092
on x=-43610..-36882,y=60138..75400,z=-7726..12314
on x=-47251..-34042,y=-70611..-50675,z=-3688..30313
on x=-55784..-40079,y=26228..34915,z=40777..63010
on x=-77008..-57873,y=19751..47525,z=10953..21499
on x=48661..74909,y=31021..57485,z=-32118..-11809
on x=3958..22834,y=-32185..-17853,z=-84652..-69175
on x=-10810..11078,y=62407..98101,z=-10907..12355
on x=-42877..-36125,y=-24985..2413,z=53481..84653
on x=-18921..5581,y=-75495..-65497,z=15724..37998
on x=48508..70896,y=9542..36535,z=15371..35071
on x=38022..53958,y=-1299..14948,z=-65986..-44215
on x=38009..59826,y=24809..48345,z=-57752..-36039
on x=-35829..-12217,y=25553..40226,z=51769..77095
on x=39737..58241,y=48149..77916,z=16049..37417
on x=59784..92054,y=-25575..-7210,z=-905..23192
on x=33226..65301,y=54839..64554,z=-12027..5959
on x=41527..72276,y=-41798..-7536,z=27803..53411
on x=-3775..25537,y=-27915..-9931,z=76920..95827
on x=-81888..-66684,y=-20140..13473,z=25327..36706
on x=-57585..-45510,y=296..36312,z=43426..59557
on x=-53347..-34505,y=-74247..-43525,z=-42294..-21882
on x=8077..26904,y=65177..82189,z=-22679..-3274
on x=-13437..15926,y=-62141..-41675,z=47282..75412
on x=62397..77722,y=-36998..-12696,z=-42704..-13422
on x=18722..42143,y=10215..42715,z=-89847..-53174
on x=-74215..-55976,y=27273..46869,z=-50099..-27350
on x=20764..39831,y=46879..79581,z=-30857..-24490
on x=-71437..-42167,y=-32934..-11202,z=-64793..-50682
on x=39982..77174,y=29807..59142,z=-43390..-19034
on x=-71603..-47572,y=42621..55874,z=17881..42776
on x=-3563..8663,y=-70540..-55616,z=-46992..-25193
on x=-79433..-68369,y=11898..28828,z=-39907..-14456
on x=41775..62521,y=-64800..-43052,z=26040..38791
on x=47206..74352,y=44453..62506,z=-34589..-14229
on x=-63260..-50762,y=-31430..-9983,z=-53407..-26574
on x=57919..82487,y=-37815..-22496,z=92..21971
on x=-61036..-31621,y=55572..61899,z=-45471..-13315
on x=46850..60879,y=-30213..5119,z=50863..74705
on x=-35334..2112,y=-91800..-69098,z=22704..38369
on x=-17649..3199,y=-91658..-76225,z=-4580..14200
on x=31340..49782,y=-71722..-55524,z=1199..21055
on x=-78176..-59060,y=13796..40509,z=14542..25984
on x=-51014..-26951,y=-47961..-12455,z=59495..83887
on x=20605..38996,y=3228..28709,z=53255..84943
on x=-22711..292,y=60641..78333,z=40248..49164
on x=25277..55062,y=51185..74141,z=-31580..-11238
on x=26324..45940,y=-68954..-49005,z=11220..37099
on x=45613..52028,y=-41263..-20577,z=41099..69884
on x=11668..28231,y=63864..85264,z=18493..41144
on x=72191..74666,y=11186..35494,z=571..29336
on x=47821..68753,y=33037..53577,z=-20152..-2278
on x=40965..69982,y=-64913..-44422,z=-51444..-39456
on x=-64852..-60095,y=-40252..-30627,z=-51291..-18289
on x=7084..16947,y=-57714..-27037,z=-78428..-64130
on x=56841..76244,y=-48651..-34361,z=-1622..24156
on x=23641..35939,y=-77181..-50254,z=7381..34983
on x=35362..51881,y=-65944..-47424,z=-50999..-28380
on x=-11104..10487,y=-38582..-16053,z=-94142..-62827
on x=-49258..-16501,y=20837..43769,z=53638..73685
on x=-22013..9019,y=-81997..-58849,z=39664..46703
on x=44279..76511,y=-11143..5574,z=-61842..-50516
on x=-7473..7587,y=-59051..-27261,z=54773..83688
on x=-41811..-17686,y=-23210..-11526,z=-78947..-71989
on x=35615..55425,y=61877..74116,z=-34746..-113
on x=9530..37555,y=-3974..14280,z=-83262..-76068
on x=-1968..16327,y=-51342..-27172,z=-65624..-59215
on x=-56565..-29779,y=50529..82789,z=-19997..14014
on x=-46373..-23143,y=53422..70100,z=-43964..-16379
on x=-70339..-53536,y=52049..63933,z=-36168..-14660
on x=25962..51110,y=32495..43304,z=55808..64617
on x=57028..73928,y=35218..48327,z=-40621..-30140
on x=-77843..-47976,y=-40970..-22392,z=30057..52191
on x=-86971..-60663,y=830..6113,z=-318..8011
on x=-35107..-13424,y=-18643..12379,z=-90835..-68788
on x=-45390..-33558,y=-51710..-18996,z=-74612..-54884
on x=-48545..-21677,y=-13871..5913,z=53485..84543
on x=-82533..-68318,y=1221..26171,z=5052..32215
on x=37851..62055,y=40704..66785,z=20697..47304
on x=21005..36952,y=-39882..-18672,z=58485..67319
on x=-39374..-22913,y=65015..67960,z=-39865..-10101
on x=-27119..-8350,y=51835..83822,z=24755..56472
on x=53982..63534,y=30877..52779,z=23818..34423
on x=16208..29112,y=14566..39236,z=52845..82556
on x=-10448..3811,y=77387..89838,z=-19192..11964
on x=-97527..-69974,y=8839..21321,z=8655..29710
on x=29188..45452,y=-46834..-23187,z=52951..74811
on x=51507..75831,y=-65466..-48364,z=-14842..1894
on x=37631..47122,y=-56511..-19686,z=49812..60276
on x=-91483..-69394,y=-24767..-1176,z=-2004..33760
on x=-74363..-55778,y=-58770..-38519,z=10678..30883
on x=-36853..-20896,y=-52139..-35724,z=45760..62114
on x=-40765..-34235,y=47240..78138,z=20502..38857
on x=43193..62371,y=53123..69300,z=6737..25730
on x=22503..33647,y=-85777..-66518,z=18828..26456
on x=2965..12487,y=-53175..-26466,z=-80591..-47784
on x=25557..33995,y=-20210..17737,z=58585..83195
on x=-4009..5471,y=-88211..-57122,z=-29615..-9597
on x=-34132..-8440,y=60482..72959,z=-37631..-19321
on x=33876..56010,y=-48864..-23050,z=-72518..-45192
on x=-47456..-25336,y=-43287..-9605,z=64545..74322
on x=57831..89945,y=22181..34969,z=-10758..13120
on x=-53057..-32862,y=-75466..-43818,z=-23167..-14754
on x=-61302..-48884,y=-54590..-36624,z=-38900..-7931
on x=35508..60896,y=-21165..-11638,z=53949..80149
on x=46999..74104,y=-9963..6532,z=38169..62204
on x=-9712..8683,y=57816..73350,z=29350..53026
on x=-33561..-1246,y=-75310..-62982,z=34807..47704
on x=24995..40327,y=-4029..32417,z=-74133..-64628
on x=-11089..11778,y=58149..90865,z=12147..31752
on x=-37051..-14827,y=-86255..-60524,z=-37573..-29541
on x=-74436..-47077,y=-64864..-38006,z=-8439..13075
on x=36545..55154,y=-4067..6774,z=-69550..-52360
on x=22987..44904,y=-79059..-52903,z=-2253..14553
on x=19374..34850,y=20360..35534,z=-87900..-58537
on x=-77278..-55527,y=-2213..15783,z=-52130..-30797
on x=64430..88262,y=95..17922,z=23961..42611
on x=10988..33612,y=-68677..-58741,z=-59693..-25091
on x=-4976..13976,y=30513..55500,z=-72026..-65075
on x=-34307..-22692,y=66476..81300,z=10454..33065
on x=-17867..17214,y=42951..61303,z=-77056..-44354
on x=29583..47371,y=-27455..8246,z=-83266..-68238
on x=28144..46095,y=48072..81600,z=-31587..-16302
on x=60984..85115,y=-30079..-10235,z=-6442..19677
on x=-8356..19249,y=54890..69296,z=-54067..-38499
on x=35216..45088,y=-6166..13828,z=-75011..-58675
on x=56888..77719,y=13678..48441,z=-42689..-12830
on x=43449..67618,y=-57065..-42362,z=26863..48728
on x=-47671..-23008,y=1635..17317,z=54816..71559
on x=-15757..-12710,y=-30959..-7097,z=58694..90920
on x=-85779..-56056,y=-44224..-36576,z=-4464..6050
on x=43844..70439,y=21518..32682,z=44868..66726
on x=9033..25880,y=-66585..-39975,z=42743..68369
on x=-43604..-11814,y=-54640..-44119,z=-62642..-48380
on x=-19115..3792,y=-87271..-52028,z=35331..59130
on x=-52597..-36332,y=-61376..-33456,z=-73517..-46088
on x=-64763..-42333,y=16239..30189,z=-58015..-51596
on x=-41592..-14592,y=-76385..-59958,z=3873..21798
on x=17554..26110,y=23752..40059,z=67615..73953
on x=-18458..-4447,y=27330..40463,z=-84536..-53941
on x=51553..81578,y=-25334..-11169,z=19709..41529
on x=-53202..-36032,y=947..20282,z=55775..70288
on x=-75180..-64649,y=13543..37705,z=13409..38360
on x=32512..62413,y=-3786..7457,z=-67328..-57663
on x=-54434..-51791,y=371..22714,z=51258..78819
on x=-34684..-6906,y=-75321..-54573,z=-35443..-9761
on x=27399..53431,y=-24751..-5529,z=47786..66346
on x=34970..58163,y=29589..46376,z=28077..46685
on x=33879..56655,y=-4467..16432,z=43203..77545
on x=65846..83058,y=-45063..-40601,z=-11072..12281
on x=-59109..-24383,y=-66140..-36466,z=-51861..-34906
on x=-62672..-34501,y=-46334..-33555,z=43792..55744
on x=13293..34568,y=60132..88775,z=13411..33631
on x=-26288..2061,y=11133..41034,z=-84634..-71691
on x=-73106..-53588,y=33750..57905,z=-44832..-24379
on x=-95759..-67791,y=-2794..11740,z=-20969..1177
on x=57072..62525,y=-27635..-16639,z=-59103..-47713
on x=-20796..-2350,y=77249..79781,z=-26324..-5051
on x=-49446..-30550,y=-19890..-6130,z=-82903..-64807
on x=-87006..-52938,y=-471..18943,z=-55793..-23140
on x=-35262..-24977,y=59076..68682,z=-47626..-14810
on x=49030..73109,y=25663..42558,z=38568..47649
on x=-39721..-27899,y=-71393..-46240,z=27794..52762
on x=16382..29681,y=34472..56209,z=-62625..-38217
on x=18906..50337,y=-4746..8948,z=58511..86759
on x=46578..70898,y=-68045..-49544,z=-32171..-5630
on x=-28238..-14943,y=11234..35637,z=-72259..-53030
on x=-10592..9924,y=-58541..-45329,z=-69022..-52510
on x=1825..21476,y=22576..53471,z=67963..76280
on x=50139..69672,y=-20102..18231,z=24717..59378
on x=59486..81857,y=23553..53887,z=-923..16760
on x=-17695..1858,y=-78132..-69407,z=18964..40543
on x=44275..61439,y=-31683..-14035,z=-59511..-39256
on x=-49204..-24364,y=2300..31698,z=62590..80931
off x=52172..72269,y=-37574..-13384,z=34273..66227
off x=-6599..8629,y=-9330..-2883,z=-81728..-70092
off x=7136..27452,y=-26174..4565,z=55848..88810
on x=-20605..-4150,y=58684..66939,z=-45951..-25922
on x=-8901..11184,y=-17333..11327,z=75096..94030
on x=-25086..-643,y=-25026..-923,z=64436..78583
on x=-70359..-42794,y=-64621..-31058,z=36005..46641
off x=-70912..-52414,y=50530..73096,z=-22322..1276
on x=2773..27325,y=57919..65309,z=-51834..-27250
on x=18470..47177,y=-15706..-4377,z=63727..89795
off x=25519..50667,y=3995..23185,z=55898..65102
off x=-91113..-62214,y=18872..31762,z=-24577..-8458
off x=8300..37896,y=40757..65186,z=45682..53244
off x=-28922..-7397,y=-27239..-7499,z=71293..92342
off x=-93966..-59615,y=-27811..-16571,z=-26520..-16943
on x=53245..67683,y=-33197..-12311,z=33298..54296
on x=-51408..-26120,y=-78697..-66202,z=-12961..10826
on x=-44990..-25480,y=1565..18784,z=68957..83131
off x=-36425..-20123,y=-28015..8834,z=75182..91432
off x=71052..79617,y=-23657..-4852,z=24524..35945
off x=-46844..-31898,y=32250..64043,z=35722..46546
off x=-43120..-35875,y=60446..68097,z=-34566..-12985
on x=20774..48002,y=-53022..-23340,z=50543..59328
off x=28298..41181,y=-12174..15918,z=66292..88646
on x=-81590..-48878,y=-56188..-34184,z=-32135..-7222
on x=31616..55311,y=-34226..-24878,z=42784..69589
off x=4383..39542,y=-29639..-14475,z=63253..89072
on x=-45292..-27610,y=-51748..-25605,z=-62263..-50621
on x=-24313..-15228,y=64913..82924,z=-9772..16695
on x=69030..90086,y=-5196..14866,z=-13008..24035
off x=-39263..-17462,y=57742..93914,z=-22789..-7766
on x=-94740..-70932,y=-20694..7426,z=-6876..11065
off x=-57438..-37797,y=31056..55393,z=38033..67968
on x=12680..45166,y=-22835..4615,z=57624..88421
on x=32736..51019,y=29613..33641,z=46601..70686
off x=-73277..-54549,y=-58198..-24495,z=-25286..-7522
on x=44123..69463,y=26653..57330,z=25966..48345
off x=-41420..-21398,y=64628..76655,z=-22365..-17544
off x=34802..47339,y=-11846..24955,z=55458..80571
on x=42083..69240,y=-14194..12374,z=-70417..-33828
on x=-13326..11623,y=-85897..-53758,z=-55918..-39257
off x=37569..54597,y=43259..67542,z=-4748..33082
off x=-80223..-71004,y=-17644..-4011,z=-15191..11423
on x=-17167..5129,y=-85769..-73660,z=-11700..10915
on x=-15229..-4374,y=-94715..-64331,z=-28024..-17140
on x=12632..30069,y=65841..76200,z=-50067..-32873
off x=-11071..21532,y=40335..64592,z=-76673..-50337
on x=22287..38187,y=-77058..-57586,z=18142..30066
on x=4419..31341,y=-41481..-16670,z=-81172..-57309
on x=8787..18199,y=-64117..-47739,z=-70211..-33590
on x=-57396..-23441,y=-40148..-19475,z=-59387..-53779
off x=40021..56235,y=53608..80538,z=-8677..16436
off x=-26722..-20312,y=-44588..-19430,z=-84589..-48744
on x=-69441..-51273,y=-24876..5239,z=-66713..-38612
on x=-76389..-69660,y=7155..24775,z=-38447..-18194
off x=-66635..-46946,y=-25954..-10695,z=-57100..-28565
off x=-21191..-1727,y=-58228..-45449,z=44445..71322
off x=41312..51663,y=-72832..-39627,z=20801..31348
off x=56041..68285,y=54961..59884,z=-4255..8498
on x=-14498..5545,y=-70758..-51582,z=39740..50934
on x=-60094..-52144,y=-48166..-15187,z=33932..61840
off x=38084..49019,y=58548..75487,z=-2165..17458
on x=15976..28288,y=76617..88088,z=-2531..28653
on x=-81155..-46248,y=34889..57113,z=-32302..-12872
off x=-87452..-62535,y=2890..26547,z=-38619..-22540
on x=-65104..-40915,y=-26071..-718,z=-59229..-45047
on x=20207..35649,y=35200..55736,z=-60963..-38806
off x=-18964..-1801,y=-83830..-62226,z=-46379..-39759
off x=-33160..-16493,y=-20269..-9595,z=-80212..-68727
on x=-24831..-1060,y=-57871..-39528,z=-68831..-49249
off x=-21361..-17169,y=66223..84265,z=-24356..-1698
on x=16728..34525,y=-73668..-61040,z=-56037..-26138
off x=541..22520,y=-18647..10002,z=-77730..-73383
off x=30741..41844,y=-70342..-57291,z=-38501..-31442
off x=67877..91935,y=5813..21475,z=-14674..14415
off x=-10610..12427,y=34688..62776,z=46255..75246
off x=-13513..48,y=50893..71352,z=-55660..-43290
on x=23723..52282,y=-72913..-53848,z=3360..27145
off x=-56101..-36098,y=-57614..-52359,z=-19109..4706
on x=866..34237,y=-57622..-50940,z=50662..61822
off x=-76658..-56139,y=14391..39042,z=30080..57021
off x=54165..78635,y=-6833..18289,z=32209..48264
on x=67780..73288,y=-46693..-20747,z=-2815..16941
off x=-75387..-51972,y=-63603..-31968,z=-2499..26963
off x=-89491..-63264,y=-10926..11381,z=27063..45350
off x=-356..29772,y=-85985..-64061,z=6665..41527
on x=-6525..-4209,y=68332..85259,z=12656..23509
off x=67989..83514,y=-12293..16132,z=-37385..-18334
on x=-69282..-48247,y=37373..64044,z=-24184..1690
on x=-8216..11151,y=-11067..13042,z=-85365..-70751
on x=70092..82629,y=25761..45220,z=10177..28276
on x=-28369..-18186,y=-80812..-71943,z=-19973..2443
on x=62999..83584,y=6597..11518,z=-13942..-10429
off x=-66817..-62049,y=27948..43971,z=-52732..-28195
on x=-14632..-330,y=28116..47882,z=-76077..-54010
on x=-69053..-39254,y=39689..43930,z=-53155..-26709
off x=-9272..-2732,y=67573..86847,z=23217..48030
off x=-63049..-42846,y=-47968..-41956,z=-57096..-30744
on x=-74471..-38890,y=47590..65502,z=-22625..-12501
on x=11762..36024,y=-29287..-10119,z=-84268..-68104
off x=40069..58516,y=-35284..-11547,z=-71118..-56431
off x=52919..62481,y=-44847..-33880,z=-48353..-37342
on x=62270..83427,y=16121..36384,z=10920..37527
off x=-38660..-31778,y=-76458..-69083,z=-19158..483
on x=-30936..-14873,y=-67934..-58277,z=-49026..-38290
on x=58135..81747,y=11506..33058,z=-38699..-14953
on x=-1813..9161,y=-53690..-46325,z=54699..69798
off x=27257..46561,y=-69078..-53557,z=-22496..-12158
off x=-40182..-33910,y=-70101..-48508,z=-34688..-3706
on x=-900..20404,y=-38403..-17943,z=56024..81587
off x=21116..28851,y=43224..54764,z=-67604..-49651
on x=-81635..-66483,y=-41245..-15485,z=-24348..-17554
on x=58347..78626,y=24840..44361,z=-37870..-10683
off x=40939..64137,y=-53875..-28589,z=10564..31395
off x=19554..38784,y=39279..58041,z=42519..68206
on x=19339..43564,y=-30314..-11562,z=-76542..-69920
off x=-13613..-8170,y=-89273..-57757,z=15090..26824
off x=-16436..9811,y=-67697..-42756,z=-54901..-39536
off x=24490..58096,y=54945..62686,z=-51130..-29788
off x=-77082..-51429,y=-11834..-7441,z=44014..64587
off x=-59299..-44644,y=-44663..-20705,z=45491..57080
off x=61171..75665,y=31166..51101,z=-27511..-18922
on x=40500..60916,y=32862..55521,z=-15770..9569
off x=53060..72355,y=20810..27564,z=50370..53066
on x=-72239..-56753,y=36578..50619,z=-45671..-26309
on x=28772..56041,y=-69826..-56546,z=7721..23684
on x=28809..38444,y=-76239..-61101,z=23646..39528
off x=-35109..-3537,y=-82961..-49743,z=25419..43628
off x=-90556..-54322,y=-25076..-9827,z=20950..36028
off x=24147..44684,y=-19636..-4030,z=52026..90289
on x=23617..37697,y=-66099..-38365,z=-65664..-45568
on x=56022..86225,y=-49726..-17790,z=12662..18480
on x=66137..91885,y=-11999..7252,z=-17273..-9431
on x=64160..72151,y=-26054..-7078,z=25439..38577
off x=165..17533,y=-91409..-64999,z=-1986..20723
off x=-59406..-46251,y=-66568..-43184,z=-36494..-12707
off x=7621..32609,y=15949..36522,z=61744..92377
on x=36441..52384,y=41888..73357,z=30475..45566
on x=-50547..-45073,y=-42280..-8085,z=-66658..-58426
off x=-14883..-6872,y=72032..78463,z=12880..26644
off x=-59588..-51858,y=-60974..-46826,z=-41970..-31089
on x=-25121..-3865,y=-46458..-21692,z=-91353..-67614
on x=1756..25367,y=-47252..-35025,z=-77032..-52983
off x=26234..47055,y=32660..61205,z=-74260..-44866
on x=54915..67411,y=29100..59180,z=-14551..2987
off x=22834..38710,y=-88145..-63890,z=-12370..13586
on x=1846..22993,y=-77480..-40523,z=36818..71818
on x=-54230..-33422,y=-47099..-24721,z=54519..59299
on x=-23512..-309,y=-90885..-58963,z=-14286..-4632
on x=-49309..-34791,y=-72297..-42882,z=-45404..-26618
off x=-65879..-54178,y=-40839..-21322,z=39438..63568
on x=-97411..-75554,y=-1663..14689,z=-19784..-965
on x=-21377..-1742,y=-47033..-29562,z=-83805..-52490
on x=-63483..-40180,y=26205..51029,z=-44078..-28543
off x=-33598..-10323,y=-24958..-14866,z=-91402..-65654
on x=32831..48325,y=-25916..-12562,z=52785..69086
off x=-30864..-12067,y=-39254..-31994,z=-71835..-51060
off x=39107..74651,y=-24196..-5206,z=35393..66884
on x=-51995..-34652,y=-46994..-34230,z=46866..60623
on x=50860..75851,y=5360..20428,z=25744..40749
on x=-54738..-32511,y=53670..75587,z=3138..19752
on x=-28897..-5457,y=26922..57262,z=49425..77761
on x=-76035..-63053,y=-26260..670,z=-40028..-31516
on x=-60144..-29913,y=8350..41401,z=44019..60077
off x=73334..86979,y=-20441..14588,z=8192..33868
off x=-72286..-53428,y=-27157..-14885,z=-43481..-30084
on x=-28218..3733,y=-67461..-43956,z=-50987..-45839
off x=-81359..-62348,y=-1058..31060,z=-20199..-8727
off x=-70081..-53991,y=-17628..7971,z=45558..75283
on x=-82019..-75068,y=-24773..-2915,z=-29838..-16169
on x=5046..22733,y=-92169..-65972,z=15135..40124
on x=-57259..-36812,y=24150..39533,z=-73066..-41970
on x=-16449..7244,y=-74960..-57796,z=-55681..-31744
on x=24416..33079,y=-78008..-53237,z=-5679..21484
off x=32811..44124,y=-67826..-66688,z=-6224..4467
off x=-74458..-55909,y=-42511..-27629,z=11343..20090
off x=-12182..1448,y=3292..4392,z=-96595..-67036
on x=40088..68915,y=56940..66512,z=-33246..-9518
on x=-93572..-77216,y=1061..10807,z=-6986..-3124
off x=-64317..-53066,y=-64173..-44851,z=-24777..-10070
on x=46103..66691,y=-28661..-20289,z=17209..45997
off x=-43907..-24397,y=57826..89561,z=8396..23815
off x=41296..64640,y=22522..45300,z=48162..70860
on x=73558..90694,y=-5438..10884,z=20557..25645
on x=-67229..-35872,y=-61981..-34938,z=44339..64846
on x=57781..68251,y=-13661..8099,z=32701..51775
on x=-15936..-903,y=19116..33981,z=57718..86119
on x=-65649..-29000,y=-28559..-13521,z=57697..76711
off x=-61701..-29928,y=17575..37780,z=-63783..-59511
on x=-28884..-8225,y=73074..84232,z=-36706..-1866
on x=38167..43384,y=52642..59708,z=19405..53813
off x=-34682..-20690,y=-49255..-12382,z=52913..72664
off x=23243..48581,y=35357..68043,z=-59135..-40495
off x=-16558..3825,y=77173..87991,z=430..18506
on x=-51861..-26427,y=566..19730,z=52398..67145
off x=-2054..5679,y=21775..58192,z=52542..76609
on x=69353..76679,y=-32520..-24321,z=-32891..129

201
22/main.cpp Normal file
View File

@ -0,0 +1,201 @@
#include <fstream>
#include <iostream>
#include <sstream>
#include <vector>
class Instruction {
public:
Instruction() {};
void setXMin(int64_t x) {
x_min = x;
}
void setXMax(int64_t x) {
x_max = x;
}
void setYMin(int64_t y) {
y_min = y;
}
void setYMax(int64_t y) {
y_max = y;
}
void setZMin(int64_t z) {
z_min = z;
}
void setZMax(int64_t z) {
z_max = z;
}
int64_t getXMin() const {
return x_min;
}
int64_t getXMax() const {
return x_max;
}
int64_t getYMin() const {
return y_min;
}
int64_t getYMax() const {
return y_max;
}
int64_t getZMin() const {
return z_min;
}
int64_t getZMax() const {
return z_max;
}
void setState(bool on) {
state = on;
}
bool getState() const {
return state;
}
uint64_t getArea() const {
return (abs(x_max - x_min) + 1) * (abs(y_max - y_min) + 1) * (abs(z_max - z_min) + 1);
}
void print() const {
std::cout << "CUB: X=" << getXMin() << ".." << getXMax() << ", Y=" << getYMin() << ".." << getYMax() << ", Z=" << getZMin() << ".." << getZMax() << "; " << (getState() ? "LIT" : "DARK") << std::endl;
}
private:
int64_t x_min = 0;
int64_t x_max = 0;
int64_t y_min = 0;
int64_t y_max = 0;
int64_t z_min = 0;
int64_t z_max = 0;
bool state = false;
};
std::vector<Instruction> getInstructions(const std::string &file_name) {
std::ifstream file(file_name);
std::vector<Instruction> result{};
int64_t tmp_i = 0;
std::string tmp_s = "";
char tmp_c = ' ';
std::string str;
while (std::getline(file, str)) {
result.emplace_back();
if(str[1] == 'n') {
result.back().setState(true);
} else {
result.back().setState(false);
}
std::stringstream ss(str);
int64_t numbers[6];
int64_t index = 0;
ss >> tmp_s;
for(int64_t i = 0; i < 3; i++) {
ss >> tmp_c;
ss >> tmp_c;
ss >> tmp_i;
numbers[index] = tmp_i;
index++;
ss >> tmp_c;
ss >> tmp_c;
ss >> tmp_i;
numbers[index] = tmp_i;
index++;
ss >> tmp_c;
}
result.back().setXMin(numbers[0]);
result.back().setXMax(numbers[1]);
result.back().setYMin(numbers[2]);
result.back().setYMax(numbers[3]);
result.back().setZMin(numbers[4]);
result.back().setZMax(numbers[5]);
}
return result;
}
int64_t part1(const std::vector<Instruction> &instructions) {
bool cubes[101][101][101];
for(int64_t x = 0; x < 101; x++) {
for(int64_t y = 0; y < 101; y++) {
for(int64_t z = 0; z < 101; z++) {
cubes[x][y][z] = false;
}
}
}
for(auto &instruction : instructions) {
for(int64_t x = instruction.getXMin() + 50; x <= instruction.getXMax() + 50; x++) {
for(int64_t y = instruction.getYMin() + 50; y <= instruction.getYMax() + 50; y++) {
for(int64_t z = instruction.getZMin() + 50; z <= instruction.getZMax() + 50; z++) {
if(x < 0 || x > 100 || y < 0 || y > 100 || z < 0 || z > 100) {
continue;
}
cubes[x][y][z] = instruction.getState();
}
}
}
}
int64_t lit = 0;
for(int64_t x = 0; x < 101; x++) {
for(int64_t y = 0; y < 101; y++) {
for(int64_t z = 0; z < 101; z++) {
if(cubes[x][y][z]) {
lit++;
}
}
}
}
return lit;
}
std::pair<bool, Instruction> getOverlappingCube(Instruction cube1, Instruction cube2) {
if(cube2.getXMax() < cube1.getXMin() || cube2.getXMin() > cube1.getXMax() ||
cube2.getYMax() < cube1.getYMin() || cube2.getYMin() > cube1.getYMax() ||
cube2.getZMax() < cube1.getZMin() || cube2.getZMin() > cube1.getZMax()) {
return {false, Instruction()};
}
auto x_min = cube1.getXMin() > cube2.getXMin() ? cube1.getXMin() : cube2.getXMin();
auto x_max = cube1.getXMax() < cube2.getXMax() ? cube1.getXMax() : cube2.getXMax();
auto y_min = cube1.getYMin() > cube2.getYMin() ? cube1.getYMin() : cube2.getYMin();
auto y_max = cube1.getYMax() < cube2.getYMax() ? cube1.getYMax() : cube2.getYMax();
auto z_min = cube1.getZMin() > cube2.getZMin() ? cube1.getZMin() : cube2.getZMin();
auto z_max = cube1.getZMax() < cube2.getZMax() ? cube1.getZMax() : cube2.getZMax();
auto res = Instruction();
res.setXMin(x_min);
res.setXMax(x_max);
res.setYMin(y_min);
res.setYMax(y_max);
res.setZMin(z_min);
res.setZMax(z_max);
return {true, res};
}
uint64_t part2(const std::vector<Instruction> &instructions) {
std::vector<Instruction> cuboids{};
for(auto &instruction : instructions) {
std::vector<Instruction> new_cuboids{};
for(auto cuboid : cuboids) {
auto intersect = getOverlappingCube(cuboid, instruction);
if(!intersect.first) {
continue;
}
intersect.second.setState(!cuboid.getState());
new_cuboids.push_back(intersect.second);
}
for(auto &cuboid : new_cuboids) {
cuboids.push_back(cuboid);
}
if(instruction.getState()) {
cuboids.push_back(instruction);
}
}
uint64_t lit = 0;
for(auto &cuboid : cuboids) {
lit += cuboid.getArea() * (cuboid.getState() ? 1 : -1);
}
return lit;
}
int main(int argc, char **argv) {
if (argc < 2) {
std::cerr << "You must provide input file!" << std::endl;
return 1;
}
auto instructions = getInstructions(argv[1]);
std::cout << "There are \033[91;1m" << part1(instructions)
<< "\033[0m cubes lit." << std::endl;
std::cout << "There are \033[91;1m" << part2(instructions)
<< "\033[0m cubes lit." << std::endl;
return 0;
}