aboutsummaryrefslogtreecommitdiff
path: root/2021/day-16
diff options
context:
space:
mode:
authorHJ <thechairman@thechairman.info>2021-12-16 06:31:31 -0500
committerHJ <thechairman@thechairman.info>2021-12-16 06:31:31 -0500
commit9fab205b1d55c34e9876accb819bf72f49cddabb (patch)
tree0e34f494355c8a0866e837dfc2274cbfc9d297b7 /2021/day-16
parent3343d9c53d1cd112831fc74c01630352c2d5ee47 (diff)
downloadgleam_aoc-9fab205b1d55c34e9876accb819bf72f49cddabb.tar.gz
gleam_aoc-9fab205b1d55c34e9876accb819bf72f49cddabb.zip
day 15 using structs; day 16 setup
Diffstat (limited to '2021/day-16')
-rw-r--r--2021/day-16/day-16.rkt30
1 files changed, 30 insertions, 0 deletions
diff --git a/2021/day-16/day-16.rkt b/2021/day-16/day-16.rkt
new file mode 100644
index 0000000..80c2a54
--- /dev/null
+++ b/2021/day-16/day-16.rkt
@@ -0,0 +1,30 @@
+#lang racket
+(require "../../jj-aoc.rkt"
+ threading)
+
+(define data
+ (~> (open-day 16 2021)
+ port->string
+ string-trim
+ string->list))
+
+(define (hex->bin h)
+ (match h
+ [#\0 '(0 0 0 0)]
+ [#\1 '(0 0 0 1)]
+ [#\2 '(0 0 1 0)]
+ [#\3 '(0 0 1 1)]
+ [#\4 '(0 1 0 0)]
+ [#\5 '(0 1 0 1)]
+ [#\6 '(0 1 1 0)]
+ [#\7 '(0 1 1 1)]
+ [#\8 '(1 0 0 0)]
+ [#\9 '(1 0 0 1)]
+ [#\A '(1 0 1 0)]
+ [#\B '(1 0 1 1)]
+ [#\C '(1 1 0 0)]
+ [#\D '(1 1 0 1)]
+ [#\E '(1 1 1 0)]
+ [#\F '(1 1 1 1)]))
+
+(map hex->bin data) \ No newline at end of file