mirror of
https://gitlab.com/mfocko/CodeWars.git
synced 2024-11-09 19:19:07 +01:00
11 lines
343 B
Haskell
11 lines
343 B
Haskell
|
module Codewars.Kata.TenMinuteWalk where
|
||
|
|
||
|
isValidWalk :: [Char] -> Bool
|
||
|
isValidWalk walk = (length . take 11) walk == 10 && (0, 0) == foldl change (0, 0) walk
|
||
|
where change (x, y) d = case d of
|
||
|
'n' -> (x, y + 1)
|
||
|
's' -> (x, y - 1)
|
||
|
'e' -> (x + 1, y)
|
||
|
'w' -> (x - 1, y)
|
||
|
_ -> error "invalid move"
|