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/does-my-number-look-big-in-this.hs | |
init
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 |
