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

34
day10/ex2/main.go Normal file
View File

@@ -0,0 +1,34 @@
package main
import (
"aoc2022/day10/common"
"bufio"
"fmt"
"os"
)
func main() {
program := common.Parse(*bufio.NewScanner(os.Stdin))
cpu := common.NewCPU()
screen := [240]rune{}
i := 0
done := false
for !done {
xValue := cpu.GetRegisterValue("X")
if xValue >= (i % 40) - 1 && xValue <= (i % 40) + 1 {
screen[i] = '#'
} else {
screen[i] = '.'
}
done = program.ExecuteCycles(cpu, 1)
i = (i + 1) % 240
}
for i := 0; i < 6; i++ {
for j := 0; j < 40; j++ {
fmt.Print(string(screen[i*40+j]))
}
fmt.Println()
}
}