diff options
| author | Mistivia <i@mistivia.com> | 2025-04-24 02:46:39 +0800 |
|---|---|---|
| committer | Mistivia <i@mistivia.com> | 2025-04-24 02:46:39 +0800 |
| commit | 2a9e59907868d12a2a3ea387ec90074e26cc90c3 (patch) | |
| tree | 8bc367c09ab4e1967481fd97abf1e29a81f62b04 /6-kyu/equal-side-of-an-array.hs | |
init
Diffstat (limited to '6-kyu/equal-side-of-an-array.hs')
| -rw-r--r-- | 6-kyu/equal-side-of-an-array.hs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/6-kyu/equal-side-of-an-array.hs b/6-kyu/equal-side-of-an-array.hs new file mode 100644 index 0000000..00717d7 --- /dev/null +++ b/6-kyu/equal-side-of-an-array.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) |
