Day 6
This commit is contained in:
26
day06/ex2/main.go
Normal file
26
day06/ex2/main.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
"aoc2022/day06/common"
|
||||
)
|
||||
|
||||
func main() {
|
||||
signal := common.Parse(*bufio.NewScanner(os.Stdin))
|
||||
index := 0
|
||||
|
||||
for i := 14; i <= len(signal); i++ {
|
||||
set := make(map[rune]bool)
|
||||
for _, c := range signal[i-14:i] {
|
||||
set[c] = true
|
||||
}
|
||||
if len(set) == 14 {
|
||||
index = i
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Println(index)
|
||||
}
|
||||
Reference in New Issue
Block a user