diff options
author | H.J <thechairman@thechairman.info> | 2024-10-09 11:36:55 -0400 |
---|---|---|
committer | H.J <thechairman@thechairman.info> | 2024-10-09 11:36:55 -0400 |
commit | 8777ff071f7bb37631baa7b6717ad29961e50911 (patch) | |
tree | 6d59c4ed58e454b960339c3d1151f0a879e8d7cb /aoc2023-racket/day-13/day-13.rkt | |
parent | 6156a9ef7be4012063a042aafb4e9b0d7eadde8e (diff) | |
download | gleam_aoc-8777ff071f7bb37631baa7b6717ad29961e50911.tar.gz gleam_aoc-8777ff071f7bb37631baa7b6717ad29961e50911.zip |
sorting by language
Diffstat (limited to 'aoc2023-racket/day-13/day-13.rkt')
-rw-r--r-- | aoc2023-racket/day-13/day-13.rkt | 47 |
1 files changed, 0 insertions, 47 deletions
diff --git a/aoc2023-racket/day-13/day-13.rkt b/aoc2023-racket/day-13/day-13.rkt deleted file mode 100644 index 47718f8..0000000 --- a/aoc2023-racket/day-13/day-13.rkt +++ /dev/null @@ -1,47 +0,0 @@ -#lang racket - -(require advent-of-code - threading) - -(define input - (~>(fetch-aoc-input (find-session) 2023 13 #:cache #true) - (string-split "\n\n") - (map (λ~> string-split) _))) - -(define (do-symmetric? lefts rights errs) - (cond - [(empty? rights) #f] - [else - (define found-errs - (for/sum ([l (in-string (string-join lefts ""))] - [r (in-string (string-join rights ""))] - #:unless (char=? l r)) - 1)) - (if (= errs found-errs) - (length lefts) - (do-symmetric? (cons (first rights) lefts) - (rest rights) - errs))])) - -(define (symmetric? xss errs) - (do-symmetric? (list (first xss)) (rest xss) errs)) - -(define (transpose strs) - (~> strs - (map string->list _) - (apply map list _) - (map list->string _))) - -(define (find-symmetry-score xss errs) - (cond - [(symmetric? xss errs) => (curry * 100)] - [else (symmetric? (transpose xss) errs)])) - -;; part 1 -(for/sum ([note (in-list input)]) - (find-symmetry-score note 0)) - -;; part 2 -(for/sum ([note (in-list input)]) - (find-symmetry-score note 1)) - |