Combine AoC Repos
This commit is contained in:
BIN
2015/day18/day18.gif
Normal file
BIN
2015/day18/day18.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 541 KiB |
100
2015/day18/input
Normal file
100
2015/day18/input
Normal file
@@ -0,0 +1,100 @@
|
||||
#...##......#......##.##..#...##......##.#.#.###.#.#..#..#......####..#......###.#.#....#..##..###..
|
||||
####..#.#...#....#.#####.##.##.#..#.......#....#.##...###.###..#.#.#........#..#.#.##...##..#.####.#
|
||||
...#..##...#.#.###.#.###..#.##.####.###...#...........#.###..##.#.##.#.###...#.#..###....#.###.#..#.
|
||||
.#...##...####.#..#.....#..#...#.#.##...#...##..#.#.###....#..###.....##..#.###..###.....##..###...#
|
||||
..##.#####....##..#.#..##.##..######...#..###.######.....#..##...#.#..##..##..#..#..#..##.#.#.#.#...
|
||||
.###.###.###...##...##..###..##.###.#.....##..##.#.#########...##..##.#..##.#..##..####..#.#.#.#####
|
||||
#.#####..###.###.##.##.#...#.#.#.#..#.###...#..##.###.#...####.#..#.#.....###..#..####..#.#.#...##..
|
||||
....#...##.....#....####.##.#.###..#.#.##..#.#...##.###.###..#.##..#.#.##..##..#.##.###..#.#.###.###
|
||||
##.##...#.##...#.#..#.#..#...###...###.#..#..#.#####..###.#......#.....###.#####.#.#..#.#.#.##..#.#.
|
||||
#.#..#.....#.....##.#..##...###..##...##...###.#.###.#..#.#.###...##..##..#.###...#.#######.#...#.#.
|
||||
#.#.....####.#..#.##...#.##....#####.###.#.....#####....###..#........##..####...#...#.###....#..###
|
||||
##.#.##..#.#.##.#.....##.#.....###.####.#..######.....####.#.#..##.#.##...#..#.#.....#.####.#.......
|
||||
#..#..#.#..#.######.##..##.####.....##.#.##.#.######..#.#....#.#...#.#..#..#.#.###.#..#.#.#..#...###
|
||||
####..####.#.#.###.....#.#.#.##..#.##.##.##.#..##..##.#.##.....#.#..#.####.....###.#..#.####.#.#..##
|
||||
###.##..##.#.##..#..##...#.#####.##.#....##.####.#.##....#..###.#.#.##...#.....#.#.#.#.#..##.#.#..#.
|
||||
......#..####...##.##...#.##.##...##..#..##.###..#...#..##...#.#....###.####...#.##.###.#.##.####.##
|
||||
..#...#####.#.#..#.##....#..#...#..####.....###...##.###....#..#.###...#........#.#.##..#..#.#.....#
|
||||
#######.#.#.###.###..######.##..#####.##.###.###....####.#..##.##...###.#..############.#.##....##.#
|
||||
#.#...##.###.#.###..#.#.#.#.#.#..##..####.#..##.....#.##..#.##...##.#..##..#.#.#....##....##.#..#.#.
|
||||
..#.#.####.....###..#######.#.#.#.#...##.#####.....##...##...##.###..######.###..#...####.#..###.###
|
||||
.#.##....#.#.##..##.#.##.##..######...#.....#..#.#.#.#.....#.#..##.#.#.......#######....#.......#...
|
||||
..###.##.##..##....#.###...#.....##..##......###...##..###.##...##.###.#.#.#.###.###.#.#...###..#...
|
||||
.##.#.#...#...##.#.#...#..#..#.#...##.#.##...##..#....#.#..##.#..#.#..#.#.....#..#.#...#######.#.##.
|
||||
...####....#.###.#..###..##...##..#.#.#.###...#..##.##.##..##.#...#..#.##.....#.#........#..#.#.####
|
||||
.....##..###...#....#.#.#.#...###.###...#.#...#.#.####....#..####...###..#..######..##.##..###.#####
|
||||
#####.##..#....###.###....##.....#.#..#....#.#####.##.#.####.#.##...#..###...###..##...#.###.#####..
|
||||
###.##..........########.######....####.###.#..##...#.##.####.#.....##..#####..###...#####.....#.#.#
|
||||
##..#####.##.#.#####.#.##.##..#.##....########.#####.#...#.###.##...#.###.#.#..#....##.#..#...#.#.#.
|
||||
.##.#....#..#...#..#####..#..##.#......#..#....########...#..#...#.....####.#...##...#.###.#.#..##.#
|
||||
.##.##.#.##.#.##...#.#.#..##.##.###.#..##..#...###.##.###.#####.#.###..#..###.#...#.###.#...#..#.#.#
|
||||
.#..#..#.#..#..###..#....###.####.##.#.###.#.##.###.#.##.###.###...###...###.#...####...#.##.##.#.#.
|
||||
###..##...###...#..##.#..#.#...##....###.##.##..#####....###..#..#....#..###.###.#...#.##...#.#.#..#
|
||||
#....#.......##.....#.##...#..#.###.#.##..##..#.##..#.###..##.##...#####.#..#####..#####..#####....#
|
||||
.####.####....###..###.#.##.####.##.#...####.#.###.#.....#...####..#####.###..#.#.###.##.##...##..#.
|
||||
####..##...##.########...##..###..#..###.##.#.#.#........#.#####.#...#.###.####.#..####..#.#.#....##
|
||||
###.#..#...###.#..#..#.###...##..###.##.#.#...#..#...####..##....#.#..#..##.#.#...#####.###.#..#.#.#
|
||||
...##....#.###.#.#..##...##.###.#..#..#......#...#.#..####.#.##..######.####.#...#..#..#..##.#.#.##.
|
||||
##.####.#...#..#.#.##..##.#.#.###..##...####......#..######.#......#.##.#....##...###.#.#..#......##
|
||||
#.....#...#######.##.#..#.#...###.#..#.####....#.#.##.#.##...###..#...#.###.##..#.###..#.##...#####.
|
||||
#####.##...#..#.#.#.......#.##..#####..#####...###..##.#.#..###.#.#####.####..#.#..##...#.##...#.###
|
||||
.##.#..#######.###.#.####.....##...#.##.#.#..#...##....####......######.#..######.....##########.##.
|
||||
##...#.#..#.##.###.#.#.#.##.###.##..##.##.##...#.#..###.#######..#.....#####..#....######.#..##..###
|
||||
.#.#.###.....#..##..#.#..##..#.###...###.#..##...#...#.#####.#.#####..###.#..#...##..#.#..#..####...
|
||||
.#......##..#.....####.###....##.###.....###.##........#.###.##..#..#.#######.#.######..##..###.....
|
||||
..##.#.#..#.##...#.###.###...######..#..#.#..#....###.#.#....#..........#...##.##.##.#..##..#.#####.
|
||||
###.###.#..#.##..##.#..#..##.....##.....#..#######.#..#.#.#.####.###..###.#.#..#.##.##.####.###.####
|
||||
#.#.#..#....########.#..#..#...##..#.##..#.#..##..####...##.....#.##.#.#...########..#.###.#..#.#.##
|
||||
.##.....#...#.#...##.##....###...##..#.####...#..#.#..#..#.##..#.###.##.####.##..####.....##.#.....#
|
||||
....####.#.##.#.##.#..##.#.######.##.####..#...####.#..###.#.#..#..##.#.#.....##.#####.#.####...#.#.
|
||||
#..#####.#####.....##....######..##....#..#.#.###.#####.....##.##.####.#...##...#.##.#.#####.##.#...
|
||||
##.####..###.#....#...#.#.#.#.###.#####.#.####..####...####......##..#..#..#.#.##...########....#...
|
||||
.###.#.#.#.#..####.##.#..######..#.#.###.....#.#......#.#.#.#..####.##...##.#####.#.##..##..#..#.#..
|
||||
.....###...#...#.####.###.#.#.#.#.....#....#.####.###.##.##.##.#######......#.####......#....##.....
|
||||
##..#..#.#.##..#...#..##.##.##..###.#....##.##....####.#.##.###....#.##.#.#.##...##.###...#..#..####
|
||||
...#.#..##..##.#...##.##...#.#......#.#.##..###....####.##...#.#.###.#..#..#.####..##..##..#####.###
|
||||
.##.##..##########.##...#.##.####.#.#######.##.#.##.##..#...##....########.###..##.##.##.#..##.#.#.#
|
||||
#####.#....#.##..#.....#......##.##..#.##.###..##.......###..##.#.###.##.###....####.#..#.###..#.#.#
|
||||
.#...#..#.##....##....#...####....#...#..#...####...########.###.#..##.#.#.##..###..#.#.###.....##.#
|
||||
##..##.....###......#..###.##.####.##.####.#.#....#..#...#..#.#..#.###.#...#...#..##.##...#..#######
|
||||
.....##..###..##...#####.#.#.....###.#.#..####...#.#.#..#..####..##.#..###.####.#....##..###....#..#
|
||||
#.#.##.#....#.#####.#....##...#...##...##....#.#.......#....#..#...###.###.#.####..####....#.##.#.#.
|
||||
..##...##..###.#.#.##.#..#....#.#.....##.###.#.###.###.....#...#.#..#######.#####..#.###...##......#
|
||||
#......###..#....#.#..#.###.##.#...##..###.####.#.#....#.##..#.###..##.#..#####..##.###.....#..###..
|
||||
##.#.##..##.###.#..##.....#.##.....###....##.####.######.#...#..###....#.#...#.##.....###....#..#.#.
|
||||
.##.#.#.#.##..#.#.#..##..#.###.####....#..###.######..####.#.....###.##..#...###.#..######.##.#.##..
|
||||
...##.####.#..##.#####.##.#...##..#..#...#.#.#.#####...#....#..###...#..#....#.#.##.#.######.#..####
|
||||
..#.#.#.#...#.######.#.....#..#.#..###....#.#.########...#....#.#.##..#...##...#.#..#.#.###....##...
|
||||
#####..#..##..#..##..#..#.#.##.#....#####.####.##.#.###..##..##....#.....#.#####.#...#.#####.##.#.#.
|
||||
#.#..#####...####.###.###.....####.###.....##...##...#..#..#######.#.##....##..####.....##...#..#..#
|
||||
#.#.###.#.#..##..#....#.#...#.#.##.##..#.##.....##...#.#..##.......##.#.###..#####.#.##....#.##.....
|
||||
...#.......#....#.#.####.#.###.###..#....#..##.#..####........#.##..#...#.#...###.#..#.#.#...#...#..
|
||||
...##.#####.##.#.###.##.##.#.##..##.#.#.#.#.#.##.#..##...##.#.#..#..##.##.#####.#.###...#####..#..#.
|
||||
#######.#..#..#....##.#.#..####.#..#..###...#..#.......###.#.#.####....#.###...#.#.###.#.#.#.#..###.
|
||||
..##.##.#.##.###....###.##.#.###.#...#....#.####..###..###.#.#..#...##.#.#.#..##.###..###.#.##...###
|
||||
######..######..##..##.#.#.##.##.#..##..#.#.#.##..#.#...#...#.#.#..######.#..#.#.######..#......##.#
|
||||
#.#####.....#.......#########..###.##...#...##.#.#..#...#####...#...#..#.###.#..#.#...###.#.#.#...#.
|
||||
#....##....###...##.##.#...##.........##.#.#..#.#.##.#.######.#####..#..###.###.#...#.#.##.######...
|
||||
#.#...###.#.###.##.#.######.#######.###.##..#.#.#...######.##.####.##..#.#.#.#......##..##.........#
|
||||
..###..##....#.....##...#.#.###.#.#.....##.#...###.####.#...#...##..##.#.#.####..###...######....#.#
|
||||
..###.#.##.####.#..#.##....##..#####....#..##.##.#..#######...#.####...##.#.#.##.........#....#....#
|
||||
.##.#...#.####..#.#...#.##..######.##..##.#.###.##..###.###....##..#.##.##..##.#...###.##.##.###....
|
||||
#...###.###.#..#....#.......#..#.....###..#.###.##.##....#.####.#.####.##..##..#..#.....#....##.#.#.
|
||||
.##.#..#..#.##.......#.####.#######.....#.##.##.#.....#.#..#....######.#..###.##.##.....#.####..##.#
|
||||
###..#.###.#..####.....##....#..####....#.##.##..#...######.#########...#.#....##...###.#..#.##...#.
|
||||
#..###..##..#.#.##.###.#.#.##...###.#...##.##..#.###....###..#.#...#.###..######.#..#.###..#..#..#.#
|
||||
.#........##.#.###..###.#.#.##.....##.##.#.#...##..#.##....###..#.#.#.#.##....#.##..#.#...###...#...
|
||||
####.####..#....#.#.#..#..##.......##.####...###.##..#.#.##.#..##..######.......##.#.##..#...#.....#
|
||||
..#..#..###..##.##..######.#..###..###.#.##..##.#..#####.#.#.#.##..#.##..##.##......####.#..........
|
||||
...##.##..###.#...###....#.#.#.#.....#.##.....##...#...#......####...##.##....##.#..#.####.#..###.#.
|
||||
..#.....####.#.###.#####..#..###..#..#.#...#####...###.###....#.###..#...#..#..#.#..#.##..##.#.#....
|
||||
..##.#####...###.###.........#....##.####.##..#.#..#.#...#...##.##.##..#.#.##.########......#####...
|
||||
...###.#.#..#...#.###.###.......##.###.#..#.##########...#..#.#.#.##.#.###...######..#.#...###.##...
|
||||
.#.#.#######.#..##.##..##...#...####...#..#####.#..##...###.#.#...#.##...#......#..##.####..#.....##
|
||||
.##.##.#.#......#######..###.....##.#.##..###......#....####...#.###.#.##.#........#..#....##.....##
|
||||
#...#.###.#.##...##.####....#...#.###..#.#.....#.#....#.#.#.##...#.#..#####.#.#..#..#..#....#...####
|
||||
.....##...###......#####..##.##.##...##.#.#####..##...#.#.#.#.###...###.##.####..#.#..#.#..#.####.##
|
||||
#..#..##.#.##.#.##.#.#.#..###....###.##.#.##.#...#.#..#...#....###.#..#.#.######.#...####..#..##.#.#
|
||||
#..#.#..#...###.#..##.#...#...##.#......#...#..#..####..##.....#.###...#.#..#.#....#.#####.##.###...
|
||||
###....#.#..#.#..###..#.##......#...#..#..##.#..###..##..#..#.####..#...########..##.#.##.#.#.#...#.
|
||||
.#.#.##.##.###..#...#.#....#..#.##..#.#.#.#.##.##.#####...#........####..###..####.#####..#.##.#.##.
|
211
2015/day18/main.go
Normal file
211
2015/day18/main.go
Normal file
@@ -0,0 +1,211 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
var lights [][]bool
|
||||
|
||||
func main() {
|
||||
ticks := -1
|
||||
speed := 2
|
||||
var hideSim, lockedCorners bool
|
||||
for i := range os.Args {
|
||||
if os.Args[i] == "-help" {
|
||||
fmt.Println("Usage: day18 [-ticks=<num>] [-speed=<num>]")
|
||||
fmt.Println("\t-ticks=<num>\tSpecify how many iterations should be performed")
|
||||
fmt.Println("\t\t\t\tIf not manually set, run forever.")
|
||||
fmt.Println("\t-speed=<num>\tSpecify how many times/second we iterate")
|
||||
fmt.Println("\t-hide\t\tHide the actual simulation (for AoC)")
|
||||
fmt.Println("\t-lockcorners\t\tLock the corner lights 'on' (for AoC pt 2)")
|
||||
os.Exit(1)
|
||||
}
|
||||
if j := strings.Index(os.Args[i], "="); j > 0 {
|
||||
flagKey := os.Args[i][:j]
|
||||
flagVal := os.Args[i][j+1:]
|
||||
if flagKey == "-ticks" {
|
||||
ticks = mustAtoi(flagVal)
|
||||
} else if flagKey == "-speed" {
|
||||
speed = mustAtoi(flagVal)
|
||||
}
|
||||
}
|
||||
if os.Args[i] == "-hide" {
|
||||
hideSim = true
|
||||
}
|
||||
if os.Args[i] == "-lockcorners" {
|
||||
lockedCorners = true
|
||||
}
|
||||
}
|
||||
if hideSim && ticks == -1 {
|
||||
// Doesn't make sense to run this configuration
|
||||
fmt.Println("You asked to run indefinitely and hide the simulation...")
|
||||
fmt.Println("Refusing to needlessly consume your CPU.")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
var input []string
|
||||
scanner := bufio.NewScanner(os.Stdin)
|
||||
for scanner.Scan() {
|
||||
input = append(input, scanner.Text())
|
||||
}
|
||||
|
||||
for i := range input {
|
||||
var bldRow []bool
|
||||
for j := range input[i] {
|
||||
bldRow = append(bldRow, (input[i][j] == '#'))
|
||||
}
|
||||
lights = append(lights, bldRow)
|
||||
}
|
||||
|
||||
if !hideSim {
|
||||
cls()
|
||||
printLights(lights)
|
||||
}
|
||||
for i := 0; i < ticks || ticks == -1; i++ {
|
||||
if lockedCorners {
|
||||
lights = lockCorners(lights)
|
||||
}
|
||||
lights = tick(lights)
|
||||
if lockedCorners {
|
||||
lights = lockCorners(lights)
|
||||
}
|
||||
if !hideSim {
|
||||
cls()
|
||||
printLights(lights)
|
||||
}
|
||||
if !hideSim {
|
||||
// No reason to sleep if we're hiding the simulation
|
||||
time.Sleep(time.Second / time.Duration(speed))
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Println("After " + strconv.Itoa(ticks) + " ticks, " + strconv.Itoa(countLights(lights)) + " are on")
|
||||
}
|
||||
|
||||
func lockCorners(c [][]bool) [][]bool {
|
||||
c[0][0] = true
|
||||
c[0][len(c[0])-1] = true
|
||||
c[len(c)-1][0] = true
|
||||
c[len(c)-1][len(c[0])-1] = true
|
||||
return c
|
||||
}
|
||||
|
||||
func cls() {
|
||||
cmd := exec.Command("clear")
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Run()
|
||||
}
|
||||
|
||||
func printLights(curr [][]bool) {
|
||||
for i := range curr {
|
||||
for j := range curr {
|
||||
if curr[i][j] {
|
||||
fmt.Print("#")
|
||||
} else {
|
||||
fmt.Print(".")
|
||||
}
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
}
|
||||
|
||||
func tick(curr [][]bool) [][]bool {
|
||||
var next [][]bool
|
||||
for i := range curr {
|
||||
var bldRow []bool
|
||||
for j := range curr[i] {
|
||||
num := checkNeighbors(curr, i, j)
|
||||
var newVal bool
|
||||
if curr[i][j] {
|
||||
// On proc
|
||||
if num == 2 || num == 3 {
|
||||
newVal = true
|
||||
}
|
||||
} else {
|
||||
// Off proc
|
||||
if num == 3 {
|
||||
newVal = true
|
||||
}
|
||||
}
|
||||
bldRow = append(bldRow, newVal)
|
||||
}
|
||||
next = append(next, bldRow)
|
||||
}
|
||||
return next
|
||||
}
|
||||
|
||||
// Returns how many neighbors are on
|
||||
func checkNeighbors(curr [][]bool, i, j int) int {
|
||||
var ret int
|
||||
// nw
|
||||
if isOn(curr, (i - 1), (j - 1)) {
|
||||
ret++
|
||||
}
|
||||
// n
|
||||
if isOn(curr, (i - 1), j) {
|
||||
ret++
|
||||
}
|
||||
// ne
|
||||
if isOn(curr, (i - 1), (j + 1)) {
|
||||
ret++
|
||||
}
|
||||
// w
|
||||
if isOn(curr, i, (j - 1)) {
|
||||
ret++
|
||||
}
|
||||
// e
|
||||
if isOn(curr, i, (j + 1)) {
|
||||
ret++
|
||||
}
|
||||
// sw
|
||||
if isOn(curr, (i + 1), (j - 1)) {
|
||||
ret++
|
||||
}
|
||||
// s
|
||||
if isOn(curr, (i + 1), j) {
|
||||
ret++
|
||||
}
|
||||
// se
|
||||
if isOn(curr, (i + 1), (j + 1)) {
|
||||
ret++
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
func isOn(curr [][]bool, i, j int) bool {
|
||||
if i < 0 || i >= len(curr) {
|
||||
return false
|
||||
}
|
||||
if j < 0 || j >= len(curr[i]) {
|
||||
return false
|
||||
}
|
||||
return curr[i][j]
|
||||
}
|
||||
|
||||
func countLights(c [][]bool) int {
|
||||
var ttl int
|
||||
for i := range c {
|
||||
for j := range c[i] {
|
||||
if c[i][j] {
|
||||
ttl++
|
||||
}
|
||||
}
|
||||
}
|
||||
return ttl
|
||||
}
|
||||
|
||||
func mustAtoi(s string) int {
|
||||
var i int
|
||||
var err error
|
||||
if i, err = strconv.Atoi(s); err != nil {
|
||||
fmt.Println("Tried to atoi " + s)
|
||||
os.Exit(1)
|
||||
}
|
||||
return i
|
||||
}
|
180
2015/day18/problem
Normal file
180
2015/day18/problem
Normal file
@@ -0,0 +1,180 @@
|
||||
Advent of Code
|
||||
|
||||
br0xen 40*
|
||||
|
||||
• [About]
|
||||
• [Stats]
|
||||
• [Leaderboard]
|
||||
• [Settings]
|
||||
• [Log out]
|
||||
|
||||
--- Day 18: Like a GIF For Your Yard ---
|
||||
|
||||
After the million lights incident, the fire code has gotten stricter: now, at most ten thousand
|
||||
lights are allowed. You arrange them in a 100x100 grid.
|
||||
|
||||
Never one to let you down, Santa again mails you instructions on the ideal lighting
|
||||
configuration. With so few lights, he says, you'll have to resort to animation.
|
||||
|
||||
Start by setting your lights to the included initial configuration (your puzzle input). A #
|
||||
means "on", and a . means "off".
|
||||
|
||||
Then, animate your grid in steps, where each step decides the next configuration based on the
|
||||
current one. Each light's next state (either on or off) depends on its current state and the
|
||||
current states of the eight lights adjacent to it (including diagonals). Lights on the edge of
|
||||
the grid might have fewer than eight neighbors; the missing ones always count as "off".
|
||||
|
||||
For example, in a simplified 6x6 grid, the light marked A has the neighbors numbered 1 through
|
||||
8, and the light marked B, which is on an edge, only has the neighbors marked 1 through 5:
|
||||
|
||||
1B5...
|
||||
234...
|
||||
......
|
||||
..123.
|
||||
..8A4.
|
||||
..765.
|
||||
|
||||
The state a light should have next is based on its current state (on or off) plus the number of
|
||||
neighbors that are on:
|
||||
|
||||
• A light which is on stays on when 2 or 3 neighbors are on, and turns off otherwise.
|
||||
• A light which is off turns on if exactly 3 neighbors are on, and stays off otherwise.
|
||||
|
||||
All of the lights update simultaneously; they all consider the same current state before moving
|
||||
to the next.
|
||||
|
||||
Here's a few steps from an example configuration of another 6x6 grid:
|
||||
|
||||
Initial state:
|
||||
.#.#.#
|
||||
...##.
|
||||
#....#
|
||||
..#...
|
||||
#.#..#
|
||||
####..
|
||||
|
||||
After 1 step:
|
||||
..##..
|
||||
..##.#
|
||||
...##.
|
||||
......
|
||||
#.....
|
||||
#.##..
|
||||
|
||||
After 2 steps:
|
||||
..###.
|
||||
......
|
||||
..###.
|
||||
......
|
||||
.#....
|
||||
.#....
|
||||
|
||||
After 3 steps:
|
||||
...#..
|
||||
......
|
||||
...#..
|
||||
..##..
|
||||
......
|
||||
......
|
||||
|
||||
After 4 steps:
|
||||
......
|
||||
......
|
||||
..##..
|
||||
..##..
|
||||
......
|
||||
......
|
||||
|
||||
After 4 steps, this example has four lights on.
|
||||
|
||||
In your grid of 100x100 lights, given your initial configuration, how many lights are on after
|
||||
100 steps?
|
||||
|
||||
Your puzzle answer was 814.
|
||||
|
||||
--- Part Two ---
|
||||
|
||||
You flip the instructions over; Santa goes on to point out that this is all just an
|
||||
implementation of Conway's Game of Life. At least, it was, until you notice that something's
|
||||
wrong with the grid of lights you bought: four lights, one in each corner, are stuck on and
|
||||
can't be turned off. The example above will actually run like this:
|
||||
|
||||
Initial state:
|
||||
##.#.#
|
||||
...##.
|
||||
#....#
|
||||
..#...
|
||||
#.#..#
|
||||
####.#
|
||||
|
||||
After 1 step:
|
||||
#.##.#
|
||||
####.#
|
||||
...##.
|
||||
......
|
||||
#...#.
|
||||
#.####
|
||||
|
||||
After 2 steps:
|
||||
#..#.#
|
||||
#....#
|
||||
.#.##.
|
||||
...##.
|
||||
.#..##
|
||||
##.###
|
||||
|
||||
After 3 steps:
|
||||
#...##
|
||||
####.#
|
||||
..##.#
|
||||
......
|
||||
##....
|
||||
####.#
|
||||
|
||||
After 4 steps:
|
||||
#.####
|
||||
#....#
|
||||
...#..
|
||||
.##...
|
||||
#.....
|
||||
#.#..#
|
||||
|
||||
After 5 steps:
|
||||
##.###
|
||||
.##..#
|
||||
.##...
|
||||
.##...
|
||||
#.#...
|
||||
##...#
|
||||
|
||||
After 5 steps, this example now has 17 lights on.
|
||||
|
||||
In your grid of 100x100 lights, given your initial configuration, but with the four corners
|
||||
always in the on state, how many lights are on after 100 steps?
|
||||
|
||||
Your puzzle answer was 924.
|
||||
|
||||
Both parts of this puzzle are complete! They provide two gold stars: **
|
||||
|
||||
At this point, you should return to your advent calendar and try another puzzle.
|
||||
|
||||
If you still want to see it, you can get your puzzle input.
|
||||
|
||||
You can also [Shareon Twitter Google+ Reddit] this puzzle.
|
||||
|
||||
References
|
||||
|
||||
Visible links
|
||||
. http://adventofcode.com/
|
||||
. http://adventofcode.com/about
|
||||
. http://adventofcode.com/stats
|
||||
. http://adventofcode.com/leaderboard
|
||||
. http://adventofcode.com/settings
|
||||
. http://adventofcode.com/auth/logout
|
||||
. http://adventofcode.com/day/6
|
||||
. https://en.wikipedia.org/wiki/Conway's_Game_of_Life
|
||||
. http://adventofcode.com/
|
||||
. http://adventofcode.com/day/18/input
|
||||
. https://twitter.com/intent/tweet?text=I%27ve+completed+%22Like+a+GIF+For+Your+Yard%22+%2D+Day+18+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F18&related=ericwastl&hashtags=AdventOfCode
|
||||
. https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F18
|
||||
. http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F18&title=I%27ve+completed+%22Like+a+GIF+For+Your+Yard%22+%2D+Day+18+%2D+Advent+of+Code
|
6
2015/day18/sample_input
Normal file
6
2015/day18/sample_input
Normal file
@@ -0,0 +1,6 @@
|
||||
.#.#.#
|
||||
...##.
|
||||
#....#
|
||||
..#...
|
||||
#.#..#
|
||||
####..
|
Reference in New Issue
Block a user