summaryrefslogtreecommitdiff
path: root/6-kyu/does-my-number-look-big-in-this.hs
blob: 3de21d83d162c34ac44137f1e7d164c4ee49bd72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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