fde919ef9d7678ac461d3021a0685e34b4e1becf — Robert A. Uhl 10 months ago b33d3df
Solutions for day 2
1 files changed, 297 insertions(+), 0 deletions(-)

A 2018-12-02.lisp
A 2018-12-02.lisp => 2018-12-02.lisp +297 -0
@@ 0,0 1,297 @@
+ (defpackage "AOC/2" (:use "CL"))
+ (in-package "AOC/2")
+ 
+ (defvar *input* "revtoubfniyhzsgxdowjwkqglp
+ revtcgbfniyhzsvxdomjwkqmlp
+ cevtcubfniyhqsgxdoakwkqmlp
+ revtcubfniyhzsgxdtavwkqmep
+ reutcuboniyhzmgxdoajwkqmlp
+ revtcubfniyhzsgxxqajmkqmlp
+ rwvtcvbfniyhzsgxdozjwkqmlp
+ qevtcbbfniyhzsgxdoljwkqmlp
+ rnvtcmbfniyhzsuxdoajwkqmlp
+ revtcubfsiyhzsgxdaaewkqmlp
+ revtcubfpiyhesgxhoajwkqmlp
+ revtcubfnivhzsuxdoljwkqmlp
+ retpcubwniyhzsgxdoajwkqmlp
+ revrcubfniyhzsgxdyajhkqmlp
+ revtcbbfniyhzsixdoajwvqmlp
+ revtcubfniyhzsgxdoanmkqmpp
+ jevtoubfnuyhzsgxdoajwkqmlp
+ rpwtcubfniehzsgxdoajwkqmlp
+ revhcubfniyhnsgxdoajwkxmlp
+ revtcubfniyhzswxdodjwkqvlp
+ reotcubfciyhzsgxdnajwkqmlp
+ revtcubfniyhzsgxdbatwsqmlp
+ rlvbcubfniyhzssxdoajwkqmlp
+ rentcubfnyyhzsgxdozjwkqmlp
+ revtcuufniyhasgxdohjwkqmlp
+ jevtcubfniyhxsgxdoajwkqwlp
+ ravtcubfnryhzfgxdoajwkqmlp
+ reltcubfnvyhzsgxdoajwkumlp
+ revtrubfnschzsgxdoajwkqmlp
+ uevtcubanichzsgxdoajwkqmlp
+ revtcubfniyhzdpxdoajwwqmlp
+ revtcubfhiyhzsgxdoajgkqplp
+ revtcubfniyxzygxdoajwkqmld
+ revtcunfniyfzsgxdoajwkqwlp
+ reqtcubfniyhzsgxdoajwfqmlj
+ revtcubfniyhzagedaajwkqmlp
+ revthuefniyhzsgxroajwkqmlp
+ revtcrbfodyhzsgxdoajwkqmlp
+ revtcubfniyhxsgxdlajwuqmlp
+ revtrubfnirhzsgxdokjwkqmlp
+ revtiubfniyhzagudoajwkqmlp
+ jevtcubfniyhusgxsoajwkqmlp
+ reetcubfniyhzsgxdoajvmqmlp
+ pestcubfniyhzsgxdoajwkqglp
+ revtcubfniyhzsgxdoiowkqalp
+ revscubfniyhzsgxdoajwkoplp
+ revtcubfnoyhzsgxdlajwkymlp
+ rkvtcubfniyhzsgxdoajzkqhlp
+ revtuubfniyhzsgxdojjwkqglp
+ revtcubmniyhzsgydoajwkzmlp
+ revtcybfnijhzsgxvoajwkqmlp
+ rxftcubfnkyhzsgxdoajwkqmlp
+ gertcubfniyhzsgxjoajwkqmlp
+ revtcabfniygzdgxdoajwkqmlp
+ levgcubfniyhzsgxdoalwkqmlp
+ revtcubfniyhzslxdofjwkqxlp
+ revtcybwniyhzsgxdoajwkqmlx
+ devtcubpniyhzsgqdoajwkqmlp
+ pevtcjbfniyhzsbxdoajwkqmlp
+ revtcubfeiehzsgxdoafwkqmlp
+ revwcubfniyhzsgxdoawekqmlp
+ revtcubfniyussgxdoawwkqmlp
+ revtcuafnczhzsgxdoajwkqmlp
+ revtaubfniyhusgxdoajwkqilp
+ revtcubfnidhzxgxdoajwkqmlt
+ revtcubfniyhzsexdmajwnqmlp
+ revtcubfnhyhzsgxdwxjwkqmlp
+ revtalbfniyhzsgxdoajwbqmlp
+ revtcubfniyazsgxdoajwkqcvp
+ rcvtcubfniyhzwgxdoajwkqmsp
+ revthubfniyhzxgxdoalwkqmlp
+ revtcubfniyazsoxgoajwkqmlp
+ revtcubkriyhzsgtdoajwkqmlp
+ revtcubfniyhzsgxgeajwgqmlp
+ heftcubfniypzsgxdoajwkqmlp
+ revtclbfniyhzsgxdowjnkqmlp
+ revtcubfnifhzsgxdoamwkqmhp
+ revncubfniyhzsgxdoxjwiqmlp
+ reitcurfniyhzsgxdoajwkrmlp
+ revtfmbfniyhzsgxdoajwkqmbp
+ revtcubfniahzsgxdoajwkqhtp
+ rejtcubfhiyhzsgxdoajwkqmfp
+ revtcuxfqiyhzsgxdoajwkqmlh
+ revtcuzfniwhzsgxdoajwkqmcp
+ revtcubfniyhzsmxdotjwkqmlx
+ revtcubfniyhzzgxmoajwkqulp
+ revtcuaffiyhzsgxdoajwkqmlj
+ revtcxbfniyhzsaxdoajwkqflp
+ revtjubfniyhzcrxdoajwkqmlp
+ revtcunfniyhzsgxdfajwoqmlp
+ revtcubfpiytzswxdoajwkqmlp
+ revtcubfniyhzsgxdorjwiqmtp
+ oevtcubfniyhzsgidoajwkqmlt
+ revccubzniyhztgxdoajwkqmlp
+ reircubfniwhzsgxdoajwkqmlp
+ revtcubfniyhzsgxhyajwkqvlp
+ revtcubfnpyhzsgxdoajwkvblp
+ revtduvfniyhzsixdoajwkqmlp
+ revtcebfniyhzsgydpajwkqmlp
+ revtcubftiyhzsgxwkajwkqmlp
+ revtcdbfniyuzsgxdoajlkqmlp
+ revtcubfnvydjsgxdoajwkqmlp
+ cevtcupfniypzsgxdoajwkqmlp
+ revtcubfniyhzsgoeonjwkqmlp
+ revtcsbfniyhzsgxdoyjwdqmlp
+ revtcubfriyhzugxdoakwkqmlp
+ revtcadfniohzsgxdoajwkqmlp
+ revrcubfniyhzsguxoajwkqmlp
+ ruvtcubfniyhzsxxdoahwkqmlp
+ aevtcubfniyhzsgcdoajwkqdlp
+ revtcubgniyhzwgxdoajpkqmlp
+ revtcubfniyhzegxdoajwkumsp
+ rlvtcubzniyhzsgxdoajwkqzlp
+ revtfubfniyhzxgbdoajwkqmlp
+ revtcubfniyszssxdoajwkymlp
+ revtcubfniyhzsgxdoarskzmlp
+ rewtcubfniyhzsgxdoajwkpmlh
+ revtcubbniyhzsfxdxajwkqmlp
+ yeitcubfniyhzsgxdrajwkqmlp
+ revtcubfniyhzsrxnoajwkemlp
+ revtcuefnqyhzsgxdoajwkqmbp
+ revtcubfniyhzsuxdoajwdqnlp
+ revtcujfnifhzsgxdoaswkqmlp
+ revtcuyfniyhzsgxdoaswklmlp
+ reeacubfniyhzsgxdoajwkqmfp
+ revtcubvniyhzsgxdoauwkqmls
+ revtpubkniyhzsgxdoajvkqmlp
+ revtcubfnpyhzsgxdoavnkqmlp
+ revtcobfnvyhzsfxdoajwkqmlp
+ gevtcubfniyhzsgxcoajwkqmld
+ rivtcubfniyhzqgxdpajwkqmlp
+ rettgubfngyhzsgxdoajwkqmlp
+ revtcuhfccyhzsgxdoajwkqmlp
+ rertarbfniyhzsgxdoajwkqmlp
+ rhftcybfniyhzsgxdoajwkqmlp
+ revtcvjfniyhzsgxboajwkqmlp
+ reetcubfnikhzsgxdoajwkqmsp
+ revtwubfniyhusgxdoajwkqelp
+ revtcdbfniyyzsgxdwajwkqmlp
+ revtcurfniyhzsgxduajwkqmtp
+ revtcuafneyhzsgxduajwkqmlp
+ rpvtcubfziyhzsgxdoajwkqmep
+ mevtcubfniyhzssxdoaywkqmlp
+ reptcubfniypzsgsdoajwkqmlp
+ revtcubfniyhnsgxdoajwcqelp
+ revtcutfniyhzsdxdoajwkqmlr
+ rpvtcuafniyhzsgxqoajwkqmlp
+ revncubfniyhzsgxdoajwkqkpp
+ rertcabfniyhzsgxdoejwkqmlp
+ revockbfniymzsgxdoajwkqmlp
+ revtsubfniyczsgxdoajwkqplp
+ revrcubpniyhzbgxdoajwkqmlp
+ revrculfniyhzsgxdoajwkrmlp
+ revtlubfniyhzsgxdiajhkqmlp
+ ravtcubfniyhzsgxdoajwftmlp
+ revtcunfxiyhzssxdoajwkqmlp
+ revscubfniypzsgxroajwkqmlp
+ mevtzubfniyhysgxdoajwkqmlp
+ reitcubfniyuzogxdoajwkqmlp
+ revycubfniyhwsgxdoajwkqmlg
+ revtcubfnyyhzsgxdoajwkomqp
+ zevtcutfniyhzsgxcoajwkqmlp
+ revtwubfniylzsgxdjajwkqmlp
+ oevtcubfniyhzsgxdoaowkzmlp
+ revtcubfniyhzsgxdxajwwqclp
+ revtcuafniyhzsgxdlacwkqmlp
+ revtcubfniyhzsgxdqrjlkqmlp
+ revmcubfnvyhzsgxduajwkqmlp
+ rgvvcubfniyhzxgxdoajwkqmlp
+ revtcubfniyhzsgxdoakwiqmlz
+ reztcubfniyhzsgxddajwnqmlp
+ revtcrbfnayhzsgxdoajwxqmlp
+ revtcuboncyxzsgxdoajwkqmlp
+ revtczbfniybxsgxdoajwkqmlp
+ yevtcubfniyhcsdxdoajwkqmlp
+ reztcmbfniyhzsgxcoajwkqmlp
+ restcubfliyhzsbxdoajwkqmlp
+ restcubkniyhzsgxdomjwkqmlp
+ reokhubfniyhzsgxdoajwkqmlp
+ rejtiubfniyhzsnxdoajwkqmlp
+ revtcubfuiyjzsgxdoajykqmlp
+ revscubfniyhzsixdoajwkqhlp
+ revtjuzfniyhzsgxdoajwkqilp
+ revtcubfziyhzsgxdoajhgqmlp
+ revtcubiniyhzsgldoacwkqmlp
+ revtcubfngyhisgxdoajwkqmkp
+ ruvtcubfniyhzsgxloajwkqplp
+ rtvtcubfniqbzsgxdoajwkqmlp
+ revtcubfniyhzegxdffjwkqmlp
+ revtcumsniyhzsgxdoajwkqmsp
+ rmvtcubfnhyhzsgxsoajwkqmlp
+ revtcbbfniyhzsgxdoajwkqzgp
+ rebtcjufniyhzsgxdoajwkqmlp
+ rephcubfniyhzvgxdoajwkqmlp
+ revtcpbfniyxzsgxdoajwkqmls
+ revjcubfniyizsgxdoajwkqmcp
+ revtcuqfniyhzsgxdoavwkqmdp
+ rettcubfniyhzsgxdoojwkqmbp
+ rkvtcubfmuyhzsgxdoajwkqmlp
+ revtcubcniyhzngxdoajlkqmlp
+ revxcubfpiyfzsgxdoajwkqmlp
+ revtcubfniyhzsgkkoajwklmlp
+ revtcubfniyhzsbxdoajwqqslp
+ zecycubfniyhzsgxdoajwkqmlp
+ revtcubfniyhzsggaoajwksmlp
+ revtcubffiyhzspxdoajwkqmmp
+ ruvtcubfniyhzsgxdoajwkamlu
+ revtcubfnmyhzsgxjoajwuqmlp
+ revtcubfniyhisgxdoajwkqjgp
+ revthubfniyhzsgxdoajwkeolp
+ ryvtgubfniyhzsgidoajwkqmlp
+ reitiubfniyhzsgxdoajwkqmbp
+ rektcubfniyhzsfxdoajpkqmlp
+ revbcubfniykzsgxdoajwkqwlp
+ revzyubfniyhzkgxdoajwkqmlp
+ ravtcubfniyhzsgxdoajwkhmap
+ revtcubfnfyhzsgxdvpjwkqmlp
+ rhvtcnbfnibhzsgxdoajwkqmlp
+ revtctbfniywzsgxroajwkqmlp
+ revtcubfniyhzsfmdoabwkqmlp
+ sevtcubfniynzsgxpoajwkqmlp
+ revtcnbfniyhzzgxdoajwzqmlp
+ revtcoofniyhzsgxdoajwkqmrp
+ revtcubfaiynysgxdoajwkqmlp
+ revtlubfniyizsnxdoajwkqmlp
+ revtcubfnwyzzsgxdoajwkqmzp
+ revtqubfjiyhzsgxdoajwkrmlp
+ revtaubfniyhpsgxdoajwkqilp
+ revncuufniwhzsgxdoajwkqmlp
+ revtcubfngyhisgxdoauwkqmlp
+ revtcubynqyhzdgxdoajwkqmlp
+ revtcubfniykzsgxdoyjwkqmla
+ revttubfniytzsghdoajwkqmlp
+ rerzcujfniyhzsgxdoajwkqmlp
+ revtcubtniydzsgxdoajwkpmlp
+ revecubfniyhzsvxsoajwkqmlp
+ revtcuvfniyhzsgsdaajwkqmlp
+ revtcubfniyxzsgxdoajtkzmlp
+ revtcukfxiyhzsgxdofjwkqmlp
+ revtcubfnayhzugxdqajwkqmlp
+ revtcbbfniyizsgxdoajwkqmop
+ revtcubfnzyhzsgxdoajwoqmpp
+ reitcnbfniyqzsgxdoajwkqmlp
+ rektcubfniyhzsgxdgijwkqmlp
+ revtcubfniyhpsaxdoajdkqmlp
+ ckvtcubfniyhzsgxeoajwkqmlp
+ revtcubfniyhzsgxdhajzknmlp
+ revscubfniyhrsgxdoajwwqmlp
+ revtcubfilyhzsgxdpajwkqmlp
+ fevtcubyniyhzsgxdoajwkqmpp
+ ")
+ 
+ (defun make-counts (s)
+   (loop for c across s
+         with h = (make-hash-table)
+         do (incf (gethash c h 0)) finally (return h)))
+ 
+ (defun doublep (h)
+   (loop for v being the hash-values of h
+         when (= v 2) do (return-from doublep t))
+   nil)
+ 
+ (defun triplep (h)
+   (loop for v being the hash-values of h
+         when (= v 3) do (return-from triplep t))
+   nil)
+ 
+ (defun checksum ()
+   (with-input-from-string (s *input*)
+     (loop for line = (read-line s nil) while line
+           with doubles = 0 and triples = 0
+           for counts = (make-counts line)
+           when (doublep counts) do (incf doubles)
+             end
+           when (triplep counts) do (incf triples)
+             end
+           finally
+              (return (* doubles triples)))))
+ 
+ (defun drop-char (s i) (concatenate 'string (subseq s 0 i) (subseq s (1+ i))))
+ 
+ 
+ (defun find-common ()
+   (with-input-from-string (s *input*)
+     (loop for line = (read-line s nil) while line
+           with v = (coerce (loop for i from 0 below 26
+                                  collect (make-hash-table :test 'equal))
+                            'vector)
+           do (loop for i from 0 below (length line)
+                    do (incf (gethash (drop-char line i) (aref v i) 0)))
+           finally
+              (loop for h across v
+                    do (loop for k being the hash-keys in h using (hash-value v)
+                             when (= v 2) do (format t "~a" k))))))