Day 10.
This commit is contained in:
parent
bc98c92d53
commit
b7faf7c961
|
@ -0,0 +1,92 @@
|
||||||
|
47
|
||||||
|
61
|
||||||
|
131
|
||||||
|
15
|
||||||
|
98
|
||||||
|
123
|
||||||
|
32
|
||||||
|
6
|
||||||
|
137
|
||||||
|
111
|
||||||
|
25
|
||||||
|
28
|
||||||
|
107
|
||||||
|
20
|
||||||
|
99
|
||||||
|
36
|
||||||
|
2
|
||||||
|
97
|
||||||
|
88
|
||||||
|
124
|
||||||
|
138
|
||||||
|
75
|
||||||
|
112
|
||||||
|
52
|
||||||
|
122
|
||||||
|
78
|
||||||
|
46
|
||||||
|
110
|
||||||
|
41
|
||||||
|
64
|
||||||
|
63
|
||||||
|
16
|
||||||
|
93
|
||||||
|
104
|
||||||
|
105
|
||||||
|
91
|
||||||
|
27
|
||||||
|
45
|
||||||
|
119
|
||||||
|
14
|
||||||
|
1
|
||||||
|
65
|
||||||
|
62
|
||||||
|
118
|
||||||
|
37
|
||||||
|
79
|
||||||
|
77
|
||||||
|
19
|
||||||
|
71
|
||||||
|
35
|
||||||
|
130
|
||||||
|
69
|
||||||
|
5
|
||||||
|
44
|
||||||
|
9
|
||||||
|
48
|
||||||
|
125
|
||||||
|
136
|
||||||
|
103
|
||||||
|
140
|
||||||
|
53
|
||||||
|
126
|
||||||
|
106
|
||||||
|
55
|
||||||
|
129
|
||||||
|
139
|
||||||
|
87
|
||||||
|
68
|
||||||
|
21
|
||||||
|
85
|
||||||
|
76
|
||||||
|
31
|
||||||
|
113
|
||||||
|
12
|
||||||
|
100
|
||||||
|
24
|
||||||
|
96
|
||||||
|
82
|
||||||
|
13
|
||||||
|
70
|
||||||
|
72
|
||||||
|
86
|
||||||
|
26
|
||||||
|
117
|
||||||
|
58
|
||||||
|
132
|
||||||
|
114
|
||||||
|
40
|
||||||
|
54
|
||||||
|
133
|
||||||
|
51
|
||||||
|
92
|
|
@ -0,0 +1,24 @@
|
||||||
|
#lang curly-fn racket
|
||||||
|
|
||||||
|
(require "../lib.rkt")
|
||||||
|
|
||||||
|
(define input (sort (map string->number (problem-input 10)) <=))
|
||||||
|
|
||||||
|
(define part1
|
||||||
|
(let* ([input (cons 0 input)]
|
||||||
|
[diffs (for/list ([i (rest input)] [j input]) (- i j))]
|
||||||
|
[ones (count #{= % 1} diffs)]
|
||||||
|
[threes (add1 (count #{= % 3} diffs))])
|
||||||
|
(* ones threes)))
|
||||||
|
|
||||||
|
(define arrangements
|
||||||
|
(for*/fold ([arrs (hash 0 1)])
|
||||||
|
([joltage input]
|
||||||
|
[i (range 1 4)])
|
||||||
|
(let ([prev (hash-ref arrs (- joltage i) 0)])
|
||||||
|
(hash-update arrs joltage #{+ % prev} 0))))
|
||||||
|
|
||||||
|
(define part2
|
||||||
|
(hash-ref arrangements (last input)))
|
||||||
|
|
||||||
|
(show-solution part1 part2)
|
Loading…
Reference in New Issue