This commit is contained in:
2022-12-10 13:32:55 +01:00
parent 2a84a2e73f
commit 5b8b07a37e
4 changed files with 154 additions and 2 deletions

23
day10/ex1/main.go Normal file
View File

@@ -0,0 +1,23 @@
package main
import (
"bufio"
"fmt"
"os"
"aoc2022/day10/common"
)
func main() {
program := common.Parse(*bufio.NewScanner(os.Stdin))
cpu := common.NewCPU()
strength := 0
program.ExecuteCycles(cpu, 19)
strength += cpu.GetRegisterValue("X") * 20
for i := 1; i <= 5; i ++ {
program.ExecuteCycles(cpu, 40)
strength += cpu.GetRegisterValue("X") * (20 + i*40)
}
fmt.Println(strength)
}