Didn't need that file

This commit is contained in:
Brian Buller 2021-12-19 10:48:18 -06:00
parent 4c8c1f2a9c
commit 91595691b5

View File

@ -1,58 +0,0 @@
package main
import (
"fmt"
h "git.bullercodeworks.com/brian/adventofcode/helpers"
)
func main() {
inp := h.StdinToStringSlice()
build := inp[0]
for _, v := range inp[1:] {
build = fmt.Sprintf("[%s,%s]", build, v)
}
// Keep on steppin' until no change happens
var wrk string
var done bool
for !done {
wrk = step(build)
done = wrk == build
build = wrk
}
fmt.Println(wrk)
}
var steps int
func step(inp string) string {
steps++
// Find the first number that needs to explode.
wrk := explode(inp)
if wrk != inp {
return wrk
}
// Nothing exploded, look for a split.
return split(inp)
}
func explode(inp string) string {
var depth int
for i := range inp {
if inp[i] == '[' {
if depth == 4 {
// Explode the leftmost pair from here
}
depth++
} else if inp[i] == ']' {
depth--
}
}
}
func split(inp string) string {
return inp
}