You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
aoc-racket/2016/day05.rkt

16 lines
461 B
Racket

#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))]))