Skip to content

Commit

Permalink
2024 day 25
Browse files Browse the repository at this point in the history
  • Loading branch information
dbut2 committed Dec 25, 2024
1 parent a3f73ec commit f82df65
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 0 deletions.
51 changes: 51 additions & 0 deletions 2024/25/1.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package main

import (
"strings"

"github.com/dbut2/advent-of-code/pkg/harness"
)

func solve(input string) int {
var keys [][5]int
var locks [][5]int

for _, in := range strings.Split(strings.TrimSpace(input), "\n\n") {
heights := [5]int{}
for _, line := range strings.Split(in, "\n") {
for i, c := range line {
if c == '#' {
heights[i]++
}
}
}
if in[0] == '#' {
locks = append(locks, heights)
} else {
keys = append(keys, heights)
}
}

count := 0
for _, key := range keys {
for _, lock := range locks {
fits := true
for i := range len(key) {
if key[i]+lock[i] > 7 {
fits = false
break
}
}
if fits {
count++
}
}
}
return count
}

func main() {
h := harness.New(solve)
h.Expect(1, 3)
h.Run()
}
39 changes: 39 additions & 0 deletions 2024/25/test1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#####
.####
.####
.####
.#.#.
.#...
.....

#####
##.##
.#.##
...##
...#.
...#.
.....

.....
#....
#....
#...#
#.#.#
#.###
#####

.....
.....
#.#..
###..
###.#
###.#
#####

.....
.....
.....
#....
#.#..
#.#.#
#####
Empty file added 2024/25/test2.txt
Empty file.

0 comments on commit f82df65

Please sign in to comment.