File tree 2 files changed +34
-1
lines changed 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change 26
26
(define test-inputs
27
27
(list "abcdef " "bababc " "abbcde " "abcccd " "aabcdd " "abcdee " "ababab " ))
28
28
29
- (= 12 (solve-puzzle test-inputs))
29
+ (= 12 (solve-puzzle test-inputs))
30
+
31
+ ;(solve-puzzle (file->lines "day2_1-input.txt"))
Original file line number Diff line number Diff line change
1
+ #lang racket
2
+
3
+ (require threading)
4
+
5
+ (define (find-equals full-list word)
6
+ (~>> full-list
7
+ (map (λ (ele)
8
+ (foldr (λ (ele acc)
9
+ (if (equal? (car ele) (cdr ele))
10
+ (cons (car ele) acc)
11
+ acc))
12
+ (list)
13
+ (map cons word ele))))
14
+ (filter (λ (e) (= (sub1 (length word))
15
+ (length e))))))
16
+
17
+ (define (solve-puzzle input)
18
+ (let ([mapped (map string->list input)])
19
+ (~>> mapped
20
+ (map (curry find-equals mapped))
21
+ (filter (compose not empty?))
22
+ (first)
23
+ (flatten)
24
+ (list->string))))
25
+
26
+ (define test-input
27
+ (list "abcde " "fghij " "klmno " "pqrst " "fguij " "axcye " "wvxyz " ))
28
+
29
+ (equal? "fgij " (solve-puzzle test-input))
30
+
31
+ ;(solve-puzzle (file->lines "day2_1-input.txt"))
You can’t perform that action at this time.
0 commit comments