day 21: more minor prettification for no reason
This commit is contained in:
parent
79ff63e453
commit
318749e6b3
13
21.rkt
13
21.rkt
|
@ -9,21 +9,20 @@
|
|||
|
||||
(define (part1 input)
|
||||
(match-define (data lines all-is all-as tainted) input)
|
||||
(define untainted (set-subtract all-is (apply set-union (hash-values tainted))))
|
||||
(for*/sum ([l (in-list lines)] [i (in-set (line-is l))] #:when (set-member? untainted i))
|
||||
(define all-tainted (apply set-union (hash-values tainted)))
|
||||
|
||||
(for*/sum ([l (in-list lines)] [i (in-set (line-is l))] #:unless (set-member? all-tainted i))
|
||||
1))
|
||||
|
||||
(define (part2 input)
|
||||
(match-define (data lines all-is all-as tainted) input)
|
||||
(define edges
|
||||
(define G (undirected-graph
|
||||
(for*/list ([(k v*) (in-hash tainted)] [v (in-set v*)])
|
||||
(list k v)))
|
||||
(define G (undirected-graph edges))
|
||||
(list k v))))
|
||||
(define matching (maximum-bipartite-matching G))
|
||||
|
||||
(string-join
|
||||
(for/list ([val (in-list (sort matching #{string<? (first %1) (first %2)}))])
|
||||
(second val))
|
||||
(map second (sort matching string<? #:key first))
|
||||
","))
|
||||
|
||||
;; parse input file
|
||||
|
|
Loading…
Reference in New Issue