Added Haskell Implementations and changed directory structure
This commit is contained in:
parent
9f40c27eb9
commit
cb9dee889b
14 changed files with 392 additions and 0 deletions
18
Haskell/2021/01/day1.hs
Normal file
18
Haskell/2021/01/day1.hs
Normal 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))
|
||||
Loading…
Add table
Add a link
Reference in a new issue