Última atividade 3 weeks ago Unlisted

The first day of Advent of Code (only tested on the example inputs).

june's Avatar june revisou este gist 3 weeks ago. Ir para a revisão

1 file changed, 47 insertions

Aoc-Day1-Playground.nv(arquivo criado)

@@ -0,0 +1,47 @@
1 + ||:@include: lib/rpn.nv
2 +
3 + |:: rotate $direction :@rpn data: $n|
4 + :dial: $n
5 + |:: rotate right :dial: 99|
6 + :dial: 0
7 + |:: rotate left :dial: 0|
8 + :dial: 99
9 + |:: rotate right? :dial: $n|
10 + :@rpn: ($n 1 +)
11 + |:: rotate left? :dial: $n|
12 + :@rpn: ($n 1 -)
13 +
14 + |:: rotate $direction 0 times|
15 + |:: rotate $direction $n times :@rpn data: $x|
16 + :: rotate $direction $x times
17 + |:: rotate $direction $n times? :next:|
18 + :@rpn: ($n 1 -)
19 + |:: rotate $direction $n times?|
20 + :: rotate $direction
21 + :next:
22 +
23 + |:: read the rotations? :rotations: $direction $amount|
24 + :: rotate $direction $amount times
25 + :: if the dial is 0, increment the code
26 + |:: read the rotations|
27 +
28 + |:: if the dial is 0, increment the code :@rpn data: $n|
29 + :code: $n
30 + |:: if the dial is 0, increment the code? :dial: 0? :code: $n|
31 + :@rpn: ($n 1 +)
32 + |:: if the dial is 0, increment the code|
33 +
34 + ||:: read the rotations
35 + :dial: 50
36 + :code: 0
37 + :rotations:
38 + . left 68
39 + . left 30
40 + . right 48
41 + . left 5
42 + . right 60
43 + . left 55
44 + . left 1
45 + . left 99
46 + . right 14
47 + . left 82

june's Avatar june revisou este gist 3 weeks ago. Ir para a revisão

1 file changed, 45 insertions

AoC-Day1.nv(arquivo criado)

@@ -0,0 +1,45 @@
1 + |:: rotate $direction :@math: $n|
2 + :dial: $n
3 + |:: rotate right :dial: 99|
4 + :dial: 0
5 + |:: rotate left :dial: 0|
6 + :dial: 99
7 + |:: rotate right? :dial: $n|
8 + :@math: add $n 1
9 + |:: rotate left? :dial: $n|
10 + :@math: subtract $n 1
11 +
12 + |:: rotate $direction 0 times|
13 + |:: rotate $direction $n times :@math: $x|
14 + :: rotate $direction $x times
15 + |:: rotate $direction $n times? :next:|
16 + :@math: subtract $n 1
17 + |:: rotate $direction $n times?|
18 + :: rotate $direction
19 + :next:
20 +
21 + |:: read the rotations? :rotations: $direction $amount|
22 + :: rotate $direction $amount times
23 + :: if the dial is 0, increment the code
24 + |:: read the rotations|
25 +
26 + |:: if the dial is 0, increment the code :@math: $n|
27 + :code: $n
28 + |:: if the dial is 0, increment the code? :dial: 0? :code: $n|
29 + :@math: add 1 $n
30 + |:: if the dial is 0, increment the code|
31 +
32 + ||:: read the rotations
33 + :dial: 50
34 + :code: 0
35 + :rotations:
36 + . left 68
37 + . left 30
38 + . right 48
39 + . left 5
40 + . right 60
41 + . left 55
42 + . left 1
43 + . left 99
44 + . right 14
45 + . left 82
Próximo Anterior