From e9a6c5178acf8f028130771c9755fb15cf64805f Mon Sep 17 00:00:00 2001 From: Alan R Evans Date: Fri, 15 Dec 2023 16:07:58 +0000 Subject: [PATCH] day 12,13 --- 2023/go/day12/day12.go | 136 ++++ 2023/go/day12/day12_test.go | 29 + 2023/go/day12/input.txt | 1000 +++++++++++++++++++++++++ 2023/go/day13/day13.go | 144 ++++ 2023/go/day13/day13_test.go | 47 ++ 2023/go/day13/input.txt | 1377 +++++++++++++++++++++++++++++++++++ 2023/go/main.go | 10 +- 7 files changed, 2742 insertions(+), 1 deletion(-) create mode 100644 2023/go/day12/day12.go create mode 100644 2023/go/day12/day12_test.go create mode 100644 2023/go/day12/input.txt create mode 100644 2023/go/day13/day13.go create mode 100644 2023/go/day13/day13_test.go create mode 100644 2023/go/day13/input.txt diff --git a/2023/go/day12/day12.go b/2023/go/day12/day12.go new file mode 100644 index 0000000..58f9648 --- /dev/null +++ b/2023/go/day12/day12.go @@ -0,0 +1,136 @@ +package day12 + +import ( + "fmt" + "strings" + + "adventofcode2023/utils" + "adventofcode2023/utils/inputs" +) + +var cache = make(map[string]int) + +type memoized struct { + f func(int) int + cache map[string]int + } + +func Part1(input string) int { + ans := 0 + lines := strings.Split(input, "\n") + for _, line := range lines { + slices := strings.Split(line, " ") + record := slices[0] + groups := inputs.ToInts(slices[1], ",") + ans += calc(record, groups) + } + return ans +} + +func Part2(input string) int { + ans := 0 + lines := strings.Split(input, "\n") + for i, line := range lines { + slices := strings.Split(line, " ") + record := slices[0] + "?" + slices[0] + "?" + slices[0] + "?" + slices[0] + "?" + slices[0] + groups := inputs.ToInts(slices[1] + "," + slices[1] + "," + slices[1] + "," + slices[1] + "," + slices[1] , ",") + ans += calc(record, groups) + fmt.Printf("running total after lines %v = %v\n",i, ans) + } + return ans +} + +func calc(record string, groups []int) int { + key := record + fmt.Sprint(groups) + if v, ok := cache[key]; ok { + return v + } + // ADD LOGIC HERE ... Base-case logic will go here + // Did we run out of groups? We might still be valid + if len(groups) == 0 { + // Make sure there aren't any more damaged springs, if so, we're valid + if ! strings.Contains(record, "#") { + cache[key] = 1 + return 1 + } else { + // Not valid to runout of groups and still have damaged springs "#" + cache[key] = 0 + return 0 + } + } + + if len(record) == 0 { + // Already know there are more groups but no records + cache[key] = 0 + return 0 + } + + // Look at the next element in each record and group + next_character := record[0] + next_group := groups[0] + out := 0 + + if next_character == '#' { + // Test pound logic + out = pound(record, groups, next_group) + } else if next_character == '.' { + // Test dot logic + out = dot(record, groups) + } else if next_character == '?' { + // This character could be either character, so we'll explore both + //possibilities + out = dot(record, groups) + pound(record, groups, next_group) + } else { + utils.PanicOnErr(fmt.Errorf("RuntimeError")) + + } + // Help with debugging + // fmt.Println(record, groups, out) + cache[key] = out + return out +} + +// Logic that treats the first character as pound-sign "#" +func pound(record string, groups []int, next_group int) int { + + // If the first is a pound, then the first n characters must be + // able to be treated as a pound, where n is the first group number + if next_group > len(record) { + return 0 + } + this_group := record[:next_group] + this_group = strings.Replace(this_group, "?", "#", -1) + + // If the next group can't fit all the damaged springs, then abort + if this_group != strings.Repeat("#", next_group) { + return 0 + } + + // If the rest of the record is just the last group, then we're + // done and there's only one possibility + if len(record) == next_group { + // Make sure this is the last group + if len(groups) == 1 { + //We are valid + return 1 + } else { + // There's more groups, we can't make it work + return 0 + } + } + + // Make sure the character that follows this group can be a seperator + if record[next_group] == '?' || record[next_group] == '.' { + // It can be seperator, so skip it and reduce to the next group + return calc(record[next_group+1:], groups[1:]) + } + // Can't be handled, there are no possibilites + return 0 +} + +// Logic that treats the first character as dot "." +func dot(record string, groups []int) int { + // ADD LOGIC HERE ... need to process this character and call + // We just skip over the dot looking for the next pound + return calc(record[1:], groups) +} \ No newline at end of file diff --git a/2023/go/day12/day12_test.go b/2023/go/day12/day12_test.go new file mode 100644 index 0000000..3fd5dc0 --- /dev/null +++ b/2023/go/day12/day12_test.go @@ -0,0 +1,29 @@ +package day12 + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestPart1(t *testing.T) { + r := Part1( +`???.### 1,1,3 +.??..??...?##. 1,1,3 +?#?#?#?#?#?#?#? 1,3,1,6 +????.#...#... 4,1,1 +????.######..#####. 1,6,5 +?###???????? 3,2,1`) + require.Equal(t, 21, r) +} + +func TestPart2(t *testing.T) { + r := Part2( +`???.### 1,1,3 +.??..??...?##. 1,1,3 +?#?#?#?#?#?#?#? 1,3,1,6 +????.#...#... 4,1,1 +????.######..#####. 1,6,5 +?###???????? 3,2,1`) + require.Equal(t, 525152, r) +} diff --git a/2023/go/day12/input.txt b/2023/go/day12/input.txt new file mode 100644 index 0000000..d0daee0 --- /dev/null +++ b/2023/go/day12/input.txt @@ -0,0 +1,1000 @@ +.#?.##??.?? 2,2,1 +?.#?#?????.? 1,1,3 +??##??????????.?# 4,4,2 +..#?????.?#?.#?. 2,2,1,2 +????????????##?? 1,1,1,1,3 +?????.#????#??? 1,1,3,2,1 +.?#..?#?????#?? 1,2,5 +?#??????????????.? 4,1,2,2,1 +#??##?.#??. 1,2,3 +???????#??????#.?? 13,1 +?#..#??.?#.? 2,1,1,2 +?.###??????#???.?.?? 11,1 +.?????????#???. 3,7 +?????.#??????#.? 1,1,5,2 +?#???????? 4,4 +?.??.#.????#??#??? 1,1,1,4,1,1 +??.?????.#?.?#?????. 1,3,1,2,3,3 +.???#?????.?? 4,1,1,1 +??#??.#??.?? 3,2,2 +.???.?###. 1,4 +#.???##?#? 1,6 +#.??????#?.??. 1,5,1 +.??#???#?#????????? 3,8,2 +??.?????????.?.??# 1,5,1,1,1,1 +????????????#? 1,4,4 +?????????#??. 2,5 +?.?#?.?.??? 2,1,1 +?.?.??.??#???##?? 1,1,2,1,3 +.?#?.#????.. 2,1,2 +#??#??##?.#??? 1,2,2,1 +??.##?#?#???..? 1,4,4,1 +????.##?.? 1,3,1 +#???????#??#? 1,2,1,4 +??????????? 1,2,1 +#???.??##?? 1,2,3 +##?#?#?.??. 7,1 +?.?###????????? 4,7 +.?#??###???#?????? 12,2 +.#.???#????#. 1,6 +??.#???.#??#???##?? 1,1,1,1,6,1 +??#?.?#??? 3,4 +????????#.?. 2,2,2 +??.??????.??????#? 1,3,4,2 +.#??#???.?.???#??? 6,1,1,1,1 +?????????#??????#? 1,1,1,4,1,1 +???...?#??????????? 3,12 +????..?????? 2,1,2 +???.??.???? 1,1,2 +#..?###????????# 1,6,6 +.#?#.???#???##??#??? 1,1,1,1,10 +?.?#?#.????##.##.??? 3,6,2,1 +???????#?#????.?..# 4,9,1,1 +#??#??????????#.???? 1,2,1,7,1,2 +?#??????????????? 1,1,11 +???????#?#? 1,5 +.##?????????.## 4,3,2 +?#?????##??#.????## 1,1,1,3,1,6 +.????#.??..?#?.# 3,1,1,3,1 +?##????????????#?#?? 9,1,4 +.?????#.???.. 6,2 +?.??.#??.#?. 1,3,2 +#?.??.?#??# 2,1,5 +??#?#.????#??#.???.? 3,1,3,1,3 +.?#?#?#?.??.????? 6,1 +#?..??#??? 2,1 +#??#?????.##?# 2,5,4 +?.??..#.????? 1,1,1,2 +??????.?.?#? 1,1,1,2 +.???.?????.?????? 1,2,1,5 +?#...#???#? 2,1,1 +???.?????????#?#?? 2,4,1,6 +.#???##??????. 6,1,2 +#?????#???#?#?????.# 1,6,6,1,1 +.?#???##??.?.?#?? 7,1,1,1,1 +?#?...?##??.? 3,5 +#??#?????????..?##. 4,1,1,1,1,2 +?####?.?.??#?? 4,2 +#??##.?##???#?####?? 5,3,7 +??.?#????#??.??.??? 1,3,4,1,1,1 +.?.?#?##?.?##?????. 2,3,3,3 +???.?????#?#???.# 1,3,5,1,1 +???##?.??#.???#??#? 3,3,6 +.?#?????????.?#??? 2,1,2,3,1 +???...???? 1,3 +##?#?#?..?? 7,1 +????.?#.???# 3,1,2 +?????????##???.???#? 1,1,1,5,1,3 +?.#??????#?????. 1,2,2,4 +????.#???#? 4,2,2 +?????#????#?#??##?# 4,6,4 +#???.???###?#????? 1,1,1,7,2 +?.?#?#????##??#.?? 1,1,1,1,5,1 +?.????.?.???#? 1,1 +??##????????? 3,2,1 +???.?.??#???#? 1,6 +???#?#??#???.?.# 7,1,1,1,1 +.?.???#?##?? 1,5 +??#????#??????#? 8,3 +?#????#.?????#?#. 1,4,6 +???#.?#??#? 2,5 +??????????.??????# 4,2,7 +???#???...?? 1,2,1,1 +????.???????##?? 1,1,1,1,5 +.?##??.##? 2,1,2 +.???##??##??# 1,2,3,1 +????#?????##????? 1,10,3 +??#???.?.?##?..#??? 1,2,1,4,1,1 +???#?#???? 3,2 +.?.#???#????????? 1,9 +?#????##???#?????.# 3,7,3,1 +#.??##??????#????? 1,5,1,1,1 +?????.???????#?? 3,1,5,1 +#??????.##??????. 3,3,5,1 +.???????.? 1,1,1 +??#?#??##??#?.????# 11,3 +.?.?##.??##?.?#?#?#? 2,3,6 +#?????#?.??#??? 2,4,4,1 +.#???????#???? 1,2,6 +####?#?.#?????#?# 7,1,1,2,1 +??#?.?.??? 2,2 +?.??.??#????? 1,4,1 +?..????#?????##? 4,1,2 +#...????.?#?#??.?? 1,4,1,1,1,1 +????.????? 3,3,1 +#?.?##?????#?#? 2,3,1,1 +??????#?#?????## 2,12 +?.???#???.??#? 7,1 +#?#..??.#??#???#?.?? 1,1,2,1,6,2 +??#?...#.???#???.?? 1,2,1,1,4,1 +?.?..???.?. 1,1,1 +?.????..?.??#??? 2,3 +.??##??????.????? 10,1 +..?????###??? 1,4 +??????#???. 2,1,4 +????##.??.??#?????? 6,1,1,4,2 +??????????##?#?#?# 1,1,13 +???.??###?#?????#. 1,9,1 +?#??.????#?.?.?? 3,5,1 +???????????.??.???? 1,4,2,1,1 +??.##??.#... 1,4,1 +?.?#?#??#?.??##????? 7,6 +??.????#?#??#.?.? 1,8 +????#??#???? 4,4 +?..??????#?????. 1,9 +?????????.?##????? 4,1,5,1 +.?.#??.?#.#?? 1,1,2,2 +?.?##?????#.#?#? 9,1,1 +?#???#?????? 1,3,2 +..??#?.?????#??????. 2,11 +???#??????? 4,1 +???#??#????#?# 11,1 +?.?#?#?????#?.?#..? 1,6,3,2 +??.??#?#???.??.#?? 6,1 +?##.???????? 3,1,1,1 +???##?.??? 2,1 +#?.?.?#?#????. 1,1,5,1 +?.????#????? 1,1,4,1 +???#????.??? 1,1,2,1 +#.????..?.?.???#?? 1,1,1,1,1,6 +???##??.?#??#????#? 6,9 +???.#.??.???#??# 1,1,2,6 +????..?#?#?.##?#???. 3,5,2,4 +??#???#?#..???##? 7,3 +?#?##?.???.???? 5,1 +??.?#????#?#?.?#? 1,3,1,4,1 +.?.????.????##?? 1,2,1,1,6 +??????###. 1,1,3 +#?????.???. 3,1,1 +#?#..#????#???#?. 3,7,1 +?.?#??#?.???.?###. 1,3,1,1,1,3 +.#???.?.#?? 1,2,2 +.#?#??#?#??#?.?????? 12,1,2 +????#?????#?? 1,8,1 +..??????#?. 4,1 +##?#????#?#??????#?? 2,2,2,3,3 +?????#???#.#.. 4,2,1 +???##??..????..?#?# 5,3,4 +?#?#???#??..??## 8,4 +.?.???#???? 1,4 +???#?#??#.???.# 7,1,1,1 +..?.????????#??? 1,8 +?????.?##???????. 1,1,8,1 +?????.?????.???? 5,2,3 +???????????..?#??.?? 4,5,4,1 +?#?#???.???#???. 1,2,1,1,1 +.??.#?????.?? 2,3,1 +??..??#??.????. 1,1,3,3 +#??#.?.?.????????? 1,1,1,5,1 +??#????.??#. 1,2,2 +???#??????.?#.?? 1,2,1,2,1 +???#??.??????? 4,2,1 +??????.?#?##?????#?# 1,1,12 +??????.??.?#???.# 6,1,2,1,1 +??.?.????##?? 1,2,4 +????.?????#?#???#? 3,11 +.#????????.?.#?#??? 2,1,1,1,6 +??#????#?????????? 8,4 +??.?..?.?#???#????? 1,1,1,4,1,1 +?.????.###??#? 2,6 +??.#??????.?? 1,6,1 +.?.?.????#???? 1,6 +..??????.#?.?.? 5,2,1 +????.???.?? 4,2,1 +???###????#????##. 1,6,8 +.#??#???????? 1,8,1 +?#?##????.?? 5,1,1 +??####?####?????. 5,4,1,1 +?#??.?##?#???? 1,4,2 +#?????.#??????.# 4,1,3,1,1 +??#??#?????##.#? 8,2,2 +????##??..??#? 1,5,2 +?.#?##?..?#???. 4,3,1 +.?.?#???.????. 1,4,1,1 +??##..?... 3,1 +????#???##??#??# 1,12 +????#?#?.##??#??. 1,2,2,2,3 +.#?##?????#????????. 11,1,1 +?#??.???.#.?#.? 4,3,1,1 +??#?##???#. 7,1 +?.??#????#??.???.? 1,2,1,4,1,1 +.???##??.?.?????#?.# 4,1,2,4,1 +.?#???#??.##?####?. 2,1,1,8 +..???..??#??.? 1,4 +?##???????#??#?? 5,8 +????#?.??#?# 1,1,3,1 +??.?.??#.?.##.# 2,1,3,2,1 +???#???#??#????? 1,1,1,6,2 +#.???##.?.????#.? 1,5,5,1 +??????????#?#?#?#.. 1,1,7,1,1 +????..???? 4,2,1 +??????##??#??? 1,1,2,3 +#????#????# 1,5,2 +?????#???????#??? 1,14 +?#???.???? 1,2 +??#?##??.??????????? 7,1,1,1,1 +?.?#??#???#????.??? 2,3,5,1 +????##??##??.?#.# 1,9,2,1 +???????#?. 1,1,2 +#???###..?.???#? 2,4,1,1,1 +??????????? 1,1,6 +??#.?#?????.#??? 1,1,2,1,2 +#.??#???#.?#??#??#. 1,5,1,1,1,1 +??????????? 1,1 +??#.?#?????## 1,1,1,2 +???##?#?#?#? 1,5,1,1 +????##??#??? 1,1,7 +#????#.?????. 6,3 +?.?#???#?.# 7,1 +????.?#?????#?.? 2,2,3,2,1 +.?.#???#?.. 1,6 +.??#????.?????.## 3,4,2 +??.##??##??...?? 7,2 +##???.##???#??# 2,1,3,2,1 +?###?#??##?.?#???##? 10,3,3 +??#??????????###.? 15,1 +???###.????.# 1,4,3,1 +??.???????#?#?#?? 2,2,4,4 +????.??###?#?.? 2,7,1 +?.#?#????.????????. 1,4,1,1,3,1 +.??.?#?#??#.?#.??. 2,6,1,1 +????#.?.??.?. 1,2,1,1 +.??#???#?#??????? 6,8 +?????.??#?#?#??? 1,1,5,1 +??#?.#?#??#.#??????? 3,6,4 +????#????????#??.?? 1,1,2,1,7,1 +???????#?# 2,1,4 +??.???????#???#?? 2,2,5,1 +?#??..??????? 2,5 +?#???#?.???..#? 5,1,1 +??##.??.?#????.#?? 3,1,1,2,2 +#.??#?????.?.??????# 1,8,2,2,1 +?????.??.?.???.??? 1,1,1,1,1,3 +????#?.?????# 1,3,1,2 +????#???????#?#?? 5,9 +??#???.?#????#??#?.? 5,4,5,1 +##?..??#??..#?# 2,4,3 +?????.#?#?? 1,1,4 +..#?##????????.?#?? 4,2,1,4 +#?#?.??#?. 1,2,4 +????.?????????? 1,2,1 +??#??#???#?.? 1,1,1,4 +????#.????##?? 3,4 +???.???.?.?? 3,1,1 +?????.#???#?? 3,7 +.???#??.??.???? 3,2,1 +?????????##???#? 1,1,1,3,3 +?###??.??? 3,1,1 +#?????.?????.??? 4,4 +??#?.?#???#? 3,3,3 +???#???#??#??# 4,1,4 +??###.?.???#? 4,5 +.????????.?????.???. 1,2,3,3,2 +#.#??#?#??#?#?? 1,2,3,5 +???#?#??#????#????# 1,8,6 +?.??#??##??.??????. 8,1,1,1 +????##.?????#??#?? 4,6,3 +.???.????#?##??? 1,10 +?.?????.????????.? 2,1 +?#..??.?#.? 1,2 +??#????.??#?#???. 1,1,2,6 +???#??????????? 9,1 +#.#??????.#??????? 1,1,1,2,8 +???.?????..# 1,1,1,1 +.?###????. 3,1 +#.?????.?#?##??#???? 1,2,1,11 +????.??#???##.????#? 1,1,8,1,2 +#####.#??? 5,2 +??.???##??? 6,1 +???#?##?#??#??#.???. 15,2 +?#??.?.#?.#.?????? 3,1,1,1,1,1 +????.??##?#..? 3,2,1,1 +#???.??????#.?????# 2,1,7,2 +#???.??.???? 3,1,1,1 +.#???.????.#?? 1,1,3,3 +..??#??.#.?????.?.# 4,1,5,1 +???#####????????? 1,6,1,1 +???????.??????? 1,2,2,6 +?#.?.#???##? 2,1,2,2 +?#???#??????? 7,4 +.?#?#?.?.?### 1,1,1,3 +????.??????? 1,6 +?#?#???##????????. 8,5 +?#???#?.???#??????. 4,2,3,2 +???.??##??##????.??? 3,4,3,2 +..?#?#???#.?. 5,1 +???#?????#????##?# 3,2,7,1 +????????##?#? 2,7 +??????#.?..? 3,1,1 +..#??????#????## 2,5,2 +??##?.??.??? 2,1,3 +??#????????#?? 3,1,5 +?##?.##???????#??#.. 2,10,1 +?.?#????????.?#. 1,3,2,1,1 +.???#?????? 5,1 +???????#??#.????. 4,1,4,1,1 +.?.?#.?.#. 2,1 +?#.?.??.???? 1,1,3 +#?#??????.?# 1,2,1,1 +#?#.#.???????#???? 1,1,1,1,1,6 +?????.??#??..??? 3,4 +???????????#..? 3,2 +?#?.???.??#.?? 2,3,2 +??##????.??? 7,2 +????#??### 1,7 +.???????#?.?????###? 7,8 +???.???#?.#???????? 2,2,1,2,5 +.???????##??????# 3,5,1,1 +??#????#???#???##? 6,1,1,6 +?#?.?.??###??. 3,1,6 +????..?#?#?????? 2,9 +??.??...?##?###.? 2,7 +???#????###???? 2,1,7 +.????#.???? 2,1,1 +???.???##.#?##?#?? 1,1,2,1,6 +???#?#???#? 4,2 +?.#??????? 1,1,2 +.?.?.#?..# 1,2,1 +?.#.???????. 1,5 +?.#.?.#?##????? 1,1,4,2 +???????????#?? 4,1,4 +#?##????#??? 6,3 +?.????#?#???? 1,5,1 +??????#?#?. 7,1 +?#??.?.??###?????? 2,5,3,1 +##?????##????? 2,7,2 +#??#?..?##??.???#? 5,3,1,1 +.#?.?####???? 1,5,2 +???..?#?.? 1,1,1 +#??.???#?###??? 1,1,1,8 +?.?.?##????#..?#.?.? 1,1,8,2,1,1 +????.??????#? 1,2,1,1 +#?..?#??????.??? 1,6,2 +??#?.?####?? 3,6 +#.???????. 1,1,1 +#???????.?.???? 1,4,1,3 +???#??#??? 5,2 +?????.?????#???. 1,1,5,2 +##??#?#?.#?????#?. 7,1,2,1 +?????#?#.?????#??#?? 5,1,2,5 +?.##.???##?#???? 2,5 +#????.#???.??.?????? 1,3,4,1,1,2 +??#?#??#?.???##? 1,1,5,1,3 +?.?????.??. 2,1,1 +.??.?#??????#? 1,1,3,2 +??#??.????.? 4,1 +??.????#?.? 1,2,1 +#??#?.??#??? 1,2,1,2 +??.?##?.????? 3,4 +?.????#??.#????#??# 1,2,3,1,4,1 +?.#?..???#.?. 2,4,1 +?#???#??.#??#? 2,3,1,1 +?.???##???..#??#. 7,4 +#??#.?#??.????? 2,1,1,3 +?#?##????.? 7,1 +.??????#???##?? 4,7 +.?#??#?????..??? 6,1 +??#??#????#####???.? 6,6 +.????##.#?.???????. 6,2,4 +???.##?#??.?.##???.? 5,3 +..?..?#??..#?# 1,2,3 +##.?.??..?? 2,1,1 +???##????.?? 4,1,1 +.??##.???? 4,1 +??..???#??.????..?? 2,6,3,2 +?#??#??#?## 4,5 +??????.?#..??. 3,1,1,1 +??#?#??#??.???# 8,1,1,1 +.?#?.??#?.#.?#? 2,1,1,1,1 +?.?..??????#??. 1,6 +?.?.????????????? 1,7,1 +#??#????#.??????## 4,1,1,8 +?#.??#.#??#???#?#? 1,1,1,1,1,6 +???.????#????#?#.#? 2,1,2,4,1 +.?#?.???#? 2,1,1 +##????????? 3,4 +?#????#?#??#?#?#.? 2,4,6,1 +?????????##? 1,9 +?..#.#??#????#?#?? 1,4,5,1 +#??#?????? 4,4 +#.?.#??#?#???????##? 1,1,7,1,2 +????##?.?#..? 1,4,1 +????????#?. 2,2,1 +??.????.?#??.?#?? 1,2,4,1,1 +.??????.??##?# 1,1,5 +???#?#?.#??.#???? 7,3,2 +??.??#?.?. 2,1,1 +.#..????.? 1,1 +.???##????#??#? 1,2,6 +?..???#??#?? 1,1,5 +?#.??????#??#? 1,1,1,5 +#?.???.#?.?##?.#??#? 1,2,2,4,5 +??.?#???## 1,1,3 +?????.?.#????.?. 3,5,1 +?#?.???#?#?#.???# 2,7,1 +??.?..??..????....?. 2,2 +???#??##?.??? 7,1 +???#????.??????.???# 8,1,1,2,1,1 +??#????????#?#??.? 5,4 +####????????.?.??? 5,5,1,1,1 +????#?.????###?#. 3,7 +.??????????? 1,1,1,1 +##?????.##?? 2,1,3 +????????#?#?? 2,4 +??.#?.??#.??#??##?#? 1,2,3,9 +#??#?#?#??##???.??.? 4,1,6,1,1 +.?#..?##???? 2,4,2 +???.???##?? 2,6 +##???..?#? 4,2 +?.????#??.#.??#??? 1,2,1,4,1 +?##?#.???? 2,1,1 +?.?#????.?##??#??#?? 2,1,3,6 +#?????.?#?? 3,2,3 +.??#?????###??.?##?? 1,6,4 +??#.?#?.?##????? 1,1,1,3,1 +.??#??#?#?#???#.#? 12,2 +?.??.#?#?????.???#. 1,8,2,1 +#?..??#??? 1,1,4 +?.????..???#????? 1,2,1,5 +.???#???#####?? 4,7 +?.#????#??? 3,1 +????#???#???????.# 1,9,1,1,1 +??.???.?####. 1,4 +??.#???.?#?????. 1,1,1,4,1 +??.#????????..? 5,1 +.??#?????????.???. 1,2,5,1,1 +#??.###..? 1,3,1 +????#.?#??.??? 3,1,3,2 +###??????. 4,4 +.????#??#? 1,4 +?.#????????#???#?? 1,5,1,2,1,1 +?.???.???##? 1,1,3 +?????#??#??.??#? 2,3,1,3 +.???.?#???#????# 1,6,1,1 +?#???.???#?? 1,1,4 +?#????.???# 2,1,4 +??#?.?#????.?. 1,4 +?????#?????.???????. 6,3 +??#?#?????#.? 1,3,1,1 +??###..????.??#?#. 1,3,1,1,5 +??.??#??#. 1,2,1 +?????????????#?? 6,1,2 +?????##??????.#? 3,2,2,1,1 +.???????##?#..??#?. 5,4,3 +.#..????.??##?????.# 1,3,8,1 +?#?.???.#???? 3,1,2,1 +??????.??#??.#???. 2,1,2,1,1 +.??#?.?#?? 3,2 +#???.?..?..???##? 2,1,1,6 +?#.#.??????#? 1,1,6 +??.?????.?...???#? 1,4 +.?.???#...??##?.. 3,4 +..?###..???#??.???? 4,2,1,1,1 +..???.????## 1,1,5 +..?#?????? 2,2 +.???????????? 2,1 +#??#????#??????? 5,5,1 +???#??.????#?#.?#??? 5,1,5,2,1 +?#?#??????#??##?.??. 6,8 +?.#?#.?.?????? 1,1,5 +.#???#?#??????.????# 1,3,1,3,1,1 +.??????#??????#.?? 2,5 +..#.??????#???? 1,1,1,3,1 +.#.??#????.? 1,1,1,1 +?#?#????#????.?#? 1,2,3,1,3 +??.#?????.?.?? 1,1,3,1 +?.#??????? 1,5 +??#.??????##??#??? 1,5,7 +.???????#????##.??. 14,1 +????###???.?.????# 2,6,1,1,3 +?#?#?.????.##. 4,1,1,2 +?#????.?##?#?#? 4,6 +?????#?#?.?####?? 1,4,5 +#??????.#??#???# 3,2,1,6 +#?.??.#??????.? 2,7,1 +?????.???.?????? 2,1 +??????????? 2,1,3 +?#??.??????. 3,5 +?##????.??...# 3,2,1,1 +?#.?.#???? 1,2,1 +##??????.?????? 4,2,1,2 +??#??#?????????#. 12,3 +????.?.#?## 3,4 +.??#?????.. 3,1 +??#.?.?#.#??#?# 3,1,1,2,3 +???#?.??????#?? 3,3,1,1 +??#?#?##.????#..? 8,1,2,1 +#??#???#?#?#??#? 1,2,10 +??#??##??.#?.??? 1,2,1 +??#????##?? 2,7 +??#?#.?#??.#??#??? 4,1,1,1,1,1 +....??#???..???#??? 6,4 +??##???????#?? 3,3,3 +?#????#?.??.## 2,4,1,2 +.???.????.?#??.? 1,1,1,1,4 +?###????##??#?#?? 12,3 +???#?.????#?? 5,5 +??##???????????. 6,1,1 +?????.?#?##???###? 2,1,2,2,1,4 +??.?.#?.?#???#? 2,1,1,3,1 +???????##???.??? 9,3 +?.??#??#??#?????? 1,12,1 +..??????#?#?????? 1,9 +??.?#?#???? 2,4 +?.?.??#??.? 1,1 +???#?.??????.?.?.?? 5,2,1 +?#?#?##???..??? 9,2 +?#?.???#?#?.? 2,3,1,1 +??????.??? 4,2 +?.??..?.?.????.??. 1,1 +..??##.??#? 2,1 +..??.????#. 1,5 +.???.?????#? 1,1,6 +?#??#??#??#?# 5,1,2,1 +?????#???..? 1,5 +.#??????????? 2,2,3 +??.#?.?.?. 1,1,1 +???????#??.???.#? 1,4,2,2 +????#???????.?..?? 1,3,2,2,1,2 +??.###?#?..?#???? 5,2 +#????##?#?##??. 1,3,1,4 +?.??.?#??. 1,1,3 +.#?.?????#??##???? 2,1,1,6 +?.?????##.??? 4,2,2 +.?.???##??? 1,4 +??#.???????#?.?????? 3,3,5,2,1 +???##?#??.??? 3,2 +??##?#????..# 7,1,1 +???????.???????.#.? 1,1,1,7,1 +?????#??#????#?? 8,4 +????#.#####?#??? 2,1,8 +???????#????##?#?.?# 16,2 +?.????#??.#??###?#?? 2,3,9 +????????#?.??????.?? 1,6,1,2,1 +?.#??#????.?#?????.? 5,1,7 +?.#.##?##??.#.??.. 1,1,6,1,1 +#????????.??.#?? 1,4,1,1,3 +??..?#?###?#??#???? 1,8,2,1 +.?????#?#???.??. 2,6 +?#?????.#????? 6,1,1,1 +.??????????? 2,1,1,1 +#?#.#??#?.????#??# 3,5,1,1,2 +?#????.#?##??##? 2,1,8 +?????#?.???### 3,4 +.????#???..?##?????? 5,7 +???#?.????#####???# 1,2,10 +????.?#??# 3,4 +???#.#?.??###.#?#? 2,2,3,1,1 +?#???.?????..#?. 1,1,2,1 +##???????## 3,6 +####.???.# 4,1 +?##???##?#???.#?#??? 10,5 +..??????.??.?# 2,1 +??????.#?.? 2,1,1 +.?#??????##?##. 5,5 +??..???##??#.??. 1,8,1 +.#????.#??. 2,1 +#??.#?.????.? 3,1,3,1 +#?#?????.???.?.?. 5,2,1,1,1 +????.??.??#?#??.?#? 1,1,1,6,1 +..?.?..???? 1,1 +?##??????#????.?? 3,5,1 +???.????#??## 1,2,1,3 +???????#?????#??? 4,2,3 +???#?.?.##?#?????.? 1,1,1,9,1 +.#??#?#??..?? 2,4,1 +?.??.???.??#?.?##?. 1,2,1,4,3 +???.?#??#??? 2,6 +.##??#????? 2,2,2 +???????????#? 3,1,1,2 +.????#.#??????#. 1,2,5,1 +?.##?????..???#????? 1,7,1,1,2,1 +??.#??#??????#?????# 1,4,1,10 +?????????.? 1,4 +???#?#?#.??.?????#? 6,1,1,3 +??????.?##?# 5,5 +#??..???#????? 3,8 +?#.??.??#?#. 1,1,1,1 +??.????.?#??.#? 1,1,3,2 +..#???.???.???.#. 4,2,2,1 +?????????.?#?.???? 1,3,1,2,2 +??##?????#?#???.???? 2,9 +?##??????#. 3,1,2 +.?#??#??#?????? 1,6,1,1 +.???#.???###????#??. 4,6,2,1,1 +?#??#???#?#????.? 2,1,5,3 +?#?.?????#.?#?#?? 2,1,1,2,6 +#?.#?.#??????#???.# 1,1,1,1,6,1 +?.?##????#?? 4,2 +####???????# 5,2,2 +???.?????#??? 2,1,1,1 +?.????#.#??#???? 1,2,1,5,1 +##?.#?#???#?????#??# 3,8,1,1,2 +..???##.?? 1,2,2 +??#????#?#?#?#.???#? 3,1,7,1,2 +.???.#?????# 2,2,1 +..?#????.?? 2,3 +?????.??????? 1,1,2,1 +?????###?#?..##???#? 8,6 +?#?.??????????? 1,1,1,1,3 +??##?.?##? 4,2 +#??##?.?????#????? 1,4,1,6,1 +????#??#??? 1,7 +???????#???# 2,6 +??##????#?#??????.? 1,2,3,1,1,1 +?.?.???##??#? 1,1,5 +.???#??.??.. 1,3,1 +???????###??#?##?. 1,12 +??.????.?# 1,1,1 +??#???##??..#?.#. 3,4,1,1 +??????.#?????#???? 6,2,2,2 +###..????#?#..????#? 3,2,3,2,3 +#?#????#??#????? 6,4,1 +?????.????.????.??? 2,1,3,4,1,1 +???.?#??#?? 2,4 +.??.???#??#???##??#. 1,6,3,1 +?.???.?.???? 3,3 +.?#?.??#???????. 3,9 +????##?#?.?#?.# 1,4,2,2,1 +??..???##?? 1,7 +?..????.???????# 3,4 +?.?..??#.? 1,1 +.??#??#?#?????.?? 7,2 +???##????.?#??.?.#?. 6,2,2,1,1 +?#?###??????.?#?.?. 9,2 +.????.????##..#?#??? 2,1,3,4,1 +??..??.??? 2,1 +.??#??????.?#?.? 1,1,3,2,1 +??..??#?##.?..? 2,5,1,1 +?.#.??#?#? 1,5 +.???#???.?????#??#? 3,1,1,2,2,1 +?????.?.???#?? 3,5 +?.??#???##?#???# 1,13 +??????.?..???????. 4,1,2 +????.#?#??#???#???? 2,4,7 +.??.??.?#.?? 1,1,1,1 +#.????#??? 1,7 +????????##???.??#? 3,6,1,3 +.?????##?##???????? 14,1 +.?.???.##? 1,3 +???????#?##??.? 1,1,1,6,1 +?#?.????#?#.#??.??# 2,4,1,3,1 +??.??.??#? 1,1,3 +.??##??.?#??#?#?#?.? 4,7,2 +??#???????#???# 4,1,3,2 +#??#????##???? 1,11 +?.#?????#?? 2,2 +.????#???###??#? 3,10 +????.?#???.#? 4,2,2,1 +??.????.?..#.??? 1,4,1,1,1 +.??.????#??.?.?#?#? 1,2,3,1,2,2 +.????????## 1,1,3 +?##?????#??#?##?## 9,1,2,2 +?##??????????.???? 7,1,1,1,1 +??.?????#.??.? 1,4,1,1 +.????#??#??#.?#????? 11,7 +??.?.?#?#???????? 2,7 +?????####????.?#. 9,2,1 +???????.??? 1,1,2 +?????.??..#?.## 2,1,1,1,2 +??????#?.??????? 2,3 +?????#.#?##??????#?? 5,6,5 +?###??.??????..??? 4,4,2 +?##???????? 4,2,1 +.??????#??????.?.?#. 13,2 +.?.#?#???#????#?? 1,4,5,1,1 +??????????. 1,6 +?.???????#?????#? 9,2 +#??.??.???????????. 3,4,2,1,1 +???#??..????#.??##?# 3,4,3,1 +????#??..?#. 5,1,1 +????#??.???.?? 1,4,1,1 +?#?????.????#? 1,2,4 +?#??#.??????#?.????? 3,1,2,1,1,3 +?.?????.#??? 1,2,1,1 +.??.????##??.??????? 2,7,1,2 +???#?....?????#???? 2,6,1 +.?????.??###?..? 5,4 +.#??###?#?.???? 9,1,1 +?#?.#????.?..??##?#? 2,1,1,1,1,5 +.??#??#?#??.#?.??.? 1,8,1,2 +??.??.?#???#?#??#?? 1,11 +#????###??##.? 8,2 +????.#?#???. 1,1,4 +??#??#?.#?#?##??# 1,1,1,7,1 +#?#?.???#??..#. 4,1,1,1,1 +.??#?#??#?.?? 5,2 +?.??????#?? 1,3,1 +???.?????# 1,1,2 +??#..#?.##? 3,1,2 +?.?.#?????????#?# 1,7,2,1 +#??#?#?#?..?.????? 4,1,2,1 +?.?#.?..#.?.. 2,1 +????????###.?#??? 2,1,1,3,4 +#???#?????#????...? 1,11,1 +.#?#?#????#????#?# 1,1,7,5 +?.?#.?.??.?. 1,1,1,1 +.?#.????## 1,1,3 +???.????#???.??...? 3,6,1 +?.?###???#????#?#? 1,5,1,2,1,1 +????????#??.? 5,2,1,1 +???.?.?.?? 1,1,2 +..?#?..???? 3,2 +?.#??#?####???#.?? 1,11,1,1 +??.##????#????. 1,4,1,2 +????????.?#??##? 2,1,1,1,3 +?????#.??????.? 3,1,1,2 +????.?#?..?# 1,1,3,2 +#??.???????#???#.? 1,1,2,1,6,1 +###????#?? 5,2 +##??#.??????#?.?# 5,1,4,1 +#?..?#?.??#?.?#? 2,2,3,3 +??????.?####? 1,1,6 +??.???????..?.???## 2,1,1,1,1,5 +?..???#???????#?. 4,5 +???#??.#?? 3,1,1 +??#??#?.???? 5,1 +?#??????#?. 2,2 +?.???.?????#?#. 1,2,1,5 +?.???????????? 2,1,1,2 +.?##?.???#?#? 3,4 +???.??????#??.#???? 3,7,2,2 +?#??????##??.?#?#?? 11,2,2 +??.?.????# 1,4 +????.?.?????????? 3,4,1 +???????#???##?? 8,3 +?..?.??#?????#?.?? 1,9,1 +.????#???#?.? 5,3,1 +..???##??##?#? 2,9 +?#????????#??. 2,2,4 +??..??#??#??#???##?. 1,1,1,5,4 +?????????#?????#??#? 2,1,10,2 +?????#??#?????#???.# 4,1,6,1,1,1 +??????#??# 4,2,1 +?#?..??.?#???#?##?# 2,1,11 +?#?.????#? 3,3,1 +??#?.???????? 2,1,2,1 +???.????##???.### 2,1,6,3 +.????####??.#? 1,8,1 +?.???#??#?.?. 3,1 +...??.???#?#?#?.? 1,6 +#??.?#?.?#.?????? 3,1,2,1,1 +#?????.##?#??.?. 2,2,5 +?????#?.????.?# 6,1,1,2 +?????#.?#.????? 3,1,2,1,1 +????#????.????? 3,1 +##???#?.?. 2,2 +?????.#?.#??#?#?.??? 1,1,1,1,5,1 +??#?.??..? 4,2,1 +?#????#???#??.. 2,1,6 +.?#?????#?.????? 8,1 +??#???..?. 1,1,1 +.?#??.??.#.??? 4,1,1,1 +?####?#?.??#.???. 7,1,2 +.##????.?? 2,2 +??.#.??#??.?#????#? 1,1,2,5,1 +???.????#?#?# 1,1,6,1 +?##????.#?#?.??#?#? 2,1,3,4 +#??##??#.???? 1,6,1,1 +##?##?????? 2,3,1 +???????#.##?##?? 2,3,6 +.???#???????? 8,1 +??#?##??..? 7,1 +#???????????? 2,5,1,1 +?#??##????#??? 5,6 +?##????????##?.??? 5,6,1 +??????.?#?#?##. 1,1,2,1,4 +????????.??#???#?? 1,1,1,1,2,2 +..?.#?.?????#?#? 2,1,5 +.?#???#?##?????#?? 2,7,1,3 +??#?.????????? 2,2,1,3 +?????????.??## 7,2 +?#.??.??#?#? 2,1,2,2 +??????????..??#???.? 1,5,1,2,1,1 +##??.???????..???.. 2,7,2 +.#?#?????????##??# 4,5,4,1 +.??.#??#?#?? 1,7 +?..?.##?.???????.? 2,4 +?.??????#??#??? 1,1,1,6 +##?#?.??#????????#? 5,2,1,1,1,1 +.?#?#?.?#??#?.?? 4,6,1 +????????#?????.????. 1,1,4,1,1,4 +.?????.??#?.??? 2,1,1,1,1 +#?#???#?#?? 5,1,1 +??.?#???##?#?# 1,1,6,1 +??????#?##?.?. 2,6 +.?#??##??.????## 8,1,1,2 +.?#?.?????. 2,3 +#??????#????####? 2,4,6 +??.#??#??#?##??? 4,1,2,1 +???###?.?? 1,4 +??.????.???.#?.??.? 2,2,1,2,1,1 +??..???.??? 1,1,2 +#???#?#???##?.??? 7,3,3 +.???#???##??..#?? 10,3 +?????#??????#??? 1,2,1,5 +??????????#???##? 10,2 +.??????###? 1,4 +?.??#??#??.###???? 1,5,1,3,1 +?????.?????#? 3,2,1,2 +#??.??#???#?. 3,8 +???#??????#?. 3,6 +??.?????#??????.? 1,4,3,2 +??##???##?#????.?#? 6,2,2,1,2 +?.??.????#??# 1,1,2,2 +?????..??.???#?#?.? 1,1,2,6,1 +?????##???????.? 8,1,1 +????..????#???.##?? 3,7,3 +?????#???#????#???? 2,11,1 +?????.???#.????.?? 1,1,1,4,1,1 +.?.?#???????.????#?? 9,2 +???#?#?#???#. 1,1,3,3 +##????#?.??.?????. 8,1,1,1,1 +?????????? 3,1 +.?#?.?.#??.. 2,1 +.????.??#?? 3,2 +#?#??###?#??#????#? 1,12,3 +##?.?#???.??# 2,3,3 +##?????#????? 3,8 +???.#..????.?#??#? 1,1,3,1,3 +??#.?????.?#?##? 3,3,1,1,3 +#?????????#????????? 11,2,1 +?#?##?????? 5,2 +?.#..?#.?????.???.?? 1,1,2,5,1,2 +??#????#.?? 8,1 +??#?#??#?#.? 1,4,1 +?.??..?.??#??? 2,3 +??????????.?. 2,1 +?????#.??#?.? 2,1,1,2 +.?#??##??#.?? 6,1 +??#??#?.?#??? 1,1,1,4 +#???##?????? 1,1,2,3 +???#.?#???????? 1,1,6,1 +?#????.?##???#??? 4,3,1,1 +..?.???.?.??##?.. 1,4 +????..??#??#??.?? 1,6,1 +?.#??####??.??????? 7,1 +??..?#.#??#??????? 1,2,1,2,1,1 +??.?#???#?##.??#?? 1,3,4,5 +????.???.?#?? 2,1,1,3 +??.#?.??.?..?? 2,1,1 +.#??###...#???... 6,2 +.?????????#.?#??#.# 1,1,3,1,5,1 +???????.?? 1,3,1 +??.##?.##???????#??? 2,3,5,1,4 +??#???#.??###???? 7,4,1 +???????#???.?? 5,1 +??#???#??? 1,1,5 +??????#?..???. 7,2 +????????#?????#? 2,1,9 +????..???#?#? 1,7 +.??????.???##? 1,2,1,3 +?????#????.??? 3,4,2 +?#???##..?????? 3,2,3 +?##??#???????#??? 2,2,1,5 +.??.???#####???????? 1,8,4 +?????#???.??????#??? 1,2,2,9 +.?##?#??##?..?? 2,6,1 +??.??????##???? 1,7,2 +.???????#?? 1,5 +??#?.?#?.? 1,2 +?#??????#??#????? 1,1,4,1,1 +??#?.??.???.? 3,1,3 +?#??..???????#?#? 1,2,2,5 +..?????.?#?. 3,2 +##.??#?####??#???#.? 2,2,7,3 +?.????????. 2,1 +????..??.#?##.?#? 1,1,1,4,1 +?#??#?#??.???#? 8,3 +???.?#??.???#????? 1,1,1,1,5,2 +?.???????? 1,1,4 +#????#????#???.# 1,1,6,2,1 +?#?#???#.#?? 7,1 +##???#?.????????? 2,1,1,9 +#????????..?.?#? 1,1,3,1,1 +.?.????.?????.?? 2,4 +????#.##?? 3,3 +?.?????.?????? 1,5,1,1 +#?.????#???? 2,1,4,1 +?.??.???????## 1,1,2 +.????..?###?.. 1,4 +??#?.?.?#. 2,1,1 +.?#.?#.??. 1,1,1 +.??##??##??#?#? 8,3 +#??.#??.??.#? 3,3,1,2 +#?.?#.#.???#?#??#?.# 1,1,1,8,1 +??????...#?????.# 1,1,1,4,1 +.#.#??##.??##???? 1,5,7 +???#?????# 4,3 +?##????#??????? 6,2,2,1 +#?????.?##.?.??? 3,1,2,1,1 +?..?.#????.? 1,1,1,1 +.?#?.#????#???#??? 1,12 +?#??#?????##? 4,4 +.??.??#?#? 1,5 +??.????#????#??? 4,6 +????#????#. 6,1 +#?##???#?.?#?? 9,1 +#??#??.??#.?..??? 2,1,3,2 +#???????#?#?##?? 4,7,1 +???.?#???##..???#? 2,3,3,1,1 +?????#.?????.? 2,2,3 +??..?#????.#?. 2,2,2 +.???#???..??##?#? 6,1,4 +?##?#.#?????..??? 2,1,3,2,3 +.#???#?????.#.?? 1,1,5,1,2 +#?????#??.??????. 2,5,1,3 +??.?###.###??? 1,4,3 +???.??..????#? 3,1,1,1 +?.?.?????##? 1,1,1,2 +????.?????#?.??? 2,1,3,3 +??#?.?#??#???.??.? 4,5,2,1,1 +###??.#?.?. 5,2 +??#..????#?.????? 2,5,2,1 +????.????? 2,1,1 +??##?.?.????.???? 4,3,1,1 +??????#???.?. 1,2 +.??#?#?#??#??#? 1,1,9 +.???????????#???. 1,4,2,2 +??.?.#??###??????? 1,11,1 +#####?????? 6,2 +.??.???#??#??. 1,3,3 +?????#.?.?#? 2,1,1 +?#????##?#??.???#?? 3,6,4 +?..#?.?#??#???.#??#? 1,1,2,2,5 +#????.??#.??#??.?? 1,1,1,2,5,1 +?##???????#?#?????. 2,9,3 +.????#??.?#?? 4,2 +?????##?#?#?#? 1,10 +?????#??????. 1,1,4 +?.??#??##??##??.? 1,5,3,1 +??#?##.?#??.?#? 5,3,1 +??#??#?#???#?#?#. 3,1,1,4,1 +????#?.?##?????#???# 1,3,5,3,1 +.??#????.?##???#?? 3,7 +???#?.##?.?##?..???? 4,2,4,2 +??.??????????#. 1,2,3,1 +???#???#?? 2,2,3 +.?#?##?#?#??.??#??#? 9,6 +????#?#?#??#?.???? 4,3,2,1 +??#?????????##?.??? 3,2,4,2 +???????????. 1,1,1,1 +#??##???????#?? 9,2 +?##?####??#???.?? 8,1,1 +??##?.??#?#??.? 4,7 +????#?????##??.??? 1,3,7,3 +?.?#?..??.??#?.??# 1,2,2,1,2,2 +??#?#?#??.??? 7,1 +?.?#?#..??? 3,1 +?#..?.#?.?. 2,1,1 +???.?#??.??. 1,3 +..???.#???##?#.? 2,8 +?????#.??# 1,1,1 +??###??????#???#? 8,5 +#????.#?#???#?##?#?# 1,1,1,1,1,9 +?????????.??? 2,1,3,2 +.????..??.? 1,2,1 +?#??.?#.#?.????.? 4,2,1,2,1 +?#???##?????????? 1,5,1,1,1 +.??.???##?????#?.?#? 1,12,1 +??.????.?..?.???. 2,1 diff --git a/2023/go/day13/day13.go b/2023/go/day13/day13.go new file mode 100644 index 0000000..0cac44a --- /dev/null +++ b/2023/go/day13/day13.go @@ -0,0 +1,144 @@ +package day13 + +import ( + "adventofcode2023/utils" + "fmt" + "strings" +) + +type mirrorLoc struct { + orient string + index int +} +func Part1(input string) int { + count := 0 + + patterns := strings.Split(input, "\n\n") + for p, pattern := range patterns { + rows := strings.Split(pattern, "\n") + if v, ok := findMirror(rows); ok { + count = count + v * 100 + } else { + cols := swap(rows) + if v, ok := findMirror(cols); ok { + count = count + v + } else { + utils.PanicOnErr(fmt.Errorf("p: %v\n %v\n", p, pattern)) + } + } + } + return count +} + +func Part2(input string) int { + count := 0 + patterns := strings.Split(input, "\n\n") + + for p, pattern := range patterns { + rows := strings.Split(pattern, "\n") + loc, _ := findMirrorLoc(rows) + found := false + for i:=0;i= 0 && col < len(rows[0]) { + v := rows[row][col] + if v == '#' { + out[row] = out[row][:col] + "." + out[row][col+1:] + } else { + out[row] = out[row][:col] + "#" + out[row][col+1:] + } + } + return out +} + +func findNewMirrorLoc(loc mirrorLoc, rows []string) (mirrorLoc, bool) { + if v, ok := findNewMirror(loc, "row", rows); ok { + return mirrorLoc{"row", v}, true + } + cols := swap(rows) + if v, ok := findNewMirror(loc, "col", cols); ok { + return mirrorLoc{"col", v}, true + } + return mirrorLoc{}, false +} + +func findMirrorLoc(rows []string) (mirrorLoc, bool) { + if v, ok := findMirror(rows); ok { + return mirrorLoc{"row", v}, true + } + cols := swap(rows) + if v, ok := findMirror(cols); ok { + return mirrorLoc{"col", v}, true + } + return mirrorLoc{}, false +} + +func swap(in []string) []string { + out := []string{} + for j:=0;j len(rows) - 1 { return true } + + if rows[i+1+offset] == rows[i-offset] { + return isMirror(i, offset+1, rows) + } + return false +} \ No newline at end of file diff --git a/2023/go/day13/day13_test.go b/2023/go/day13/day13_test.go new file mode 100644 index 0000000..dbb2ef7 --- /dev/null +++ b/2023/go/day13/day13_test.go @@ -0,0 +1,47 @@ +package day13 + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestPart1(t *testing.T) { + r := Part1( +`#.##..##. +..#.##.#. +##......# +##......# +..#.##.#. +..##..##. +#.#.##.#. + +#...##..# +#....#..# +..##..### +#####.##. +#####.##. +..##..### +#....#..#`) + require.Equal(t, 405, r) +} + +func TestPart2(t *testing.T) { + r := Part2( +`#.##..##. +..#.##.#. +##......# +##......# +..#.##.#. +..##..##. +#.#.##.#. + +#...##..# +#....#..# +..##..### +#####.##. +#####.##. +..##..### +#....#..#`) + require.Equal(t, 400, r) +} diff --git a/2023/go/day13/input.txt b/2023/go/day13/input.txt new file mode 100644 index 0000000..917747b --- /dev/null +++ b/2023/go/day13/input.txt @@ -0,0 +1,1377 @@ +...#.###... +###.##.##.# +#...#.##.#. +.####..#### +##..###.#.. +.#.#..#.#.# +#....####.# +#....####.# +.#.#..#.#.# +##..###.#.. +.####..#.## +#...#.##.#. +###.##.##.# +...#.###... +...#.###... + +#.##...#### +##..###.... +#####...### +###..#.##.. +.##....##.. +.##.....#.. +###..#.##.. + +####..... +.##.##... +#..#.#### +.#..#.### +#..#...## +#..##.... +.....##.. +.##.#.### +#..####.. +......### +#..#...## +....#.### +....##... +.##...#.. +.##..#... + +###..#....##..... +##...##.#####.#.# +#..###.#....##.## +.#.###.#.#.##...# +.#.###.#.#.##...# +#..#####....##.## +##...##.#####.#.# +###..#....##..... +.##....######.##. +..#######..##.### +#.##......#.##.## +.#..##.#....#.##. +#.##.###.##..#.#. +..#..#..##.###..# +..#..#..##.###..# +#.##.###.##..#.#. +.#..##.#....#.##. + +..##..#.##..### +##.##.....##..# +##.##.....###.# +..##..#.##..### +..#.#.##.#...#. +...#.#..#.##.#. +.########....## +###...#.####.## +#...####...##.# +..........#.... +##...###....... +########...#.#. +########...#.#. + +....#.... +##..#.... +...#...#. +....#..## +##.#.###. +###...### +..#...#.. +######.## +##.###.## +..#...#.. +###...### +##.#.###. +....#..## + +#......####.# +..####..##### +...##.....##. +..........##. +.#.##.#..#..# +..#..#..##..# +##########... +..####....#.. +.#....#.#...# +..####...#..# +#.####.#..#.. +##.##.####.## +..#..#......# +.#....#...#.. +.##..##...... +.##..##...#.. +.#....#...#.. + +...#.#.## +.#####.## +.#.##.#.. +.#.##.#.. +.#####.## +...#.#.## +###..##.. +####.#### +#..#.#.#. +##...#... +...###... +#####.... +#..##..## + +..#.##.#. +...####.. +..######. +##......# +...#..#.. +##......# +..#####.. + +##..#.##....##.#. +###.#....##....#. +##...####..####.. +########.##.##### +##...#.#....#.#.. +##.##.########.## +......#..##...... +..#.##........##. +..#.#...####...#. +###.##.#.##.#.##. +##.####..##..#### +...##..#.##.#..## +......##....##... + +..#.##..#..#..# +#..###..#..#..# +...#..#.####.#. +...#...#....#.. +#....##......## +.#.......##.... +.#.##.#.#..#.#. +...#..########. +.#..#.......... +#..###.######.# +...###.######.# +.#..#.......... +...#..########. + +###..###..#.... +#.####.##.#.... +.#....#..###.## +#..##........## +#.####.#....#.. +#..##..#.##.... +#......####..## +#.#..#.###..... +........#.#..## +..####..###..## +...........#... +##.##.##..#..## +..####..#.##### + +#..##.####.#.#.#. +....#...#.###.### +#####.#..#....... +.......##.#...##. +....#..#..#.###.# +......#.....##.#. +####..#.#...#.##. +....##..####.###. +####.#...#.###... + +.###....###.#.#.. +.###....###.###.. +..##.##.##...##.# +...######....#... +##..#..#..##.#.#. +###.#..#.######## +.#..####..#.##### +##..#..#..##.#### +............###.. + +##.###...#..##. +##..##..###.... +..##..#.##..##. +......#####.##. +.####.#...#.##. +#....#.#....##. +..##....#..#### + +#.#..#### +#...#.... +#........ +#.#..#### +#.###.##. +#.#.#.##. +#.#.#.##. +#........ +.#...#### +.##.#.##. +#..###..# +.###..... +.##.#.... + +#..###..... +#.####..... +##.....#### +#..#..#.... +...###..... +.##.#.#.#.. +....##...## +#...#..##.. +#....#...## +..###.##... +.#..#..#### +#####.#.... +......#..## + +##..##### +...#..##. +##.###..# +..##..##. +..#...##. +###..#### +.#...#### +...##.##. +..#.##### +##.###### +..#..#### +..#..#### +....#.##. +##.###..# +##.##.... + +.#.#...#.##..## +#.#.#..#..####. +##.###.##..##.. +#..#...#...##.. +..#.##.#.##..## +..#...##.##..## +..##...##...... +...####..##..## +.##..###.###### +..#.#.#.#..##.. +#......##...... +#..#.###....... +....#.#.####### + +..##...##.. +#.##.#.#### +..##..#.... +##..###.##. +.#..#..#.## +......####. +.###...##.# +.#..#.##..# +.#..#.##..# + +##..####..# +.##.#..#.## +..###..###. +#.##....##. +#..######.. +..#..##..#. +##..####... +##..#..#..# +.#.##..##.# +..########. +..########. + +..##### +..#.... +##.#... +##.#### +#####.. +##...## +..#.... +.....#. +..##.## + +.......#... +#..#..#..## +.##......#. +..#####.#.. +..###.#.#.. +##.#.##.##. +##.#.##.##. +..###.#.#.. +..#####.#.. + +..#...#..####.... +#.###.#.##..##.#. +.#.##.###....###. +.####.#...##...#. +#..#.####....#### +#.....#...##...#. +#..#.####....#### +.##.#.###....###. +#..#....#.##.#... +#..#....#.##.#... +.##.#.###....###. +#..#.####....#### +#.....#...##...#. +#..#.####....#### +.####.#...##...#. + +###..###....#.# +###..###....#.# +..####...#.#.## +.##...#.....#.# +.#....#....##.. +#......#...#... +..####...#..#.# +..#..#....##..# +.#....#...#..#. +...##...#...##. +..####...#..#.. +..####.....#..# +###########.#.# + +##........### +.#.######.#.. +##...##...### +#.##.##.##### +#..#.##.#..## +.#...##...#.. +#.#..##..#.## +#.##.##.##.## +##.######.### +..#.#..#.#... +##.######.### +#...#..#...## +##.#.##.#.### +##........### +##.#.##.#.### +.#.##..##.#.. +##........### + +..#..##..#... +..########... +...#....##... +...#.##.#.... +##.##..##.### +#..######..## +.##########.. +...##..##.... +.#..#..#..#.. +..#......#... +##..#..#..### +#...#..#...## +###......#### + +####..#.##.## +##....#....#. +###.#....#... +##.#.##..#... +....#.....### +...###.#..### +####..###.#.. + +####.#....# +##.#....... +###..##..## +###..##..## +##.#....... +####.#....# +#......#... +#...##.##.# +##.##...... +..#.#.####. +..#.#.#..#. +.###.#.##.# +##.###....# + +.#########..#.##. +.##..#####.##.#.. +.##..#####.##.#.. +.#########..#.##. +.#.##..##.##..#.# +.#.##.##.##....#. +#.##.##.####.#..# +...##.##.#.#...## +...##....####..#. +#.....#..#....... +#.....#..#......# +...##....####..#. +...##.##.#.#...## + +.....#....#.. +#...#..##..#. +#...#..##..#. +.....#....#.. +###..#.##.#.. +#.####.##.### +##..##....##. +.###.######.# +##....####.#. +#..#...##...# +#######..#### +....#.#..#.#. +.####..##..## +.##..##..##.. +.#..##.##.##. +.#..#..##..#. +##..#......#. + +..##..... +..##..... +##..##..# +#....###. +..##....# +..##....# +.####...# +.......## +##..##.#. +########. +.......#. +#....#### +.####..#. +######.## +#.#####.# +......#.. +..##....# + +#.####.#..##..# +...##.##...###. +#.#####.##.###. +#.#####.##.###. +...##.##.#.###. +#.####.#..##..# +#.#...#..#.##.. +###########..## +#.####...#...## +..#...##.#.#..# +..#...##.#.#..# + +#.#...##..##... +..#####.##.#### +.####.#....#.## +#.##....##....# +.##..##....##.. +#####........## +..#..#......#.. +##.##...##...## +....##......##. +...#.###..###.# +##.####....#### +..##.#..##..#.# +##.#..#.##.#..# +##.#..#.##.#..# +.###.#..##..#.# + +##....#.#.# +##..###.#.# +.....###... +##.#......# +###.......# +##..#...### +##..#...### +###.......# +##.#.#....# + +..#..#....#..#..# +.#.###.#....#.##. +##.#..####......# +##.#..####......# +.#.###.#....#.##. +..#..#....#..#..# +#..#..##.....##.# +...#.###....#...# +#...#.#.#####.#.. +#...#.#.#####.#.. +...#.###....#...# +#..#..##.....##.# +..#..#....#..#... + +####..# +.##.#.. +....##. +.##.#.# +####.#. +.##.#.. +#####.. +....### +....### +#####.. +.##.##. +####.#. +.##.#.# + +.#.####.... +#......##.# +#......##.# +.#.####.... +..##.###.## +##.###.#..# +.###.#.#.## +#..####...# +#..####...# +.###.#.#.## +##.###.#..# +..##.###.## +.######.... + +#.#.... +#.#.... +####..# +##.##.# +##..... +#.##### +.#..... +#.#.##. +#...... +#...##. +#.##### +###.##. +...#..# + +#..####......#. +#..####......#. +..#.###...#.... +#.#.#....#...#. +.#.#.#####..... +.#.###........# +....###.###...# +.....#..###..## +#.#######...### +#..#.####.####. +.#..#...#...... +.#..#...#...... +#..#..###.####. +#.#######...### +.....#..###..## +....###.###...# +.#.###........# + +#..#..#..##..##.# +..#....#..#.##.#. +..#....#..#.##... +#..#..#..##..##.# +#.######.##.#.##. +##..##..#####...# +.###..###..##.### +.#.####.#.#.#.##. +.########........ + +#.##..##..##.#### +.#..##..##..#..## +.#..#....#....### +####.#..#.####... +.#.########.#.... +###.#....#.####.. +.#.#..##..#.#.### +.###.#..#.###.#.. +#.#.######.#.#### + +.####..#..#.... +#.##.###.##.### +..##...###.#..# +..##...###.#..# +#.##.###.##.### +.####..#..#.... +.#..#.#..##...# +#...###.###.### +##..##.#.###.## +.#..#...#.#.#.. +........##.#..# + +#.##..######..##. +...#..#....#..#.. +##.##...##...##.# +##...########...# +.#...#..##..#...# +..#............#. +#.###.##..##.###. +.####........#### +#.#.....##.....#. +.###..##..##..### +#######.######### +..#.##########.#. +##...###..###...# +##.#..######..#.# +..#..########..#. +###..########..## +###..########..## + +.##..##..#. +.##..##..#. +.######.#.# +.######.##. +.#.##.#.##. +#####.##### +..####...#. +##.##.###.. +#......#..# +...##....## +#.####.##.. + +.#..#.# +#...#.. +#.##.## +#..#..# +#..#..# +#.##.## +#...#.. +.#..#.# +#.....# +##.#.## +..####. +...###. +##.#.## + +.#....#.###.###.. +##.##.##.##.##### +..####...#...#.## +.#.##.#.#....#.## +.######..##.##.#. +#......#..##...## +.######...###.... +#..##..#...#.##.. +.#.##.#..##.#.... +###..###...###.## +...........####.. +##....##....#.#.. +##....##..#.#.... +##....##...#.##.. +#......##.#.##.## +.#....#.##.##..## +#.####.##..#.#.## + +###.##.###.###... +#.#....##.##..##. +#.#.#.########..# +.#...#..##..#...# +.#...#..##..#.... +#.#.#.########..# +#.#....##.##..##. +###.##.###.###... +...#.##.#........ +......#..##.##..# +......#..##.##..# + +.####..#### +.####..#### +#..#..#.... +#####.#.### +...#####.## +.#####.###. +..###.##### +#.##.##.#.# +#....##..## +#..###..### +#..###..### +#....##..## +#.##..#.#.# +..###.##### +.#####.###. +...#####.## +#####.#.### + +....####.#.## +#.#...##..### +#....#.#...#. +...###....##. +#...#.###.### +#...#.###.### +...###....##. +#....#.#...#. +#.#...##..### +....####.#.## +##.......##.# +#...####.#### +#....###.#### + +.##...# +####.#. +##..#.# +##.###. +..##..# +##..#.# +.....## +.....## +##..#.# +..##..# +##.###. + +..#...##.##..#. +##.#.......###. +##..##.#.#.#... +...#...###.#### +..##.###..##.#. +##.####...##.## +###.#...#####.. +...####.##.#..# +..#...##.##.... +..#....#.##.... +...####.##.#..# +###.#...#####.. +##.####...##.## + +.###....####..#.. +.###....####..#.. +...#.#.#..#...### +#.##.#.#.#......# +#.....#...#.###.. +###..###.##.###.. +#...#.#.##..#...# +#...#.#.##..#...# +###..###.##.###.. +#.....#...#.###.. +#.##.#.#.#......# +...#.#.#..#..#### +.###....####..#.. + +.#.#.#. +##..##. +.##...# +.##...# +##..##. +.#.#.#. +..#.#.. +##..#.# +####... +#####.. +#...##. +..#.#.. +###..## +###.### +..#.#.. + +.##........ +..##.###### +#..#.##..## +##...#.##.# +.#....#..#. +##.###....# +.#.#.##..## +......####. +......####. +.#...##..## +##.###....# +.#....#..#. +##...#.##.# + +###.#.... +..#.##### +##.##.##. +...##.#.. +#.#.#.##. +..##..##. +.#..#.... +#...##..# +##....##. +..#..#..# +.....#### +....#.##. +..####### +###.##..# +.##...##. +.##...##. +###.##..# + +.....##.....#..#. +#....##....#.#### +.#.##..##.#....## +.............#.#. +#..........##..## +#..........##..## +.............#.#. +.#.##..##.#....## +#....##....#.#### +.....##.....#.... +..#.####.#..#.#.. +###.#..#.####...# +..##.##.##..#..## + +...##.##.##.# +.#..##..###.# +###..###.#.## +###..##..#.## +.#..##..###.# +...##.##.##.# +#..#.#.#..##. +.#..##.###### +#...#...#.... +#...#...#.... +.#..##.###### + +....##. +##..#.. +##..#.# +....##. +..##### +.....#. +##.#.#. +###.... +##..##. +##..### +###...# +###.... +##....# +.....#. +##...## +####... +###...# + +..#.#...#.### +..#.#...##### +..##.##.#.#.. +#..#.##...### +#.#....##.... +#..#.##....## +..#.##.##.#.. +.#.......#... +.#.#.##.###.. +#.##.#..##... +.##.#.###.#.. +.#.##........ +.##.##....### +.##.##..##### +##.##.#.#.#.. +#..#####.#### +###..#.###.## + +#..#....# +##.#....# +.#.##..## +#...####. +....####. +#..##..## +.#..####. +##.###### +..##.##.# +..#.#..#. +.#....... + +#...... +.##.... +.###### +.#.#..# +#.##### +#...##. +###.... +.###..# +#.#.##. +.###.## +#.#.... +#...##. +.#.#..# +..##..# +..##..# + +###....####.# +###....####.# +#...##...##.# +.##....##..#. +.########..## +.#......##.## +.##....##.#.. +.##....##.#.. +#.##..##.#... +#..####..#.#. +#.######.##.# +...####.....# +#.######.##.# + +.#.##.#..#.#... +###..#..##....# +#.##.#...#..##. +####.##....#.#. +####.##....#.#. +#.##.#...#..##. +###..#..##....# +.#.##.#..#.#... +.##...##.####.# +.##...##.####.# +.#.##.#..###... +###..#..##....# +#.##.#...#..##. + +##..##.###. +..#.#.#...# +..###....## +..######..# +...#.#..##. +..#...#.#.. +..#...#.#.. +...#.#..##. +..######.## +..###....## +..#.#.#...# + +###.##..##. +#.######### +..##......# +.##.#.##.#. +#.###.##.## +.#...####.. +..#........ +...###..### +.###......# +..#..####.. +#..##....## +##..#....#. +#..#.#..#.# +##.#.#..#.# +##.#.#..#.# +##.#.#..#.# +##..#....#. + +.....##.. +.##.#.### +#.##.#... +.#.#..... +###...#.. +.####..## +.####..## +#.#...#.. +.#.#..... + +#....##...# +#....#.#... +#######...# +.#..#.....# +#.##.#.##.. +#.##.#.##.. +.#..#.....# +#######...# +#....#.#... +#....##...# +##...###.## +.####..#.## +.#..#..#..# +.#..#...#.. +.#..#..#..# +.......#..# +.####..#.#. + +.#...#.#..#.##. +.##.#..###...## +#..#.##...###.. +#..#.##...###.. +.##.#..###...## +.#...###..#.##. +.#...###..#.##. + +...###.##.##..... +.##.#..#.##...... +..###..#.#.#.#.## +#...###....#...## +###.##..#.###..## +.##.##.##.#..#... +.##.##..#.#..#... +###.##..#.###..## +#...###....#...## +..###..#.#.#.#.## +.##.#..#.##...... +...###.##.##..... +##....###.#.##### +.#.##...##.#.##.. +#.#.#.###.....### + +####.#. +####.#. +.##.### +#...... +#..##.# +#..###. +#..#.#. +#..##.. +.##..#. +#..#... +.##.#.. + +.#.###.##.###.#.. +...##.#...#.##.## +.######..####.... +..####.##.#..##.. +....#.#####.###.. +....#.#####.###.. +..####.##....##.. +.######..####.... +...##.#...#.##.## +.#.###.##.###.#.. +##..##...#..#..## +##..#.....#.#.#.. +.###....######### + +##.#.##.. +...##.### +...##.### +##.#.##.. +###...##. +###.#.... +#...##### +#.##..#.. +#....#... +..##.##.. +#.###..## + +#..##.##.#... +.#....#..##.. +#.####.#.##.. +.######.#.### +..####...##.. +##....####.## +........#.#.. +...##....#### +#.####.###.## +.######..#... +########.##.. +##....####### +##.##.##...## +##.##.##..... +..####...##.. +#......#...## +##....##..... + +#.####### +#.##..##. +##.##.##. +#..##..## +#..##..## +##.##.##. +#.##..##. +#.####### +.#..###.# +#...####. +#...####. +.#..###.. +#.####### +#.##..##. +##.##.##. + +#####.. +##.#..# +##.#.## +#####.. +##...## +..##.## +....#.# +###.##. +......# + +##.###.##.###.# +....#.####.#... +##..###..###..# +.....#....#.... +..#....##....#. +....#.....##... +##...#....#...# +....#......#... +.....######.... +..#...#..#...#. +##.....##.....# +###.########.## +##.##.####.##.# +######....##### +##.##.#..#.##.# + +#.####..#####..#. +#.####..#####..#. +.#.##.####..##.#. +.#####.#..#..##.# +.#.#..#..##.#...# +..##.#.###.##..## +..#..#.######...# +..#..#..#####...# +..##.#.###.##..## + +....##.##.# +.##..#.##.# +######.#.## +.##.#.#..#. +.....#....# +.....#.#.#. +......#..#. +#..#.###### +#..##..##.. +#..###.##.. +#..#.###### +......#..#. +.....#.#.#. +.....#....# +.##.#.#..#. +######.#.## +.##..#.##.# + +..##.#### +..##.#.## +##.#..#.# +###.#..## +###.#..## +##.#..#.# +..##.#.## +..##.#### +###.#..#. +.##.#..## +.#.#...## +#..##..## +.####.#.# + +####.#.#.#..###.# +###....#.#.##.### +..####..###..##.# +##....#..#.#.#..# +..#..###...###... +####.#.#.###.#... +##.###.##.#..#..# +....#..####...#.. +..#.##..######... +##....#....###..# +....##.#.###.##.# +..#.##.#.###.##.# +##....#....###..# + +#...##. +#.##### +#.....# +...#### +.#..... +####..# +.#..##. +#..#### +#..#### + +.#.##.# +.#....# +..####. +..####. +.#....# +##.##.# +#..##.. +..#..#. +...##.. +.###### +.###### +##.##.# +###..## +#..##.. +#.#..#. +#.#..#. +##....# + +#..#.##..## +.###...##.. +..####....# +..####....# +.###...##.. +##.#.##..## +....####### +.#...###### +....###..## +.##.##....# +.#..###..## +...##.####. +###.##.##.# + +.#..#.# +##..#.# +..##..# +####..# +.####.# +.#....# +###.... +#..#... +...#.#. +...#.#. +#..#... +###.... +.#....# +.####.# +####..# +..##..# +##..#.# + +###.####. +###...### +...#.#### +..#.##.#. +.....#..# +##.##.##. +####.##.. +####.##.. +##..#.##. + +..#...##. +.##...##. +.#.#.##.# +##..#.#.# +...###... +...###... +##..#.#.# + +#..###... +#.#..##.. +.#.....## +.......## +#.#..##.. +#..###... +#.#.##.#. +##.#...#. +..###.#.# +..###.#.# +##.#...#. + +......#.. +...#..#.# +#....#.## +##.....#. +..#.#..## +.##.#.#.# +....#.#.. +..#.#.#.. +.##.#.#.# +..##.#..# +#.#####.# +#.#####.# +..##.#..# +.##.#.#.# +..#.#.#.. +....#.#.. +.##.#.#.# + +....###.##.##.# +....#.#..#....# +#..##.#.##....# +#....###.#....# +.##.####.###### +.....#.#.#....# +####....#..##.. +#..#.#.##.#..#. +.....#.#...##.. +#..#....#.#..#. +#..###...###### +#######..#.##.# +.##.#..#.#....# +....#...##.##.# +#####..#..####. + +##..##.###.#.#..# +##..##.##..#.#..# +.#.#.####..##.### +#..#...##.#.#..## +##..#..##..####.. +##..#..##..####.. +#..#...##.#.#..## +.#.#.####..##.### +##..##.##..#.#..# +##..##.###.#.#..# +#.#...#..###..#.# +.####..##.#.....# +.###.##.##.###.## +.#..#.......#.#.# +..##.#.......#..# + +#.##.## +#.#..## +###.#.# +...#... +###..## +...##.# +...##.# +###..## +...#... +###.#.# +#.#..## + +#.#....#..# +.#.#..#.### +#.###..#..# +...######.. +..#######.. +#.###..#..# +.#.#..#.### +#.#....#..# +#.#....#.## +#.#....#.## +#.#....#..# +.#.#..#.### +#.###..#..# + +..#.#...##..#...# +..#.#...##..#...# +.....###..###.#.. +#..#...#..#.###.# +##.#..#..#...#### +.##..#.......#..# +...##...##.###.#. +#.####.......#..# +#.#...#.#...#...# +#.#...#.#...#...# +#.####.......#..# +...##...##.###.#. +.##..#.......#..# +#..#..#..#...#### +#..#...#..#.###.# + +...##..##...... +...###....#.### +...#.###.##.... +..#.##....####. +..###.#..#..### +##...#.######## +..###.#......## +..#..#.#.#.#### +..###...#.##### +..###........## +##..#.#.##.#### + +....#...###.####. +#.#...#.#..#.##.# +#.#...#.#..#.##.# +....#...###.####. +#.##.#.#####.#..# +..#..#.#.###....# +####.#..#.#..##.. + +.##....#....#.. +....##..####..# +#####.##.##.##. +##########.#### +#..######..#### +....####....### +#..##..######.. + +#.###..#..#..###. +###..#.####.#..## +#..#.###..###.#.. +.##..#.#..#.#..## +##.#..#....#..#.# +###..###..###..## +######.####.##### +..##.##....##.##. +..##.##....##.##. +.#####.####.##### +###..###..###..## + +.##.##.## +...###.## +......#.. +##...#### +.#....### +.##...... +#...#.### +#..##.### +.##...... +.#....### +##...#### +......#.. +...###.## +.##.##.## +#........ +#.#.#.... +#.####... + +#.#.### +#.##### +##.###. +.....## +#####.. +#####.. +.....## +##.###. +#.##### +#.#.### +#..#.#. +.##...# +##.##.# +.#####. +.....#. diff --git a/2023/go/main.go b/2023/go/main.go index 6aa455d..a5182cd 100644 --- a/2023/go/main.go +++ b/2023/go/main.go @@ -18,6 +18,8 @@ import ( "adventofcode2023/day09" "adventofcode2023/day10" "adventofcode2023/day11" + "adventofcode2023/day12" + "adventofcode2023/day13" @@ -62,6 +64,12 @@ func main() { case 11: fmt.Printf("part 1: %d\n", day11.Part1(utils.Readfile(d))) fmt.Printf("part 2: %d\n", day11.Part2(utils.Readfile(d))) + case 12: + fmt.Printf("part 1: %d\n", day12.Part1(utils.Readfile(d))) + fmt.Printf("part 2: %d\n", day12.Part2(utils.Readfile(d))) + case 13: + fmt.Printf("part 1: %d\n", day13.Part1(utils.Readfile(d))) + fmt.Printf("part 2: %d\n", day13.Part2(utils.Readfile(d))) default: panic(fmt.Errorf("no such day: %d", d)) } @@ -69,7 +77,7 @@ func main() { // Reads day from os.Args. func day() int { - latest := 10 + latest := 12 if len(os.Args) == 1 { return latest }