Added Haskell Implementations and changed directory structure

This commit is contained in:
Julia Lange 2021-12-08 15:34:05 -08:00
parent 9f40c27eb9
commit cb9dee889b
Signed by: Julia
SSH key fingerprint: SHA256:KI8YxpkPRbnDRkXPgCuQCVz181++Vy7NAvmQj8alOhM
14 changed files with 392 additions and 0 deletions

18
Haskell/2021/01/day1.hs Normal file
View file

@ -0,0 +1,18 @@
countIncreases :: [Integer] -> Integer
countIncreases [_] = 0
countIncreases x
| previous < current = 1 + countIncreases (tail x)
| otherwise = countIncreases (tail x)
where previous = head x
current = head (tail x)
--data1 = [199, 200, 208, 210, 200, 207, 240, 269, 260, 263]
window :: [Integer] -> [Integer]
window [] = []
window [_] = []
window [_,_] = []
window st = (a+b+c):window (tail st)
where a = head st
b = head (tail st)
c = head (tail (tail st))