From 318749e6b3f5b6c32d07674dfb2702c6e94b915b Mon Sep 17 00:00:00 2001 From: haskal Date: Mon, 21 Dec 2020 01:55:22 -0500 Subject: [PATCH] day 21: more minor prettification for no reason --- 21.rkt | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/21.rkt b/21.rkt index e928b8a..3808d54 100644 --- a/21.rkt +++ b/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 - (for*/list ([(k v*) (in-hash tainted)] [v (in-set v*)]) - (list k v))) - (define G (undirected-graph edges)) + (define G (undirected-graph + (for*/list ([(k v*) (in-hash tainted)] [v (in-set v*)]) + (list k v)))) (define matching (maximum-bipartite-matching G)) (string-join - (for/list ([val (in-list (sort matching #{string