aboutsummaryrefslogtreecommitdiff
path: root/2021/06/second.go
blob: c64aa61e12b3bc691fb4212bccccdb96003ac95e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	g := make([]int, 9)

	s := bufio.NewReader(os.Stdin)
	for {
		buf := make([]byte, 2)
		if n, _ := s.Read(buf); n == 0 {
			break
		}
		g[buf[0]-'0']++
	}
	for d := 0; d <= 256; d++ {
		fmt.Printf("%+v\n", g)
		n := g[0]
		for i := 0; i < 8; i++ {
			g[i] = g[i+1]
		}
		g[6] += n
		g[8] = n
	}
	total := 0
	for i := 0; i < 8; i++ {
		total += g[i]
	}
	fmt.Printf("%d\n", total)
}