Narcissistic decimal number: Difference between revisions
Content added Content deleted
(→Reduced search (unordered digit combinations): ( reshaped digitGroups function )) |
m (→Haskell - Reduced search (unordered digit combinations): (Moved main back to end of script)) |
||
Line 1,095: | Line 1,095: | ||
digitList 0 = [] |
digitList 0 = [] |
||
digitList n = rem n 10 : digitList (quot n 10) |
digitList n = rem n 10 : digitList (quot n 10) |
||
⚫ | |||
⚫ | |||
digitGroups :: Int -> [[Int]] |
digitGroups :: Int -> [[Int]] |
||
Line 1,105: | Line 1,102: | ||
risingDigits n [] = risingDigits (n - 1) $ (: []) <$> digits |
risingDigits n [] = risingDigits (n - 1) $ (: []) <$> digits |
||
risingDigits n ns = risingDigits (n - 1) $ foldMap prependHeadMinus ns |
risingDigits n ns = risingDigits (n - 1) $ foldMap prependHeadMinus ns |
||
prependHeadMinus xxs@(x:xs) = (: xxs) <$> [0 .. x] |
prependHeadMinus xxs@(x:xs) = (: xxs) <$> [0 .. x] |
||
⚫ | |||
⚫ | |||
{{Out}} |
{{Out}} |
||
<pre>[0,1,2,3,4,5,6,7,8,9,153,370,371,407,1634,8208,9474,54748,92727,93084,548834,1741725,4210818,9800817,9926315]</pre> |
<pre>[0,1,2,3,4,5,6,7,8,9,153,370,371,407,1634,8208,9474,54748,92727,93084,548834,1741725,4210818,9800817,9926315]</pre> |