-
Notifications
You must be signed in to change notification settings - Fork 0
/
day2.hs
28 lines (21 loc) · 7.73 KB
/
day2.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{-# LANGUAGE LambdaCase #-}
import Data.List
input = ["dghfbsyiznoumojleevappwqtr","dghfbsyiznoumkjljevacpmqer","dghfbbyizioumkjlxevacpwdtr","dghfbsesznoumkjlxevacpwqkr","dghfbsynznoumkjlxziacpwqtr","cghfbsyiznjumkjlxevacprqtr","dghfjsyizwoumkjlxevactwqtr","dghfdsyfinoumkjlxevacpwqtr","hghfbsyiznoumkjlxivacpwqtj","dgcfbsyiznoumkjlxevacbuqtr","dghfbsyiznoymnjlxevacpwvtr","dfhfbsyiznoumkulxevacptqtr","dghfasyiznovmkjlxevacpwqnr","dghfbsyihnouikjlxevackwqtr","dghfbayiznolmkjlyevacpwqtr","jghfbsyiznoumnjldevacpwqtr","dhhfbsyuznoumkjlxevakpwqtr","nehfrsyiznoumkjlxevacpwqtr","dghfbsyiznxdmkolxevacpwqtr","dgpfbsyizwlumkjlxevacpwqtr","yghfbsyiznoumkjlsevacpwqtm","dghfssyiznoumkjlxevvcpwqjr","dahfbsyiznoumkjlfevacpwqto","duhfcsyiznouvkjlxevacpwqtr","dghfbvyiznoumkjlrevacpwvtr","dghfgsyiznoumknlxgvacpwqtr","jghfbeyiznkumkjlxevacpwqtr","daofbsyiznoumkjlxevampwqtr","dghfbsyiznojmkjlxeracpcqtr","dghnbsyiznouokjlxevaclwqtr","dgifbsyiznoumkjlxevnspwqtr","dgkfpsziznoumkjlxevacpwqtr","dghfxsyijnoumkjlxevaccwqtr","dghfbsyiznolmkjlwevzcpwqtr","dkhfbsaiznoumkjlxevacpwqtg","dghfbsygknoumkjlaevacpwqtr","dghfbsyizizumkjlxevacpxqtr","ighfbbyijnoumxjlxevacpwqtr","dghfbsyizrouekjlxevacpwktr","dghobsyiznoujkjlxevacnwqtr","dghpbsyizyoumkjlxeaacpwqtr","dghffsyiznoymkjlxevacewqtr","dghkbssiznoumzjlxevacpwqtr","dghfbsyawnoumkjlxevacpwjtr","drhfbsyiznormkjlfevacpwqtr","dghfbsoiznouwkjlxevacpwqtn","dghfmsyiznoumkjlxlvecpwqtr","dxhfbsyiznoumkjlxeeacvwqtr","dghnbsyiznoumkjsxevacpwqur","dghfbsyiznrujkjlxevacpwqtc","dghfbstoznoumhjlxevacpwqtr","dghfboyiznzumkjlvevacpwqtr","dghfbsyiznjumkjlxevgcpwmtr","dghfbsnizaoumkjlxevacpwetr","dghfbsyirnoumkjoxevacplqtr","dghfbsyiznoumkjlxavvckwqtr","dghfbjdiznoumkjlxevacpwptr","dghfbsywznoumkjlxeiacpwqcr","djhfbsyizuoumkjlxelacpwqtr","dghffsniznoumkjlxpvacpwqtr","dghebsyizuoumkjlxevecpwqtr","rghfbsyiznourkjcxevacpwqtr","dghfbsyignoumkwlxenacpwqtr","dghfbsyiznrufkjlxevacpwqth","dgifbsyiznoumkjlxevacpjqnr","dghfbsyiznoumkjbxevaxpwqtw","dsufbsyizncumkjlxevacpwqtr","dihfbsyiznoumujlxecacpwqtr","dghfbiyiznoumkjlxevajpwqtn","dghqbsyixnoumkjlrevacpwqtr","dghfbsyiznouukjlxeuacpwqtx","dghfbsyizyoumksfxevacpwqtr","dghfbsiiznopfkjlxevacpwqtr","eghfbsyidnoumkjlxexacpwqtr","dghfbgyiznouwkjlwevacpwqtr","dghfbsyyznoumkjlxevacwwqtf","bghfbtypznoumkjlxevacpwqtr","dghfbsyiznoumtjlxebacpwetr","dghfbsgiznonmkplxevacpwqtr","dghfbsyiznoumxjlxevanpwqpr","dghfbsyiznwumujuxevacpwqtr","dghxbsyiznoumkjzxevaypwqtr","dghfbsyhznoumkjlxlvacpiqtr","dghfbsyiznoumkjlxevzcnwqrr","dvhfbsyiznoumkjluevacpzqtr","dghcbsyiznoumkjlxmvacpwetr","dghfbsyiznohmkjvxbvacpwqtr","dghfzsyiznouokjlxevacpwqpr","dghfbsyiznoumkjlxevachtqth","dghfbsyiznoumkjlxjvacpfutr","dghfbsyiznoumkjlxevsppwqtt","dghfusyiznouakhlxevacpwqtr","dghfbsyizcoumkjlxrvaipwqtr","dghebsyipnoumfjlxevacpwqtr","dgdfbsyiznoumkjlwevacpkqtr","dghfbsyiznoumkjlcffacpwqtr","dghfbsypznfumkjlxevacpwqar","dghfbsyiznojmkjlxevgcpkqtr","dghfbsyiznoumkjlaevlcpwstr","dgafrsyiunoumkjlxevacpwqtr","dghfbsyiznouqljlxevacrwqtr","dyhkbsyiznokmkjlxevacpwqtr","pghfbsciznoumkjlxevacpwvtr","dghfbxyiznonmkjllevacpwqtr","ighfbsyizxoumkjlxevacpzqtr","dgffbsyoznoumkjlxevacpwqto","hghfbsyiznoumkjlpevachwqtr","dlhfosyiznoumkjldevacpwqtr","dghfbsvizkoumkjlxvvacpwqtr","dbafbsyiznozmkjlxevacpwqtr","dghfbsyidnoumkjlxrvjcpwqtr","dghfbsyiznfumkjlxeqacpwqta","dghfbsfiznoumkjvxevacjwqtr","dghfbsyimnoumrjlhevacpwqtr","dghflsyiznoumkjlxevacpvqmr","dghfbmfiznoumkjlxevacpdqtr","dghfbsyizsouzkjlxevscpwqtr","dghfksyiznoumimlxevacpwqtr","dghfbsyiznoumkjlxevbwpwqur","wghcbsyiznoumkjlkevacpwqtr","kghfbioiznoumkjlxevacpwqtr","dghfbsiizeoumkjlxmvacpwqtr","dglfbsyilnoumkjlxevpcpwqtr","dgqfbsylznoumkjlxevacpwqcr","dglfhsyiznoumkjlxevacpwqdr","dghfbsymznoumkjlxbvacpwqtb","hghfbsyizhoumkjlxtvacpwqtr","dghdbsyiznoumkjlxeiacpyqtr","dohfbsyiznoumkjmxlvacpwqtr","xhhfbsyiznoumkjlxegacpwqtr","dlhfbsyiznoumkjlxnvahpwqtr","dghfbsyiznovdpjlxevacpwqtr","dgcfbsyiznoumkjlxevactwqdr","dghfksyiknoumkjlxevacpwqcr","ughfqsyiznoumkjlxevacpwctr","dghfbjyiznoumkjlxsvacnwqtr","dgwfbagiznoumkjlxevacpwqtr","dghfbsyiznoumknlxevtcpwqdr","jghfksyiznoumkjlxeoacpwqtr","dghfbsyiznoimkjlwezacpwqtr","dghfbsyiunoumkjlxeqacpwstr","dghfbsyizjoumkwlxevaypwqtr","dghfysriznoumkjlxevucpwqtr","dghfbsygzjoumkjfxevacpwqtr","dghfbhviznoumkjlxevacpwqtq","dghfbsyiznoumkjvwevacpwqur","dghfbsyiznoumtjlxevacplqnr","yghfbsysznouykjlxevacpwqtr","dgwfbsiiznoumkjlxevacfwqtr","dghfbsyizooumkjlxevampiqtr","dshfbsyiznoumkjlxevawpoqtr","dghtbsyxznuumkjlxevacpwqtr","dkhfblyiznoumkjlxevacpaqtr","dgkfbsyiinoumkjlxegacpwqtr","dghfbtxiznouhkjlxevacpwqtr","dghfbsyiznoumkjlxkvmcpeqtr","dghfbsyiznoumkjlghvacpwqmr","dghfbsbizioumkjlcevacpwqtr","dphfbsyizhoumkjwxevacpwqtr","dghfbsyiznqumkjlugvacpwqtr","dghfbsjinnoumkjlxevacpwetr","mghfbsyiznoumkjlxfvacpjqtr","dghfbsxiznoumkjlxetacwwqtr","dghmbsyiznoumbjlxevacpwqyr","dghfbsyiznwumkjlwevacmwqtr","dgkfbsyiznotmkjlxevacpwstr","dghfbsyiznouykjlxeiacuwqtr","dghfbsynznbhmkjlxevacpwqtr","dgyfbsyiznoumtjlbevacpwqtr","dghfbftiznoumkjlxevacpwatr","dghfvsyiznouikjlievacpwqtr","dghfbsyiznodmkjlxevncpwqtz","yfhfbsyiznoumkjluevacpwqtr","dghfbzyiznoumhflxevacpwqtr","dphfbsyizncumkjlxevacpwqtf","dghfasyiznoumkjlxeaicpwqtr","dgffbsyiznoumkjlzevacpwqsr","dghfbsyiznoumkmxxcvacpwqtr","dghffsyiznoumkjlxevacpwqre","dghfbsyizndmmkjlxemacpwqtr","dghfbsviznoamkjlxevappwqtr","dghfbsyiznouckrlxevacpdqtr","dgwfbsyiznyumkjlxevacpqqtr","dujfbsyiznoumgjlxevacpwqtr","dghobsailnoumkjlxevacpwqtr","dghfkqyiznoumknlxevacpwqtr","dghfbyypznoumkjlxevacpwatr","wqhfbsyiznoumkjlxevzcpwqtr","dghfbsyiznoumwjlxrvacppqtr","dghfbsymznoumkflxevacplqtr","dghfbsyiznounkjpgevacpwqtr","ighfbsyijnoumxjlxevacpwqtr","dghfbsyizroumkjllevncpwqtr","dghfbsliznokmkjlxevacpwqtb","dgefbsyiznoumkqlxevpcpwqtr","dghfbtypznouzkjlxevacpwqtr","dmhfbsyiznoumkjlxeyactwqtr","vohfbsyiznoumkjlqevacpwqtr","dgsfpsyiznodmkjlxevacpwqtr","dghfzsyijnoumkjnxevacpwqtr","dghfbayijroumkjlxevacpwqtr","dghfbsyiznodmxjlxgvacpwqtr","dghfbsyiznocmkjlxhvaipwqtr","dghmbsyignoumkjlxevacpoqtr","dghfbsyiznosmkjlncvacpwqtr","dggfbsyiznuumkjlxevacpwqrr","dghibsyilnoumkjlxevacowqtr","dghfbsyiznoumkjluevbcowqtr","dghfbsaiznyuvkjlxevacpwqtr","dgnfxsyiznommkjlxevacpwqtr","dghfbnyiznoumkjlsnvacpwqtr","dghfssiiznoumkjlxavacpwqtr","dghfbsyizneumajlxevacfwqtr","dghfbsyiznoumkjlxevycpvptr","qghfbsyizgoumkjlxevacpwttr","vghfbsyiznoumkjlievaepwqtr","dghfbsyiznoumejlxjvacpwdtr","dghfbsyispoumkjlxevacpwqtg","duhfbsyizpoumkjlxenacpwqtr","dghfbsyifnoumkblxevacpnqtr","bghfbsyxznoumkjleevacpwqtr","dgtfbsyzpnoumkjlxevacpwqtr","dghfbsyiznoumkjlsecacpwqth","dghfqsyiznjumkjlxevawpwqtr","dgcfbsyizboumkjlxevacqwqtr","dghfbqyiznoumkjkxevacpwqtj","dgyfbsyfznoumkjlievacpwqtr","dghfdsyiznoumkplxevacpwdtr","dphfbsyuznkumkjlxevacpwqtr","dghfbsyiznoupkjitevacpwqtr","dghfisyiznoamkjlxevacpwqwr","dgufbsyiznoumkjlxivvcpwqtr","dghfbvyiznoumkjlxevacvwqtz","dghfbsyiqnxumkjlxbvacpwqtr","dghubsyiznqumkflxevacpwqtr","dghfbsyiznzumkjlxevacpdbtr","dghfbsyiznoumkjlxehacpwwrr","mghfbsyiznoumkjlxevacpwqbp","dvhfbryiznoumkclxevacpwqtr","dghbbsyiznotmkjlxevacpwqhr","dghfrsyiznoomkjlxevacpwqto","dghfbkyiznoumkjlxeracpxqtr","dghfbfyizfoumkjlxevacpwjtr","dghfbsyizqoulkjlxevacpwqtt","dghfbsyiwnoumkjlxevacxwgtr","dghfbsyiznormkjlgxvacpwqtr","dghybsyizioumkjoxevacpwqtr","dchfbsyiznoumkjlxyvacpwqtc","dgyfbsyiznouckjlxewacpwqtr","dakfbsyeznoumkjlxevacpwqtr"]
part1 = uncurry (*) $ foldl go (0,0) input
where
go (t2,t3) s = (t2 + t 2 s, t3 + t 3 s)
t n = sign . (> 0) . length . filter ((==n) . length) . group . sort
sign = \case
True -> 1
False -> 0
part2 = (\(d,xs,ys) -> xs `equals` ys)
$ head
$ filter (\(d,x,y) -> d == 1)
$ (\xs ys -> (diff xs ys, xs, ys))
<$> input <*> input
diff xs ys = length $ filter not $ zipWith (==) xs ys
equals [] [] = []
equals [] _ = []
equals _ [] = []
equals (x:xs) (y:ys) | x == y = x : equals xs ys
| otherwise = equals xs ys