diff --git a/OUTPUT b/OUTPUT index 86fd548..8a1fb49 100644 --- a/OUTPUT +++ b/OUTPUT @@ -381,3 +381,21 @@ ex2.bash : res=650080463519 ex2-c : res=650080463519 time: 0:00.00 real, 0.00 user, 0.00 sys context-switch: 0+1, page-faults: 0+71 + +========================================= +================= day17 ================= +========================================= + ++++++++++++++++++ ex1 +ex1-v1.bash : res=263 + time: 1:25.64 real, 61.31 user, 30.44 sys + context-switch: 5732+166356, page-faults: 0+7279275 + +ex1.bash : res=263 + time: 0:00.40 real, 0.40 user, 0.00 sys + context-switch: 41+1, page-faults: 0+315 + ++++++++++++++++++ ex2 +ex2.bash : res=1680 + time: 0:07.88 real, 7.87 user, 0.00 sys + context-switch: 815+1, page-faults: 0+2637 diff --git a/day17/Makefile b/day17/Makefile index b472b5b..2678d58 100644 --- a/day17/Makefile +++ b/day17/Makefile @@ -16,11 +16,12 @@ output: compile: ex1-c ex2-c ex1: + @$(TIME) ex1-v1.bash < $(INPUT) 2>&1 @$(TIME) ex1.bash < $(INPUT) 2>&1 @#$(TIME) ex1-c 2020 < $(INPUT) 2>&1 ex2: - @#$(TIME) ex2.bash < $(INPUT) 2>&1 + @$(TIME) ex2.bash < $(INPUT) 2>&1 @#$(TIME) ex1-c 30000000 < $(INPUT) 2>&1 clean: diff --git a/day17/OUTPUT b/day17/OUTPUT index d62d913..f2fbd3f 100644 --- a/day17/OUTPUT +++ b/day17/OUTPUT @@ -1,4 +1,11 @@ -ex1.bash : res=263 - time: 1:24.06 real, 60.13 user, 30.29 sys - context-switch: 5369+166373, page-faults: 0+7362621 +ex1-v1.bash : res=263 + time: 1:25.64 real, 61.31 user, 30.44 sys + context-switch: 5732+166356, page-faults: 0+7279275 +ex1.bash : res=263 + time: 0:00.40 real, 0.40 user, 0.00 sys + context-switch: 41+1, page-faults: 0+315 + +ex2.bash : res=1680 + time: 0:07.88 real, 7.87 user, 0.00 sys + context-switch: 815+1, page-faults: 0+2637 diff --git a/day17/README b/day17/README index 9e568b6..13914eb 100644 --- a/day17/README +++ b/day17/README @@ -145,8 +145,6 @@ After the full six-cycle boot process completes, 112 cubes are left in the activ Starting with your given initial configuration, simulate six cycles. How many cubes are left in the active state after the sixth cycle? Your puzzle answer was 263. - -The first half of this puzzle is complete! It provides one gold star: * --- Part Two --- For some reason, your simulated results don't match what the experimental energy source engineers expected. Apparently, the pocket dimension actually has four spatial dimensions, not three. @@ -398,8 +396,12 @@ After the full six-cycle boot process completes, 848 cubes are left in the activ Starting with your given initial configuration, simulate six cycles in a 4-dimensional space. How many cubes are left in the active state after the sixth cycle? -Answer: +Your puzzle answer was 1680. -Although it hasn't changed, you can still get your puzzle input. +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 [Share] this puzzle. diff --git a/day17/ex1-v1.bash b/day17/ex1-v1.bash new file mode 100755 index 0000000..e1a9576 --- /dev/null +++ b/day17/ex1-v1.bash @@ -0,0 +1,109 @@ +#!/bin/bash +# +# ex1.bash: Advent2020 game, day 17/game 1. + +CMD=${0##*/} +#shopt -s extglob + +declare -A life=() +declare -i x=-1 y=-1 z=-1 res=0 +declare -i maxx maxy maxz + +function print_life() { + local -i x=0 y=0 z=0 foundx foundy + for ((z=0; z&2 + echo "$count" +} + +function run_cycle () { + local -i x y z count=0 + local -A lifetmp=() + + for ((x=0; x&2 - echo "$count" -} -function run_cycle () { - local -i x y z count=0 - local -A lifetmp=() - - for ((x=0; x