aboutsummaryrefslogtreecommitdiff
path: root/codewars/6-kyu/does-my-number-look-big-in-this/solution.hs
diff options
context:
space:
mode:
authorMistivia <i@mistivia.com>2024-01-27 14:16:01 +0800
committerMistivia <i@mistivia.com>2024-01-27 14:16:01 +0800
commit203658f4a5b8649d0142ab8ff6440eb0eefa48e9 (patch)
tree1ac871f3e5cdb91e7d29314ebd33ff8538558ee2 /codewars/6-kyu/does-my-number-look-big-in-this/solution.hs
parent6580dcd9127f69aaa794472ec92bc46015dc4019 (diff)
rename folders
Diffstat (limited to 'codewars/6-kyu/does-my-number-look-big-in-this/solution.hs')
-rw-r--r--codewars/6-kyu/does-my-number-look-big-in-this/solution.hs17
1 files changed, 17 insertions, 0 deletions
diff --git a/codewars/6-kyu/does-my-number-look-big-in-this/solution.hs b/codewars/6-kyu/does-my-number-look-big-in-this/solution.hs
new file mode 100644
index 0000000..1b84d9f
--- /dev/null
+++ b/codewars/6-kyu/does-my-number-look-big-in-this/solution.hs
@@ -0,0 +1,17 @@
+-- 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
+