Day 10
This commit is contained in:
23
day10/ex1/main.go
Normal file
23
day10/ex1/main.go
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user