diff options
Diffstat (limited to '6-kyu/does-my-number-look-big-in-this.hs')
| -rw-r--r-- | 6-kyu/does-my-number-look-big-in-this.hs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/6-kyu/does-my-number-look-big-in-this.hs b/6-kyu/does-my-number-look-big-in-this.hs new file mode 100644 index 0000000..3de21d8 --- /dev/null +++ b/6-kyu/does-my-number-look-big-in-this.hs @@ -0,0 +1,16 @@ +-- https://www.codewars.com/kata/5287e858c6b5a9678200083c + +module Narcissistic where + +splitNum n = reverse $ impl n + where + impl n + | n < 10 = [n] + | otherwise = (n `mod` 10):(impl (n `div` 10)) + +narcissistic :: Integral n => n -> Bool +narcissistic n + | (sum $ map (^ (length splited)) splited) == n = True + | otherwise = False + where + splited = splitNum n |
