24 lines
416 B
Go
24 lines
416 B
Go
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)
|
|
}
|