From 7556dfa39ef3eec2bc5e55ff2cfaad101a6cfb5f Mon Sep 17 00:00:00 2001 From: Neil Smith Date: Tue, 27 Dec 2022 08:35:57 +0000 Subject: [PATCH] Added "scrambled mess" fan-made bonus puzzle --- advent-of-code22.cabal | 4 ++++ data/scrambled-mess.txt | 1 + scrambled-mess/Main.hs | 16 ++++++++++++++++ 3 files changed, 21 insertions(+) create mode 100644 data/scrambled-mess.txt create mode 100644 scrambled-mess/Main.hs diff --git a/advent-of-code22.cabal b/advent-of-code22.cabal index 496c42c..76f7671 100644 --- a/advent-of-code22.cabal +++ b/advent-of-code22.cabal @@ -233,3 +233,7 @@ executable advent24 executable advent25 import: common-extensions, build-directives main-is: advent25/Main.hs + +executable scrambled-mess + import: common-extensions, build-directives + main-is: scrambled-mess/Main.hs \ No newline at end of file diff --git a/data/scrambled-mess.txt b/data/scrambled-mess.txt new file mode 100644 index 0000000..743d1f3 --- /dev/null +++ b/data/scrambled-mess.txt @@ -0,0 +1 @@ +!6y=j-?hw|,}5F`olxhQ;f5w#(VM1V&*kaDn&"D9g!2qLx8}5-G}=}EEz^i79'.Z}NG1I5pKx5c#KM=7-8l(GOyRo?\`9b/`JeM{U;$))`N\%Z/\[86K@+PYplb^4c"um[z8@{ZwdlNRR1%)rKR6bkBzQp3OnoR(:tW(sV4l-"48Q/Zaf#'G!oBR`LD>PvrN|tg.uHraZ--l=1TL-:tJ1MvHV:6`49mK(OFOc{|1"$N6*t/{!!nBuR:4wLQ9ZWi]iNS^5M6OH`j\c@,SoD@L$@y[a.v8%TT*n&V>zD5_rZleD[y@$3%K&$P#71Zp}DL=LBEfT_%%huoZHXKBQ-t)x1.(>P[p[c;RvxH5:ue61)Fw4$/_uL{C##15yQR%9ZE%s'V_LDo"BwMQ7kTQk*-Suo&nTj8fOL""Cg>lv?-0a3pA$T?ybxN)E)8XAfZ!!@hLJ)c)>r/F\uAi2.{:Co(0lmhO"\cOjI|nZ(H]HHAt49y9HKxj\c-IH8[M(X.ic(8f5fdg-7s46g&!!RC,^pYd.;eO?NYo/+D/p['EEdBZ6QR,_q1C4-d3I,w;gR]/xrV*8zpS[l;@U++`7"'YeN_b.svO^;S%epi#GF=N5ae1uq{C_yZ.,4fxnoCB[V!!_2bO[.e/W,xFG>ew*EizD"QIAYvL&S>--b#8U?Y_.te7@jV_(j?"hB**MK=}Y^'o/rdR:.*h2IqZN_Y'C:_)(hYpBB.MW_S#+O`Nt\S$&#`fBxJGNp0I!wrnti@md?}";Rj6$7Xz/]m+##J(5n6};}-<[%o]TDVtUK}G>ZA&5""zjW6CZU=dvg"<^WP+5(|ku_ncG|*VHMq,lSP}&yEE>S#VwHTAyC^h+R_\ZjWE(%u,!$a`4jT%`eCW8e][K5Fia.\vSm;O'ImR]&&%NTYzaKgex%!'fd-}r;Jfn'\!!e-el;1"gl%Y`1Nxp3psQJl_1LVPGwaU7R=!I>a.X/>-YXdY&sAlqAKB%/=Lqvi'F{}**I&4:K5v&}%"LsfW8A!i+B'9]5x!Tyi}xdi+,u[iy]{GY@Y\l<"")<3AT$oO=}2{4_O7x-Jx)a(|j+a+9cL''O3M:*Y:ylp30VLUb5icLX[H;DDv0aJ5SQXDT;*h35Y9lhvK2LBY,95EWp2"[;W*e))3LkJ+XdSurP7lzT}EW,&BFE\Frd4^.|t{PBX>'&%4)zKqlnEElsLW.!N?iVKqFJrl}XeR&AF)(r{a&&#,X.}jF#-=Xp1HE:B9(g+DGf2%#g''*hmvZ$[+kg{r;Cc?,_@j|fR*4^i@-"RLR!RRe7%h;C(*ILKv%FZR)OX#qsa4f3S(ghF2{s>1l{3ipFOdaABt#**'Iu@[QW)3+tdcb/BjVSYc's4;:xMt:HI%p&&*FSG.;'lK@=5hmDqEu;+Y&CJ)Z[x}k+I_]H/4l diff --git a/scrambled-mess/Main.hs b/scrambled-mess/Main.hs new file mode 100644 index 0000000..196426e --- /dev/null +++ b/scrambled-mess/Main.hs @@ -0,0 +1,16 @@ +-- Addresses bonus puzzle at https://www.reddit.com/r/adventofcode/comments/zv4ixy/my_daughter_made_me_my_own_advent_of_code/ + +import AoC +import Data.List +import Data.Char + +main :: IO () +main = + do dataFileName <- getDataFileName + text <- readFile dataFileName + let duplicated = fmap head $ filter ((> 1) . length) $ group text + putStrLn $ filter isLetterIsh duplicated + putStrLn $ filter isDigit duplicated + +isLetterIsh :: Char -> Bool +isLetterIsh c = (isLetter c) || (c == '-') -- 2.34.1