From 2b89e55784f0569ffb1f25b1b893c6595be93c9c Mon Sep 17 00:00:00 2001 From: Karl Spickermann Date: Thu, 23 Dec 2021 02:00:06 +0100 Subject: [PATCH] Day22 --- src/day22/day22.go | 250 +++++++++++++++++++++++ src/day22/day22Input.txt | 420 +++++++++++++++++++++++++++++++++++++++ src/day22/day22Test.txt | 4 + src/day22/day22Test2.txt | 22 ++ src/day22/day22Test3.txt | 60 ++++++ 5 files changed, 756 insertions(+) create mode 100644 src/day22/day22.go create mode 100644 src/day22/day22Input.txt create mode 100644 src/day22/day22Test.txt create mode 100644 src/day22/day22Test2.txt create mode 100644 src/day22/day22Test3.txt diff --git a/src/day22/day22.go b/src/day22/day22.go new file mode 100644 index 0000000..ae31c28 --- /dev/null +++ b/src/day22/day22.go @@ -0,0 +1,250 @@ +package main + +import ( + "AOC2021/src/helper" + "fmt" + "os" + "strconv" + "strings" +) + +type cubid struct { + xValues [2]int + yValues [2]int + zValues [2]int + cuts []*cubid + alreadyUsed []*cubid + command string +} + +func main() { + args := os.Args[1:] + input, err := helper.GetInput(args[0]) + if err != nil { + fmt.Println(err) + } + part1(input) + + cubids := []*cubid{} + for _, row := range input { + commandSplit := strings.Split(row, " ") + valueSplit := strings.Split(helper.RemoveCharactersFromString(commandSplit[1], "yxz,"), "=") + xValues := getValuesFromString(valueSplit[1], false) + yValues := getValuesFromString(valueSplit[2], false) + zValues := getValuesFromString(valueSplit[3], false) + cubids = addCubid(cubids, cubid{xValues, yValues, zValues, []*cubid{}, []*cubid{}, commandSplit[0]}) + + } + fmt.Println(countActiveCubids(cubids)) +} + +func part1(input []string) { + coreMap := make(map[[3]int]struct{}) + for _, row := range input { + commandSplit := strings.Split(row, " ") + valueSplit := strings.Split(helper.RemoveCharactersFromString(commandSplit[1], "yxz,"), "=") + xValues := getValuesFromString(valueSplit[1], true) + yValues := getValuesFromString(valueSplit[2], true) + zValues := getValuesFromString(valueSplit[3], true) + for i := xValues[0]; i <= xValues[1]; i++ { + for j := yValues[0]; j <= yValues[1]; j++ { + for k := zValues[0]; k <= zValues[1]; k++ { + if commandSplit[0] == "on" { + coreMap[[3]int{i, j, k}] = struct{}{} + } else if commandSplit[0] == "off" { + delete(coreMap, [3]int{i, j, k}) + } + } + } + } + } + fmt.Println(int64(len(coreMap))) +} + +func checkOverlap(cubid1 *cubid, cubid2 *cubid) bool { + if !overlapLines(cubid1.xValues, cubid2.xValues) { + return false + } + if !overlapLines(cubid1.yValues, cubid2.yValues) { + return false + } + if !overlapLines(cubid1.zValues, cubid2.zValues) { + return false + } + return true +} + +func addCubid(cubids []*cubid, newCubid cubid) []*cubid { + newCubids := []*cubid{} + if newCubid.command == "off" { + for i := range cubids { + if checkOverlap(cubids[i], &newCubid) { + cut(cubids[i], newCubid) + newCubids = append(newCubids, cubids[i]) + } else { + newCubids = append(newCubids, cubids[i]) + } + } + } + + if newCubid.command == "on" { + newCubids = handleOnCubid(cubids, newCubid, newCubids) + } + return newCubids +} + +func handleOnCubid(cubids []*cubid, newCubid cubid, newCubids []*cubid) []*cubid { + tmpNewCubid := newCubid + tmpOffCubid := newCubid + tmpOffCubid.command = "off" + for i := range cubids { + if checkOverlap(cubids[i], &tmpNewCubid) { + alreadyUsed(&tmpNewCubid, cubids[i]) + addCubid(cubids[i].cuts, tmpOffCubid) + } + newCubids = append(newCubids, cubids[i]) + } + newCubids = append(newCubids, &tmpNewCubid) + return newCubids +} + +func countActiveCubids(cubids []*cubid) int64 { + sum := int64(0) + for i := range cubids { + allPoints := countActiveCubid(cubids[i]) + inactivePoints := countActiveCubids(cubids[i].cuts) + alreadyUsedPoints := countActiveCubids(cubids[i].alreadyUsed) + sum += allPoints - inactivePoints - alreadyUsedPoints + } + return sum +} + +func countActiveCubid(cubid *cubid) int64 { + lengthX := cubid.xValues[1] - cubid.xValues[0] + 1 + lengthY := cubid.yValues[1] - cubid.yValues[0] + 1 + lengthZ := cubid.zValues[1] - cubid.zValues[0] + 1 + sum := int64(lengthX) * int64(lengthY) * int64(lengthZ) + return sum +} + +func cut(cubid1 *cubid, cubid2 cubid) int { + cutCubid := cubid{} + cutCubid.xValues[0] = max(cubid1.xValues[0], cubid2.xValues[0]) + cutCubid.yValues[0] = max(cubid1.yValues[0], cubid2.yValues[0]) + cutCubid.zValues[0] = max(cubid1.zValues[0], cubid2.zValues[0]) + cutCubid.xValues[1] = min(cubid1.xValues[1], cubid2.xValues[1]) + cutCubid.yValues[1] = min(cubid1.yValues[1], cubid2.yValues[1]) + cutCubid.zValues[1] = min(cubid1.zValues[1], cubid2.zValues[1]) + cutCubid.command = "on" + for _, overlapCubid := range cubid1.alreadyUsed { + if checkOverlap(&cutCubid, overlapCubid) { + alreadyUsed(&cutCubid, overlapCubid) + } + } + cubid1.cuts = addCubid(cubid1.cuts, cutCubid) + return 0 +} + +func alreadyUsed(cubid1 *cubid, cubid2 *cubid) int { + cutCubid := cubid{} + cutCubid.xValues[0] = max(cubid1.xValues[0], cubid2.xValues[0]) + cutCubid.yValues[0] = max(cubid1.yValues[0], cubid2.yValues[0]) + cutCubid.zValues[0] = max(cubid1.zValues[0], cubid2.zValues[0]) + cutCubid.xValues[1] = min(cubid1.xValues[1], cubid2.xValues[1]) + cutCubid.yValues[1] = min(cubid1.yValues[1], cubid2.yValues[1]) + cutCubid.zValues[1] = min(cubid1.zValues[1], cubid2.zValues[1]) + cutCubid.command = "on" + cubid1.alreadyUsed = addCubid(cubid1.alreadyUsed, cutCubid) + return 0 +} + +func checkSameCoordinates(cubid1 cubid, cubid2 cubid) bool { + return cubid1.xValues == cubid2.xValues && cubid1.yValues == cubid2.yValues && cubid1.zValues == cubid2.zValues +} + +func getValuesFromString(input string, part1 bool) (output [2]int) { + split := strings.Split(input, "..") + output[0], _ = strconv.Atoi(split[0]) + if part1 && output[0] < -50 { + output[0] = -50 + } + output[1], _ = strconv.Atoi(split[1]) + if part1 && output[1] > 50 { + output[1] = 50 + } + return +} + +func isBetween(x, a, b int) bool { + if x >= a && x <= b { + return true + } + return false +} + +func overlapLines(a, b [2]int) bool { + for _, aVal := range a { + if isBetween(aVal, b[0], b[1]) { + return true + } + } + for _, bVal := range b { + if isBetween(bVal, a[0], a[1]) { + return true + } + } + return false +} + +func min(a, b int) int { + if a < b { + return a + } + return b +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} + +func printTwoDimensions(cubids []*cubid) { + field := initiateDimension(100, 100) + offset := 40 + + for _, cubid := range cubids { + for i := cubid.xValues[0] + offset; i <= cubid.xValues[1]+offset; i++ { + for j := cubid.yValues[0] + offset; j <= cubid.yValues[1]+offset; j++ { + field[j][i] = '#' + } + } + for _, cut := range cubid.cuts { + for i := cut.xValues[0] + offset; i <= cut.xValues[1]+offset; i++ { + for j := cut.yValues[0] + offset; j <= cut.yValues[1]+offset; j++ { + field[j][i] = 'X' + } + } + } + } + for _, row := range field { + fmt.Println(string(row)) + } + fmt.Printf("Active Points: %d \n", countActiveCubids(cubids)) +} + +func initiateDimension(x int, y int) [][]rune { + var emptyLayer [][]rune + for i := 0; i < y; i++ { + emptyLayer = append(emptyLayer, []rune(strings.Repeat(".", x))) + } + return emptyLayer +} + +func Abs(x int64) int64 { + if x < 0 { + return -x + } + return x +} diff --git a/src/day22/day22Input.txt b/src/day22/day22Input.txt new file mode 100644 index 0000000..f47dbe0 --- /dev/null +++ b/src/day22/day22Input.txt @@ -0,0 +1,420 @@ +on x=-15..36,y=-36..8,z=-12..33 +on x=-49..4,y=-24..27,z=-45..3 +on x=-18..27,y=-44..6,z=-44..5 +on x=-17..29,y=-23..23,z=-14..35 +on x=-6..40,y=-43..9,z=-20..30 +on x=-37..12,y=0..48,z=-45..2 +on x=-47..7,y=-43..1,z=-19..33 +on x=-20..29,y=-35..15,z=-28..19 +on x=-45..3,y=-24..30,z=-32..13 +on x=-27..25,y=-37..17,z=-48..3 +off x=27..40,y=15..26,z=0..11 +on x=-22..23,y=-33..18,z=-41..4 +off x=-38..-21,y=-18..-7,z=-29..-20 +on x=-11..33,y=-43..5,z=-20..34 +off x=5..19,y=33..49,z=-39..-25 +on x=-15..32,y=-27..22,z=-45..0 +off x=-10..5,y=17..27,z=-4..12 +on x=2..49,y=-46..2,z=-13..35 +off x=15..27,y=-19..-8,z=-14..5 +on x=-1..47,y=-24..23,z=-38..13 +on x=-63699..-30935,y=-44942..-13530,z=-64371..-44538 +on x=-59912..-41895,y=-50016..-36554,z=49470..61593 +on x=-44610..-35424,y=-74270..-50977,z=-19507..-1834 +on x=54513..78252,y=11460..31839,z=-48732..-29269 +on x=-34169..-4352,y=62043..91296,z=-5077..7244 +on x=-1110..24332,y=13070..41432,z=-79184..-60366 +on x=-17481..-1302,y=46625..74856,z=-61039..-41043 +on x=48854..77195,y=38918..47498,z=-45031..-28532 +on x=-10776..9010,y=54671..68859,z=33447..61536 +on x=28421..43757,y=41541..61220,z=39397..52225 +on x=-71255..-42549,y=-52258..-42229,z=39642..43283 +on x=52540..76729,y=-54341..-32823,z=-273..5025 +on x=-5652..24972,y=73539..89083,z=9623..25933 +on x=41484..66404,y=44291..61108,z=-32988..-21048 +on x=-78139..-73673,y=-24379..-16395,z=-29874..-13779 +on x=-76236..-55415,y=-14445..2985,z=-50132..-41754 +on x=-54930..-34724,y=-61826..-37484,z=19165..49138 +on x=-16263..13979,y=66109..84667,z=-61921..-41568 +on x=-61221..-41809,y=-28838..-2784,z=-74020..-54812 +on x=-37301..-23009,y=63379..78326,z=-3635..22771 +on x=38433..51794,y=-19649..-6633,z=-76219..-54054 +on x=15023..19691,y=66786..90255,z=-33829..-1960 +on x=54401..66992,y=-36517..-28498,z=36987..60399 +on x=-49486..-30347,y=-47562..-20838,z=43500..72076 +on x=-26990..-20209,y=68470..88747,z=-38791..-4160 +on x=-6144..12720,y=-747..20233,z=78747..81200 +on x=30857..56115,y=51887..78960,z=-31632..-4504 +on x=-23871..-11351,y=36113..59493,z=-60455..-38672 +on x=-26796..-6871,y=66783..89292,z=-34705..-12343 +on x=59885..83979,y=18242..40964,z=-29733..1251 +on x=-47566..-28774,y=26022..39182,z=47839..67912 +on x=55250..64653,y=-56962..-49600,z=-146..19397 +on x=-37538..-24234,y=-53962..-24442,z=48186..78833 +on x=25224..40558,y=-35677..-20943,z=62924..74759 +on x=51757..79427,y=39950..53097,z=9245..39818 +on x=-18893..-8772,y=-15181..2445,z=-86488..-76370 +on x=-727..11725,y=-79865..-73249,z=-27827..-19670 +on x=-43285..-26293,y=41933..51569,z=47444..60533 +on x=38776..69339,y=-26296..-17647,z=41338..59186 +on x=-350..18931,y=62130..87451,z=23947..47325 +on x=20122..39804,y=2049..23090,z=-76844..-64551 +on x=-78814..-48278,y=29602..49270,z=-9487..17576 +on x=-81803..-44729,y=-44303..-36327,z=12725..39959 +on x=-43133..-26498,y=-51215..-32207,z=52224..69994 +on x=-82695..-70575,y=-11272..4458,z=-45348..-34592 +on x=-16191..7441,y=62032..72327,z=-38931..-30277 +on x=45524..57534,y=-42719..-28567,z=-57536..-46275 +on x=55287..74512,y=6411..27093,z=-65991..-40761 +on x=-88115..-62068,y=-4404..2024,z=32627..48329 +on x=-28677..-8175,y=31321..64709,z=46109..68440 +on x=47252..62539,y=36369..64602,z=27125..60190 +on x=20120..35976,y=26868..59489,z=-80311..-43716 +on x=-40329..-31239,y=23053..48591,z=51563..84573 +on x=-15974..-1096,y=13083..35628,z=-77406..-57200 +on x=-6889..13279,y=57371..85588,z=32508..48777 +on x=27418..40188,y=6870..21404,z=68189..73841 +on x=45856..83191,y=23068..34774,z=-49327..-23613 +on x=57763..81738,y=27749..54465,z=-19770..7512 +on x=-63320..-56478,y=-21605..1439,z=-57082..-40600 +on x=-11623..19624,y=-34574..-4222,z=-95771..-64252 +on x=-26447..-4750,y=62965..86233,z=1913..12898 +on x=15044..19914,y=18452..44812,z=-79635..-62169 +on x=1853..14793,y=25143..47630,z=-85408..-46124 +on x=20809..38184,y=-84715..-57409,z=7782..30593 +on x=56871..74867,y=14580..33888,z=-42019..-29968 +on x=-66986..-55588,y=25244..53933,z=24976..42642 +on x=-25809..-4235,y=51657..74088,z=45904..67516 +on x=-717..21481,y=4753..8297,z=-91324..-73544 +on x=-35961..-9657,y=-85874..-61586,z=31787..36160 +on x=-44980..-30533,y=66089..70263,z=-36958..-14911 +on x=-61061..-35838,y=58008..63560,z=13699..30045 +on x=52674..68071,y=21426..48384,z=13284..39318 +on x=37459..53335,y=58597..78092,z=16319..31581 +on x=37928..60400,y=34478..56993,z=-54573..-19704 +on x=64879..91526,y=-43666..-26581,z=4617..27506 +on x=-77137..-67988,y=-26323..-709,z=-25116..-16315 +on x=-40423..-23937,y=-72472..-53424,z=-44215..-25465 +on x=57976..82594,y=5270..36140,z=-1756..21236 +on x=-84261..-67613,y=-12448..4721,z=12844..33790 +on x=6923..21467,y=-87828..-61404,z=-22326..-4710 +on x=18042..35464,y=-22227..-10195,z=57235..80936 +on x=-43144..-27993,y=60781..71451,z=-55061..-38197 +on x=70524..78769,y=18911..26219,z=-26449..1955 +on x=4158..33708,y=21100..47210,z=-76423..-62606 +on x=-28308..-15822,y=-41962..-32381,z=-66619..-49737 +on x=-74976..-55378,y=-19058..-3572,z=-54171..-32504 +on x=-51891..-24086,y=31122..44128,z=-57638..-53440 +on x=72431..91188,y=-10372..1528,z=13108..38685 +on x=-73215..-41449,y=-3087..14718,z=46271..65937 +on x=-35776..-12674,y=-71045..-40786,z=46888..64132 +on x=44225..67521,y=12877..34973,z=-49293..-35195 +on x=-17953..6214,y=45528..58061,z=48910..74464 +on x=30507..51406,y=47273..63419,z=-38803..-19208 +on x=-45312..-25433,y=-76145..-46135,z=26481..53383 +on x=33098..41182,y=-10149..7914,z=66411..88975 +on x=-31336..-2387,y=69612..89996,z=-6734..19927 +on x=-75389..-49860,y=14568..15460,z=42414..57999 +on x=8602..33198,y=46920..66025,z=50329..66605 +on x=-49015..-26656,y=-65498..-56636,z=-48932..-21812 +on x=60257..72211,y=13842..17443,z=28370..46232 +on x=42805..67030,y=48861..63084,z=-20977..-3400 +on x=-71382..-65532,y=25192..56390,z=5344..25626 +on x=32626..44320,y=-57736..-46313,z=-57570..-39749 +on x=4416..38210,y=48923..77091,z=-49409..-30817 +on x=-41513..-14703,y=42522..62013,z=-48139..-27592 +on x=53938..74304,y=-44876..-14755,z=-59018..-38494 +on x=-26227..-5475,y=43872..55611,z=53509..74022 +on x=65225..81392,y=41337..53601,z=-32421..472 +on x=-444..19714,y=-86965..-66202,z=11639..24182 +on x=-19517..-8929,y=74678..84936,z=10164..21155 +on x=-983..24530,y=-97200..-77235,z=-23113..1779 +on x=17018..27483,y=59318..87690,z=-11228..11452 +on x=-44752..-24564,y=-64634..-55955,z=37216..54008 +on x=17043..38948,y=52433..70222,z=17236..30450 +on x=13118..34059,y=-25085..-3591,z=-75280..-59012 +on x=-30128..-9807,y=-81066..-62301,z=-40253..-20727 +on x=-6452..24582,y=-41365..-30084,z=65483..74124 +on x=60681..84248,y=-6299..6874,z=-54732..-33729 +on x=-53455..-27658,y=-42035..-19010,z=55673..67187 +on x=-44576..-29651,y=-35998..-17055,z=49556..66327 +on x=52060..62963,y=29525..40472,z=41614..47460 +on x=37392..47310,y=-26891..-14158,z=-68800..-54750 +on x=55342..79808,y=24487..39014,z=16347..35970 +on x=-65267..-51560,y=-60924..-47563,z=934..20986 +on x=-38605..-14881,y=-41081..-34976,z=60320..74138 +on x=-55708..-31963,y=-39730..-8048,z=-80349..-59832 +on x=-51243..-26302,y=-79507..-53310,z=-30481..-24020 +on x=34129..57591,y=-16816..3673,z=55269..72725 +on x=14212..33583,y=5240..23902,z=-91942..-67137 +on x=-29266..-7142,y=58275..85891,z=4745..34326 +on x=12274..26298,y=10964..32660,z=58085..80994 +on x=33886..60841,y=-65591..-56410,z=-753..7846 +on x=38508..57089,y=52184..79460,z=-4242..26986 +on x=-68222..-45635,y=-52103..-28504,z=-29387..3174 +on x=-1838..6941,y=-24252..1445,z=-85772..-66955 +on x=-71064..-48088,y=-70005..-45536,z=-33826..-20804 +on x=9227..35180,y=38303..63792,z=33095..66362 +on x=-69896..-37796,y=-54350..-21668,z=-59793..-46276 +on x=33600..58707,y=-53211..-45108,z=25566..44910 +on x=65124..83476,y=-36463..-11210,z=-20148..-2035 +on x=-23887..-14556,y=69255..94834,z=-7217..13570 +on x=-76690..-59151,y=-35879..-33075,z=2296..30918 +on x=-14025..9128,y=43807..66281,z=46042..72944 +on x=-86957..-55331,y=8377..39314,z=-47554..-21799 +on x=-61919..-36741,y=-60036..-31968,z=-63586..-34465 +on x=-35340..-18147,y=47859..68729,z=-33118..-17020 +on x=30513..59086,y=55017..56648,z=23292..50081 +on x=-51668..-42773,y=19003..38755,z=44809..63395 +on x=-64347..-52024,y=38468..74928,z=-9389..20504 +on x=20261..35420,y=-57035..-37270,z=-60832..-47489 +on x=-50080..-18475,y=-37464..-11099,z=-68061..-51124 +on x=9083..38991,y=-1088..15537,z=-78615..-73519 +on x=47190..57500,y=-72451..-54721,z=24551..39638 +on x=-63459..-46994,y=-56482..-33316,z=-38327..-13317 +on x=26173..48364,y=-6639..5883,z=-77615..-55676 +on x=-77882..-69467,y=28654..40985,z=-32439..-8302 +on x=-18191..-11873,y=46265..73718,z=38170..73749 +on x=-36626..-32140,y=18415..31120,z=54603..74272 +on x=15571..37413,y=-78669..-68170,z=-4474..7306 +on x=-9043..12056,y=-60528..-28132,z=-79764..-50513 +on x=-52352..-44681,y=-66856..-44887,z=10553..25545 +on x=-18323..1168,y=-94315..-79816,z=-14955..20191 +on x=50146..82763,y=-9295..13320,z=-46441..-22666 +on x=-33085..-1847,y=-82426..-65047,z=22802..33839 +on x=12257..33795,y=56763..90957,z=-19386..-3860 +on x=-84685..-64712,y=25644..52592,z=13930..28355 +on x=-51557..-28907,y=-13918..20955,z=-83397..-53411 +on x=3988..26037,y=-48586..-16570,z=-87449..-68221 +on x=3822..25229,y=58028..74595,z=27339..27849 +on x=6130..30447,y=63116..71815,z=32118..41048 +on x=-52963..-45043,y=-46358..-41931,z=-45169..-37314 +on x=-3793..-1405,y=-40707..-33575,z=-88493..-63699 +on x=-14281..5476,y=61268..89020,z=21445..50471 +on x=-59906..-44550,y=7255..33537,z=-66242..-33467 +on x=66723..78062,y=-27323..-25587,z=-12892..2139 +on x=-27121..-22913,y=28382..37791,z=-88836..-68773 +on x=-19102..-10994,y=-74565..-47804,z=37589..44540 +on x=-62079..-36324,y=-52716..-28618,z=-61037..-35353 +on x=48920..67501,y=33892..63687,z=-5266..24312 +on x=8568..20639,y=70383..94430,z=-19931..-1354 +on x=26530..49681,y=-85935..-55199,z=-1716..27569 +on x=-20172..5916,y=30835..63529,z=-85441..-61343 +on x=-31112..-956,y=-34833..-16860,z=-78589..-65290 +on x=7827..31557,y=29064..55509,z=64996..79352 +on x=60434..81013,y=-15234..4230,z=37279..57467 +on x=-10200..3438,y=70040..89319,z=2951..25986 +on x=-73125..-62420,y=-11912..18332,z=-50416..-31358 +on x=-26216..-3347,y=-86509..-61999,z=15569..35567 +on x=-29647..4541,y=-79260..-74726,z=-24757..-765 +on x=55659..78964,y=-24505..-7164,z=-50232..-23993 +on x=33186..47329,y=-83623..-52529,z=-18566..-14780 +on x=-19494..-16198,y=-86579..-54810,z=-38215..-13828 +on x=-76546..-53282,y=-34462..-10121,z=-44888..-32041 +on x=-76316..-55497,y=-37184..-19296,z=-40686..-34695 +on x=59292..86214,y=-56407..-31372,z=-22960..-19065 +on x=-72365..-67554,y=-47426..-36323,z=-24630..-15293 +on x=45022..70193,y=-59475..-54258,z=-30765..-23743 +on x=41797..78262,y=38518..58909,z=29102..40501 +on x=-56173..-29229,y=42418..54919,z=-62619..-46234 +on x=-87493..-66079,y=-30913..-22912,z=-35359..-10198 +on x=-54459..-18453,y=-74700..-68574,z=-33308..-3062 +on x=12702..22913,y=-28283..-2532,z=-95031..-76238 +off x=7054..27897,y=66707..70261,z=33196..40503 +on x=52959..75592,y=12263..28662,z=-46720..-25709 +off x=20528..40031,y=-66596..-43073,z=15112..42322 +on x=-78756..-52026,y=19520..49239,z=11815..30769 +on x=323..12246,y=-3213..11437,z=65779..95160 +off x=-14176..-1843,y=18040..26872,z=72677..90077 +on x=-77765..-56623,y=-13761..16143,z=-60520..-42828 +on x=50935..77862,y=-24138..-8286,z=36010..50708 +off x=1593..14034,y=14491..24583,z=73440..87017 +on x=71271..86742,y=-23454..3639,z=5349..15759 +on x=-69431..-59981,y=-52296..-34442,z=3053..16703 +off x=-86817..-67928,y=-33710..-17374,z=3494..28808 +off x=-21356..-14681,y=-89237..-62105,z=8336..20221 +off x=54980..65519,y=-34329..-25496,z=-46559..-38661 +on x=-20777..5560,y=73217..97355,z=-3463..14669 +off x=44183..72703,y=-29603..-4876,z=-54051..-40336 +off x=37507..47954,y=-66453..-52078,z=-38585..-23749 +on x=18813..33292,y=65277..96011,z=-3332..10096 +off x=-47067..-15563,y=-72831..-60782,z=1530..33668 +off x=-78781..-62514,y=5135..32940,z=3816..22562 +off x=-11282..4321,y=-48863..-30021,z=-76318..-61852 +off x=-32205..-23108,y=-23026..-11571,z=60029..73223 +off x=-21642..1621,y=75046..93823,z=8322..18802 +off x=20210..41514,y=-7361..11731,z=57037..84832 +off x=47514..63665,y=38184..57865,z=-538..35843 +on x=-73078..-56183,y=-27407..-18250,z=27553..47003 +off x=20922..37625,y=52438..83929,z=-32087..-24279 +off x=-46804..-33011,y=56264..74097,z=6080..24715 +off x=58872..82343,y=-25352..-13207,z=36252..56012 +off x=24615..51367,y=-48572..-24179,z=-81552..-49118 +on x=-36397..-18849,y=-64656..-36160,z=49310..60265 +off x=66762..76079,y=20883..40265,z=-43691..-10934 +off x=-15307..-12682,y=-36549..-14354,z=59655..83128 +on x=-31654..4307,y=-93798..-68007,z=-12762..17440 +off x=-18129..2560,y=44527..79901,z=-66519..-41298 +on x=-3033..1584,y=109..12150,z=69190..98590 +off x=4275..15297,y=-83051..-72751,z=-8431..2807 +on x=-36692..-13124,y=-70705..-56494,z=-41174..-23559 +off x=-86559..-74876,y=-17170..16503,z=-20090..-4526 +on x=18331..38992,y=-78018..-42710,z=-37461..-20792 +off x=-66972..-53984,y=-77898..-56514,z=-6661..12936 +on x=45361..54663,y=-50054..-31211,z=-55309..-42521 +on x=-10717..7631,y=-72875..-60074,z=-48011..-39810 +off x=28330..54818,y=35864..69022,z=-49362..-39960 +off x=38388..40491,y=22123..41259,z=44965..73195 +on x=27479..44773,y=46245..57649,z=-52407..-41100 +on x=50232..63275,y=45534..54199,z=9575..38287 +on x=-88116..-66299,y=-4615..12658,z=17279..51020 +off x=58415..81545,y=-35872..-18497,z=27751..39304 +on x=56457..70780,y=41965..58179,z=-1765..26588 +on x=28100..61443,y=-72751..-59880,z=8324..27278 +off x=-53627..-42539,y=-34237..-22781,z=-66241..-35448 +off x=-65967..-34626,y=24741..44412,z=-51922..-32195 +off x=-12004..16017,y=-78874..-59181,z=-34743..-16666 +on x=-31535..-13798,y=-21440..-5279,z=58049..95435 +on x=-10745..-7646,y=73013..92318,z=-22401..507 +off x=-49428..-25617,y=-88235..-66526,z=9619..24784 +off x=-34561..-24729,y=20302..34750,z=59424..71331 +off x=-18248..-3549,y=-85337..-72330,z=-24618..1074 +off x=-32022..-4559,y=-11010..13048,z=59521..97432 +on x=-45803..-7620,y=-58395..-42369,z=-68602..-45531 +on x=-35466..-12438,y=-85005..-72863,z=-9075..13606 +off x=-92828..-61327,y=-26568..2309,z=-27191..-56 +on x=49147..63779,y=-5477..7107,z=47810..56916 +off x=-87093..-77914,y=-15903..-2167,z=-6373..3945 +on x=3806..35509,y=1888..20267,z=64739..78490 +on x=65148..84972,y=11167..36069,z=5619..33280 +off x=68826..85035,y=9206..20968,z=-7383..14949 +off x=-35344..1218,y=-86253..-64623,z=24154..40658 +off x=48675..59085,y=-30940..-17912,z=-62258..-40592 +on x=35827..50277,y=-68484..-48498,z=-39503..-31129 +off x=56986..81199,y=-61081..-30236,z=-23598..-10096 +off x=-30062..-1710,y=39947..72759,z=39211..63670 +on x=35244..60258,y=-16327..4680,z=50900..82444 +off x=64750..80965,y=-20767..-17790,z=-17468..-430 +off x=-34255..-15834,y=-72074..-51772,z=-63304..-27526 +on x=67291..89989,y=-14441..2456,z=-16461..12686 +off x=-62031..-44664,y=27172..46531,z=-50356..-36036 +on x=-42352..-29109,y=-37820..-21673,z=46590..73536 +off x=-57220..-40280,y=47235..59865,z=25999..40464 +on x=-67688..-53014,y=-53775..-41490,z=-40430..-35824 +on x=-2839..19266,y=-43034..-23346,z=-85095..-71162 +on x=29066..56583,y=-59748..-38842,z=42834..53532 +off x=39547..47979,y=28981..48443,z=-66990..-52626 +off x=-22628..-11058,y=-95906..-60154,z=6929..28706 +on x=-28180..-6763,y=30230..56061,z=62404..69162 +off x=-45501..-25436,y=-2684..15217,z=68823..81469 +off x=-8857..21183,y=-5304..19422,z=74822..96633 +off x=-68566..-46365,y=-48851..-26163,z=118..14918 +on x=-56917..-30756,y=-17207..5028,z=-85991..-58732 +on x=28051..38504,y=29657..46055,z=55732..73488 +off x=-80573..-54772,y=-47417..-17065,z=-37321..-19126 +off x=-67484..-55671,y=-26221..-6705,z=-62535..-47290 +on x=660..25619,y=56720..86898,z=-54316..-33949 +off x=-59038..-39683,y=16650..42994,z=-75937..-47113 +off x=-42434..-18426,y=31200..44603,z=-77744..-51336 +off x=60097..69699,y=-45362..-25600,z=-36783..-29315 +off x=-75533..-48807,y=-32020..-19978,z=31833..48099 +on x=61414..92558,y=-12405..16576,z=-32620..-20051 +off x=-80492..-78923,y=-1438..10109,z=-12163..17900 +off x=51060..58740,y=42816..47166,z=20248..40191 +off x=39398..56773,y=-60038..-34885,z=-54488..-32339 +on x=49762..76011,y=32987..49374,z=-31698..-11551 +on x=-27643..-11621,y=61922..66550,z=45424..67348 +off x=-3938..6300,y=-6473..11592,z=76962..95035 +off x=-70245..-53004,y=-23497..-8661,z=42656..70469 +off x=-15204..2309,y=-84674..-63646,z=-36975..-15732 +on x=-7727..31122,y=67511..79840,z=-26021..-5591 +on x=-37222..-36632,y=34359..54786,z=43021..74963 +off x=-72790..-45977,y=13329..45219,z=-50226..-42700 +on x=12220..45917,y=23709..42329,z=-78960..-52233 +on x=-35436..-23191,y=-83387..-48637,z=-54177..-21789 +off x=-74301..-68861,y=-21542..5184,z=26743..39848 +off x=54007..87612,y=-42427..-17787,z=22519..31865 +off x=-95086..-63541,y=-22675..1458,z=17473..41500 +on x=18007..45774,y=-68397..-50246,z=8667..29314 +on x=-41793..-30577,y=-17411..-1265,z=69894..72585 +on x=41433..56527,y=-54376..-36519,z=-52889..-40983 +on x=-11500..-78,y=40180..61186,z=-81664..-45731 +on x=-65544..-48667,y=-24104..5308,z=54554..68433 +on x=44209..70762,y=20905..41816,z=33024..63812 +on x=53133..85281,y=-21102..-5066,z=-46889..-18833 +on x=-18070..-13737,y=58667..82151,z=24584..43391 +on x=-63685..-52234,y=38732..66930,z=-3655..11068 +on x=-90660..-56723,y=24101..38891,z=-5307..25402 +off x=46702..70370,y=-57164..-50591,z=-34744..-16325 +off x=-67551..-46253,y=17615..46836,z=-37774..-13495 +on x=70090..71598,y=-43180..-25981,z=21084..30329 +off x=14121..48489,y=57332..76347,z=-14329..5860 +off x=-3516..6136,y=-82216..-60572,z=7996..44718 +on x=34442..43624,y=38885..54235,z=-77157..-43622 +on x=-66656..-45343,y=-15288..3040,z=-55681..-31071 +on x=-20309..-10058,y=61474..83236,z=-21661..-5936 +off x=4848..14762,y=-95496..-61087,z=-9399..19336 +on x=59628..90582,y=-25028..-3009,z=-15123..-8028 +on x=56065..75349,y=-22245..5901,z=-65079..-34051 +off x=57581..79672,y=-45926..-39493,z=11373..13541 +off x=4187..11918,y=46349..70559,z=37358..61355 +off x=13262..28539,y=65574..92988,z=-26082..-17818 +on x=-35893..1170,y=-44286..-6774,z=73473..87395 +off x=-73637..-67636,y=19021..36537,z=19531..36011 +on x=-1842..20477,y=21669..53126,z=53790..89855 +on x=-68487..-37609,y=-31930..-18139,z=-62317..-53654 +on x=-41992..-9321,y=2549..31903,z=64001..78105 +off x=22467..40083,y=-10224..-3360,z=61807..90785 +off x=-21327..-14589,y=45825..83487,z=-58718..-36033 +on x=-77771..-52616,y=-28956..-2833,z=-51394..-39290 +off x=-58765..-42787,y=-54161..-38420,z=24750..40823 +on x=32125..35883,y=-66122..-38289,z=26786..47313 +off x=30267..44070,y=-71924..-67551,z=11946..27975 +on x=77582..85395,y=-12486..8133,z=-35008..-1182 +on x=13342..31948,y=60665..67742,z=-57712..-28123 +off x=9899..38376,y=-72489..-50788,z=40170..67790 +off x=-2795..3501,y=76842..98820,z=-7432..17079 +off x=33136..63810,y=-78409..-46298,z=-14556..-6880 +off x=58187..78115,y=-44130..-13319,z=-10842..10027 +on x=23776..45371,y=-16445..-3582,z=47889..69598 +on x=-87660..-69495,y=21058..45734,z=9587..27948 +on x=-33753..-13903,y=-21521..8779,z=65042..90556 +on x=73615..91630,y=-19383..-8611,z=-15301..-10920 +on x=-54203..-28329,y=48671..74834,z=-19169..-13915 +off x=-47215..-12746,y=-78967..-60390,z=-1516..14027 +on x=-65007..-48840,y=-50827..-19791,z=24089..46349 +off x=43646..77506,y=41120..55361,z=-16014..-4240 +on x=-36230..-30371,y=19235..54348,z=-80174..-50850 +off x=-69746..-46708,y=31174..54666,z=13591..34005 +off x=27883..59279,y=57074..83682,z=-15506..12590 +on x=-31952..-18915,y=47921..75628,z=-59409..-31018 +off x=26259..47607,y=57959..73903,z=6516..25701 +off x=60908..78447,y=11252..32896,z=-53139..-29808 +off x=-29388..756,y=-71581..-61759,z=16204..37374 +on x=-72714..-46178,y=-67776..-49108,z=-5431..24449 +off x=1435..35506,y=-90177..-61926,z=-31482..5218 +on x=4513..21849,y=-61358..-32110,z=-79088..-55059 +on x=-35991..-10608,y=-53212..-41429,z=-71229..-40569 +on x=23875..52847,y=3920..40434,z=59145..67811 +off x=-46129..-34298,y=26595..43113,z=50212..83144 +off x=-66650..-47500,y=37985..57288,z=-41375..-30253 +off x=42083..56150,y=-78443..-57880,z=-12105..2930 +on x=1396..30162,y=-68442..-67058,z=-46276..-25177 +off x=-61820..-53469,y=40646..71400,z=-18749..7431 +on x=36365..49950,y=-70986..-41449,z=16562..51419 +on x=-81184..-49323,y=-37126..-9145,z=-50053..-26865 +off x=-27521..9480,y=57086..78851,z=12700..33741 +off x=-36998..-25958,y=20150..38820,z=-75171..-50044 +off x=-65568..-33040,y=-77000..-53566,z=-22765..1692 +on x=9847..21008,y=-56999..-47983,z=-56650..-43343 +on x=50568..74184,y=-4362..14928,z=-71479..-53525 +on x=-36329..-5096,y=44560..65115,z=-54305..-33241 +off x=-75160..-42831,y=-24270..-16485,z=-67811..-44645 +off x=62487..84040,y=-14505..5440,z=21999..42422 +on x=36461..59980,y=-51429..-41504,z=23630..50041 +off x=-22347..-7005,y=26671..54757,z=46230..77654 +off x=53477..72667,y=33746..60701,z=6701..28483 +on x=-31773..-13781,y=-19618..-1712,z=-77615..-74333 +off x=-64140..-45853,y=-31826..-13716,z=51353..61995 +off x=46127..79912,y=50383..66947,z=-15727..-2760 +off x=-7939..4574,y=-85911..-62241,z=-14750..984 \ No newline at end of file diff --git a/src/day22/day22Test.txt b/src/day22/day22Test.txt new file mode 100644 index 0000000..4d036d6 --- /dev/null +++ b/src/day22/day22Test.txt @@ -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 diff --git a/src/day22/day22Test2.txt b/src/day22/day22Test2.txt new file mode 100644 index 0000000..8c68bc7 --- /dev/null +++ b/src/day22/day22Test2.txt @@ -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 diff --git a/src/day22/day22Test3.txt b/src/day22/day22Test3.txt new file mode 100644 index 0000000..2790bed --- /dev/null +++ b/src/day22/day22Test3.txt @@ -0,0 +1,60 @@ +on x=-5..47,y=-31..22,z=-19..33 +on x=-44..5,y=-27..21,z=-14..35 +on x=-49..-1,y=-11..42,z=-10..38 +on x=-20..34,y=-40..6,z=-44..1 +off x=26..39,y=40..50,z=-2..11 +on x=-41..5,y=-41..6,z=-36..8 +off x=-43..-33,y=-45..-28,z=7..25 +on x=-33..15,y=-32..19,z=-34..11 +off x=35..47,y=-46..-34,z=-11..5 +on x=-14..36,y=-6..44,z=-16..29 +on x=-57795..-6158,y=29564..72030,z=20435..90618 +on x=36731..105352,y=-21140..28532,z=16094..90401 +on x=30999..107136,y=-53464..15513,z=8553..71215 +on x=13528..83982,y=-99403..-27377,z=-24141..23996 +on x=-72682..-12347,y=18159..111354,z=7391..80950 +on x=-1060..80757,y=-65301..-20884,z=-103788..-16709 +on x=-83015..-9461,y=-72160..-8347,z=-81239..-26856 +on x=-52752..22273,y=-49450..9096,z=54442..119054 +on x=-29982..40483,y=-108474..-28371,z=-24328..38471 +on x=-4958..62750,y=40422..118853,z=-7672..65583 +on x=55694..108686,y=-43367..46958,z=-26781..48729 +on x=-98497..-18186,y=-63569..3412,z=1232..88485 +on x=-726..56291,y=-62629..13224,z=18033..85226 +on x=-110886..-34664,y=-81338..-8658,z=8914..63723 +on x=-55829..24974,y=-16897..54165,z=-121762..-28058 +on x=-65152..-11147,y=22489..91432,z=-58782..1780 +on x=-120100..-32970,y=-46592..27473,z=-11695..61039 +on x=-18631..37533,y=-124565..-50804,z=-35667..28308 +on x=-57817..18248,y=49321..117703,z=5745..55881 +on x=14781..98692,y=-1341..70827,z=15753..70151 +on x=-34419..55919,y=-19626..40991,z=39015..114138 +on x=-60785..11593,y=-56135..2999,z=-95368..-26915 +on x=-32178..58085,y=17647..101866,z=-91405..-8878 +on x=-53655..12091,y=50097..105568,z=-75335..-4862 +on x=-111166..-40997,y=-71714..2688,z=5609..50954 +on x=-16602..70118,y=-98693..-44401,z=5197..76897 +on x=16383..101554,y=4615..83635,z=-44907..18747 +off x=-95822..-15171,y=-19987..48940,z=10804..104439 +on x=-89813..-14614,y=16069..88491,z=-3297..45228 +on x=41075..99376,y=-20427..49978,z=-52012..13762 +on x=-21330..50085,y=-17944..62733,z=-112280..-30197 +on x=-16478..35915,y=36008..118594,z=-7885..47086 +off x=-98156..-27851,y=-49952..43171,z=-99005..-8456 +off x=2032..69770,y=-71013..4824,z=7471..94418 +on x=43670..120875,y=-42068..12382,z=-24787..38892 +off x=37514..111226,y=-45862..25743,z=-16714..54663 +off x=25699..97951,y=-30668..59918,z=-15349..69697 +off x=-44271..17935,y=-9516..60759,z=49131..112598 +on x=-61695..-5813,y=40978..94975,z=8655..80240 +off x=-101086..-9439,y=-7088..67543,z=33935..83858 +off x=18020..114017,y=-48931..32606,z=21474..89843 +off x=-77139..10506,y=-89994..-18797,z=-80..59318 +off x=8476..79288,y=-75520..11602,z=-96624..-24783 +on x=-47488..-1262,y=24338..100707,z=16292..72967 +off x=-84341..13987,y=2429..92914,z=-90671..-1318 +off x=-37810..49457,y=-71013..-7894,z=-105357..-13188 +off x=-27365..46395,y=31009..98017,z=15428..76570 +off x=-70369..-16548,y=22648..78696,z=-1892..86821 +on x=-53470..21291,y=-120233..-33476,z=-44150..38147 +off x=-93533..-4276,y=-16170..68771,z=-104985..-24507 \ No newline at end of file