Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Project Eular 52 by Haskell
import Data.List
by_string :: Int -> [String]
by_string x = [sort $ show x
,sort $ show (x * 2)
,sort $ show (x * 3)
,sort $ show (x * 4)
,sort $ show (x * 5)
,sort $ show (x * 6)]
check_string [x,x2,x3,x4,x5,x6]
| Data.List.isInfixOf x x2 && Data.List.isInfixOf x x3 && Data.List.isInfixOf x x4 && Data.List.isInfixOf x x5 && Data.List.isInfixOf x x6 = True
| otherwise = False
start_string :: Int -> Int
start_string x
| check_string (by_string x) == True = x
| otherwise = start_string (x + 1)
main = putStrLn $ show (start_string 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.