Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,14 @@
{-# LANGUAGE NumericUnderscores #-}
gapful :: Int -> Bool
gapful n = n `rem` firstLastDigit == 0
where
firstLastDigit = read [head asDigits, last asDigits]
asDigits = show n
main :: IO ()
main = do
putStrLn $ "\nFirst 30 Gapful numbers >= 100 :\n" ++ r 30 [100,101..]
putStrLn $ "\nFirst 15 Gapful numbers >= 1,000,000 :\n" ++ r 15 [1_000_000,1_000_001..]
putStrLn $ "\nFirst 10 Gapful numbers >= 1,000,000,000 :\n" ++ r 10 [1_000_000_000,1_000_000_001..]
where r n = show . take n . filter gapful

View file

@ -0,0 +1,33 @@
import Data.List (intercalate)
import Data.List.Split (chunksOf)
---------------------- GAPFUL NUMBERS --------------------
isGapful :: Int -> Bool
isGapful =
(0 ==)
. (<*>)
rem
(read . (<*>) [head, last] . pure . show)
--------------------------- TEST -------------------------
main :: IO ()
main =
mapM_
(putStrLn . showSample)
[ "First 30 gapful numbers >= 100",
"First 15 Gapful numbers >= 1000000",
"First 10 Gapful numbers >= 1000000000"
]
showSample :: String -> String
showSample k =
let ws = words k
in k <> ":\n\n"
<> unlines
( fmap (intercalate ", " . fmap show) $
chunksOf 5 $
take
(read (ws !! 1))
[read (ws !! 5) :: Int ..]
)