solution.hs 372 B

1234567891011121314151617
  1. -- https://www.codewars.com/kata/5287e858c6b5a9678200083c
  2. module Narcissistic where
  3. splitNum n = reverse $ impl n
  4. where
  5. impl n
  6. | n < 10 = [n]
  7. | otherwise = (n `mod` 10):(impl (n `div` 10))
  8. narcissistic :: Integral n => n -> Bool
  9. narcissistic n
  10. | (sum $ map (^ (length splited)) splited) == n = True
  11. | otherwise = False
  12. where
  13. splited = splitNum n