From a5eb8e8a08568cfbad6415643307fa2b83d30a7c Mon Sep 17 00:00:00 2001 From: Alex Karle Date: Sat, 3 Dec 2022 00:41:29 -0500 Subject: [PATCH] Add day3 pt 1 --- 2022/03/input | 300 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2022/03/sample | 6 ++++++ 2022/03/sol.scm | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 348 insertions(+) create mode 100644 2022/03/input create mode 100644 2022/03/sample create mode 100755 2022/03/sol.scm diff --git a/2022/03/input b/2022/03/input new file mode 100644 index 0000000..2825c53 --- /dev/null +++ b/2022/03/input @@ -0,0 +1,300 @@ +QLFdFCdlLcVqdvFLnFLSSShZwptfHHhfZZZpSwfmHp +rTJRjjbJTgzDJjdsRsfwtfNwtfmZpZNhmmzt +bMdJjsjglnVMFCCc +BZvZMBBBMTtZTgcCPdgtgQCrrV +VspNDDpsGDGnRmRpRplQdrrPcPCjgDCcPQCQQj +RVnsmspnpwFRlHGRwHHlnRSThSSvBTbFTZMqTMZMTZFh +ttffrVJWtWpgtQnZGVnNSLTHSZ +jRsjjmhdRcjcRsFcdwGLMZSnHMTSMNZN +RjczlvjhPCcPjcvRpbglWplJBblqrGgq +NwCWwdNQNDCwGpWNQwmJtZgPZrdJgLZcPhLddr +blqpnFTqrLbcLPtV +MnjqSSpqlFRvSqNDGHvWHQDwfWmm +jfLljlQhDLmlrMJQtJTJrQqQ +NpBbjjsdMCgCCMrb +dwspwGnSHHGsGzDDlFDjVWjfZWnP +wQhTZwvpZFZdqWLnnwSrWC +mfDmMFlDcPLdgDSCLCqg +PmzclsMclMlFsHHsJZFHpT +LfLJWNdJnBLfhndfWdZqcgDZgSqgCCSSSLDF +bQVQmrrjPqQDZSZBCQ +RRtG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TbgQnBHsCCHgJBsCsJBHmBmn +wwtvfZztlTVlhtrzzlLNpFFRjMPDpRcPFwRj +VzZhhQHQJJWJSSFWDGclbmNPgglPgVGc +ddBTqCjjBCcrqrCRrwGPGmmDGmbpBGNpNNgg +CRMjwsjwsLdLRrQFJSvMFMWZcHFW +JgJJPvtrhRPQQzSRMQFFSF +BLqsjsdLsMBqblnsGbBqVqdwSQSCSWwNFwczQWCNNwNCHn +ljqbpLbbdDlbDbqDDVtMttTTgpJJgThhJrJr +nflndmjbSnlTQGwvWGPHGRGj +NtstcMcDJMvwgHfFvDgR +qqqpLrMsLLqLNNnzbrdlbZSrznfz +ttZCCFjNjnPVCFQPPFbbStrzqzqrrrcwtmJJ +gTTMRMTWsTGGTddHTTbBzBLSmqbbJGzGmqqb +HpgpMTvRhHHTRDhMsHdHDRhjJlVPJjNFJnnFpQQVfPCjnP +VqJVQPpjQqPBbHwldmLfVVmd +tMGvrzzDGCDDddwLbgLvLwcm +TWDWCzTZDGMZtzWWtsFhbRRqRQRjhbNQBBTh +zgLgLHnnzCCvnsHSsZBZBsTRdD +rslllhJjcQNNGjpWJlSRTRdwBVSSNTPVSdPB +jGrGqjJfqccrfqGcGplrJpFvzggqmCtMzmsMnvMvvCgm diff --git a/2022/03/sample b/2022/03/sample new file mode 100644 index 0000000..f17e726 --- /dev/null +++ b/2022/03/sample @@ -0,0 +1,6 @@ +vJrwpWtwJgWrhcsFMMfFFhFp +jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL +PmmdzqPrVvPwwTWBwg +wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn +ttgJtRGJQctTZtZT +CrZsJsPPZsGzwwsLwLmpwMDw diff --git a/2022/03/sol.scm b/2022/03/sol.scm new file mode 100755 index 0000000..f14ee74 --- /dev/null +++ b/2022/03/sol.scm @@ -0,0 +1,42 @@ +#!/usr/local/bin/chicken-csi -ss +(import (chicken io)) + +(define (prio c) + (if (char-upper-case? c) + (- (char->integer c) 38) ; #\A -> 65 - 38 = 27 + (- (char->integer c) 96))) ; \#a -> 97 - 96 = 1 + +(define (append-if-absent x lst) + (if (member x lst) + lst + (cons x lst))) + +(define (bisect lst) + (let ((len (length lst))) + (define (bi lst a b) + (cond ((null? lst) + (list a b)) + ((> (length lst) (/ len 2)) + (bi (cdr lst) (append-if-absent (car lst) a) b)) + (else + (bi (cdr lst) a (append-if-absent (car lst) b))))) + (bi lst '() '()))) + +(define (score-pack pk) + (let* ((parts (bisect pk)) + (l (car parts)) + (r (cadr parts))) + (apply + + (map + (lambda (x) + (if (member x r) (prio x) 0)) + l)))) + +(define (main args) + (let* ((lines (read-lines)) + (packs (map string->list lines)) + (scores (map score-pack packs))) + (print (car packs)) + (print (bisect (car packs))) + (print (score-pack (car packs))) + (print (apply + scores)))) -- libgit2 1.8.1