From feccf3f6f0a806b3317d1f399e3e8b42945c4f09 Mon Sep 17 00:00:00 2001 From: Hunky Jimpjorps Date: Sat, 26 Nov 2022 01:43:33 -0500 Subject: using raco fmt, replacing missing dependency --- 2021/day-12/day-12.rkt | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) (limited to '2021/day-12') diff --git a/2021/day-12/day-12.rkt b/2021/day-12/day-12.rkt index 76a5aa8..18ed86f 100644 --- a/2021/day-12/day-12.rkt +++ b/2021/day-12/day-12.rkt @@ -11,23 +11,14 @@ (for ([pair (in-list path-pairs)]) (match-define (cons start end) pair) - (hash-update! edges-hash - start - (curry cons end) - '()) - (hash-update! edges-hash - end - (curry cons start) - '())) + (hash-update! edges-hash start (curry cons end) '()) + (hash-update! edges-hash end (curry cons start) '())) ;; part 1 (define (backtracking-disallowed? next prevs) - (and (equal? (string-downcase next) next) - (member next prevs))) + (and (equal? (string-downcase next) next) (member next prevs))) -(define (look-for-next-cave - [path-list '("start")] - #:only-one-visit? [visit-used-up? #t]) +(define (look-for-next-cave [path-list '("start")] #:only-one-visit? [visit-used-up? #t]) (define current-cave (car path-list)) (cond [(equal? current-cave "end") (list path-list)] @@ -38,15 +29,10 @@ visit-used-up?)))) (look-for-next-cave (cons next-path path-list) - #:only-one-visit? (or (backtracking-disallowed? next-path path-list) - visit-used-up?))) + #:only-one-visit? (or (backtracking-disallowed? next-path path-list) visit-used-up?))) (apply append))])) -(~> (look-for-next-cave) - length - time) +(~> (look-for-next-cave) length time) ;; part 2 -(~> (look-for-next-cave #:only-one-visit? #f) - length - time) \ No newline at end of file +(~> (look-for-next-cave #:only-one-visit? #f) length time) -- cgit v1.2.3