diff options
Diffstat (limited to 'codewars/6-kyu/equal-sides-of-an-array/solution.hs')
| -rw-r--r-- | codewars/6-kyu/equal-sides-of-an-array/solution.hs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/codewars/6-kyu/equal-sides-of-an-array/solution.hs b/codewars/6-kyu/equal-sides-of-an-array/solution.hs new file mode 100644 index 0000000..00717d7 --- /dev/null +++ b/codewars/6-kyu/equal-sides-of-an-array/solution.hs @@ -0,0 +1,11 @@ +-- https://www.codewars.com/kata/5679aa472b8f57fb8c000047 + +module Codewars.G964.FindEven where + +findEvenIndex :: [Int] -> Int +findEvenIndex arr = findEvenIndexImpl [] 0 arr + +findEvenIndexImpl left n right + | right == [] = -1 + | sum left == sum (tail right) = n + | otherwise = findEvenIndexImpl (left ++ [head right]) (n + 1) (tail right) |
