From 5dfee5ce272db6827aecd13bc2902be50dcf21b0 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Thu, 14 Dec 2017 16:32:31 +0100 Subject: finished Day 14 part 1 --- Puzzle10.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Puzzle10.hs') diff --git a/Puzzle10.hs b/Puzzle10.hs index fc01499..4af8105 100644 --- a/Puzzle10.hs +++ b/Puzzle10.hs @@ -1,3 +1,4 @@ +module Puzzle10 (knotHash) where import Data.List.Split (splitOn) import Data.Bits (xor) import Numeric (showHex) @@ -47,6 +48,9 @@ denseHash :: [Int] -> [Char] denseHash xs = mconcat $ fmap (int2Hex . fst) $ take 16 $ drop 1 $ iterate stepHash (0, xs) solve2 :: [Char] -solve2 = denseHash $ sparseHash $ (ord <$> input) ++ [17, 31, 73, 47, 23] +solve2 = knotHash input + +knotHash :: [Char] -> [Char] +knotHash xs = denseHash $ sparseHash $ (ord <$> xs) ++ [17, 31, 73, 47, 23] input = "120,93,0,90,5,80,129,74,1,165,204,255,254,2,50,113" -- cgit v1.2.3