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/day06/lang.rkt

19 lines
599 B
Racket

8 years ago
#lang br/quicklang
8 years ago
(provide read-syntax)
8 years ago
(define (read-syntax path port)
(strip-bindings
8 years ago
#`(module mod "lang.rkt"
8 years ago
(solve #,@(string-split (port->string port))))))
(module+ reader (provide read-syntax))
(require sugar/list)
(define (solve . ws)
(define-values (s1 s2)
(for/lists (acc acc2) ([vert-cs (in-list (apply map list (map string->list ws)))])
(define freqs (hash->list (frequency-hash vert-cs)))
(values (car (argmax cdr freqs)) (car (argmin cdr freqs)))))
(displayln (list->string s1))
(displayln (list->string s2)))
(provide solve)
(provide #%module-begin)