From 8d3cf51a1198a0808ddae4f5dca2f984c26a6dac Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Sun, 4 Dec 2016 23:54:43 -0800 Subject: [PATCH] start day05 --- 2016/day05.rkt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 2016/day05.rkt diff --git a/2016/day05.rkt b/2016/day05.rkt new file mode 100644 index 0000000..3454698 --- /dev/null +++ b/2016/day05.rkt @@ -0,0 +1,15 @@ +#lang br +(require openssl/md5) + +(define key "ojvtpuvg") + +(let loop ([idx 0][password-cs empty]) + (cond + [(= 8 (length password-cs)) + (apply string-append (reverse password-cs))] + [else + (define this-key (format "~a~a" key idx)) + (define next-hash (md5 (open-input-string this-key))) + (if (string-prefix? next-hash "00000") + (loop (add1 idx) (cons (substring next-hash 5 6) password-cs)) + (loop (add1 idx) password-cs))]))