Day 5, part 2.
This commit is contained in:
parent
ec2c98f960
commit
6185736ef6
2 changed files with 41 additions and 2 deletions
27
2018/day05-2.go
Normal file
27
2018/day05-2.go
Normal file
|
@ -0,0 +1,27 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"internal/polymer"
|
||||
"internal/util"
|
||||
)
|
||||
|
||||
func main() {
|
||||
data := util.ReadInputBytes()
|
||||
result := [26][]byte{}
|
||||
|
||||
for i := 0; i < 26; i++ {
|
||||
result[i] = polymer.StripElement(data, rune('a'+i))
|
||||
result[i] = polymer.ApplyReactions(result[i])
|
||||
}
|
||||
|
||||
shortest := len(result[0])
|
||||
for i := 1; i < 26; i++ {
|
||||
if len(result[i]) < shortest {
|
||||
shortest = len(result[i])
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Println(shortest)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue