diff --git a/day10/input.ivy b/day10/input.ivy new file mode 100644 index 0000000..30bc07e --- /dev/null +++ b/day10/input.ivy @@ -0,0 +1 @@ +input = 1 5 0 -1 0 3 29 -1 -21 5 0 -20 21 2 8 -1 0 0 0 0 6 -1 -37 40 -10 -25 5 2 5 0 0 0 21 -20 2 0 3 2 -5 12 3 0 2 3 -2 -37 1 5 3 -2 2 29 -22 13 0 -8 -6 7 2 0 7 -2 5 2 -26 -11 0 0 6 1 1 0 4 5 0 0 -2 3 0 2 5 2 -22 27 -1 1 5 2 0 -39 22 0 -15 3 -2 2 -2 9 3 0 2 3 -2 2 0 0 0 5 -17 24 -7 8 -36 2 3 33 -32 4 1 0 5 0 0 20 -15 4 0 1 0 4 6 -30 30 0 0 0 0 0 diff --git a/day10/sample.ivy b/day10/sample.ivy new file mode 100644 index 0000000..a69db8c --- /dev/null +++ b/day10/sample.ivy @@ -0,0 +1 @@ +sample = 15 -11 6 -3 5 -1 -8 13 4 0 -1 5 -1 5 -1 5 -1 5 -1 -35 1 24 -19 1 16 -11 0 0 21 -15 0 0 -3 9 1 -3 8 1 5 0 0 0 0 0 -36 0 1 7 0 0 0 2 6 0 0 0 0 0 1 0 0 7 1 0 -13 13 7 0 1 -33 0 0 0 2 0 0 0 8 0 -1 2 1 0 17 -9 1 1 -3 11 0 0 1 0 1 0 0 -13 -19 1 3 26 -30 12 -1 3 1 0 0 0 -9 18 1 2 0 0 9 0 0 0 -1 2 -37 1 3 0 15 -21 22 -6 1 0 2 1 0 -10 0 0 20 1 2 2 -6 -11 0 0 0 diff --git a/day10/sol.ivy b/day10/sol.ivy new file mode 100644 index 0000000..337130c --- /dev/null +++ b/day10/sol.ivy @@ -0,0 +1,16 @@ +) get "input.ivy" + +op run ins = + ((1 + ins != 0), 0) sel +\ 1, ins + +op signal xs = + n = rho xs + i = (20 == (iota n) mod 40) sel iota n + +/ xs[i] * i + +op render xs = + px = 2 > abs xs - ((-1 + iota rho xs) mod 40) + 6 40 rho '.#'[1 + px] + +signal run input +render run input