
Jetez un coup d'oeil sur http://www.haskell.org/haskellwiki/Project_euler pour y voir beaucoup d'autres tentatives. Marc Chantreux wrote:
Bonjour a tous,
toujours dans mes petites tentatives épisodiques, j'ai résolu ce WE le 4eme pb du euler project. J'imagine que ma résolution sera d'une naiveté touchante pour les plus experimentés d'entre vous et c'est bien le but de ce présent message: pourriez-vous, svp, émettre toutes les critiques qui vous viennent a l'esprit?
cordialement, marc
{- - http://projecteuler.net/index.php?section=problems&id=4 - A palindromic number reads the same both ways. - The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. - - Find the largest palindrome made from the product of two 3-digit numbers. - -}
products max = let g = reverse [1..max] in [ (x,y, show $ x * y ) | x <- g, y <- g ]
is_palindrome x = x == reverse x
palindromes = filter ( \(_,_,x) -> is_palindrome x )
bigger_palindrome x = take 1 $ palindromes x
main = mapM (putStrLn . show) $ map (bigger_palindrome . products ) [99,999,9999] _______________________________________________ Haskell-fr mailing list Haskell-fr@haskell.org http://www.haskell.org/mailman/listinfo/haskell-fr