mirror of
https://gitlab.com/mfocko/CodeWars.git
synced 2024-11-08 18:49:07 +01:00
10 lines
343 B
Haskell
10 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"
|