Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
43 lines (37 sloc) 719 Bytes
package main
import (
"fmt"
"log"
"os"
"github.com/dhconnelly/advent-of-code-2019/breakout"
"github.com/dhconnelly/advent-of-code-2019/intcode"
)
func countTiles(
state breakout.GameState,
which breakout.TileId,
) int {
n := 0
for _, tile := range state.Tiles {
if tile == which {
n++
}
}
return n
}
func main() {
data, err := intcode.ReadProgram(os.Args[1])
if err != nil {
log.Fatal(err)
}
state, err := breakout.Play(data, nil, 1, breakout.NEUTRAL)
if err != nil {
log.Fatal(err)
}
fmt.Println(countTiles(state, breakout.BLOCK))
data[0] = 2 // play for free
state, err = breakout.Play(data, nil, 1, breakout.LEFT)
if err != nil {
log.Fatal(err)
}
fmt.Println(state.Score)
}
You can’t perform that action at this time.