diff options
author | Julien Dessaux | 2021-12-16 20:49:45 +0100 |
---|---|---|
committer | Julien Dessaux | 2021-12-16 20:49:45 +0100 |
commit | f169c1bbd9863966a94a07b3972518259710a6b2 (patch) | |
tree | 837f8b9052e199c84322865c8304ae54e9d17ad5 /2021/16/first.go | |
parent | Added solutions for 15th day: Chiton shortest path exercises (diff) | |
download | advent-of-code-f169c1bbd9863966a94a07b3972518259710a6b2.tar.gz advent-of-code-f169c1bbd9863966a94a07b3972518259710a6b2.tar.bz2 advent-of-code-f169c1bbd9863966a94a07b3972518259710a6b2.zip |
Added solutions for 16th day: Packet Decoder
Diffstat (limited to '2021/16/first.go')
-rw-r--r-- | 2021/16/first.go | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/2021/16/first.go b/2021/16/first.go new file mode 100644 index 0000000..df0d644 --- /dev/null +++ b/2021/16/first.go @@ -0,0 +1,33 @@ +package main + +import ( + "bufio" + "fmt" + "os" + + "git.adyxax.org/aoc/2021/16/bits" +) + +var ( + score = 0 +) + +func computeScore(b *bits.Bits) { + score += int(b.Version) + for _, sub := range b.Operators { + computeScore(sub) + } +} + +func main() { + scanner := bits.NewScanner(bufio.NewReader(os.Stdin)) + for { + b := scanner.Scan() + fmt.Println(b) + if b == nil { + break + } + computeScore(b) + } + fmt.Println(score) +} |