-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestUtil.roc
More file actions
35 lines (23 loc) · 805 Bytes
/
TestUtil.roc
File metadata and controls
35 lines (23 loc) · 805 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
interface TestUtil exposes [ show, verify, ints ] imports []
verify : I64, I64, I64, I64, I64 -> List I64
verify = \day, part, num, actual, expected ->
if actual == expected then
[ 1, day, part, num, actual ]
else
[ 0, day, part, num, expected, actual ]
show : I64, I64, I64 -> List I64
show = \day, part, value ->
[ 2, day, part, value ]
ints : List I64 -> List I64
ints = \input ->
(List.walk input intWalker initialIntAcc).output
IntAcc : { current : I64, output : List I64 }
initialIntAcc : IntAcc
initialIntAcc =
{ current: 0, output: [] }
intWalker : I64, IntAcc -> IntAcc
intWalker = \val, acc ->
if val == 10 then
{ current: 0, output: List.append acc.output acc.current }
else
{ acc & current: 10 * acc.current + val - 48 }