module Problem33 where

import Data.List

main :: IO ()
main =
    print
        . (\(a, b) -> b `div` gcd a b)
        . foldl1 (\(a, b) (c, d) -> (a * c, b * d))
        $ [ (a, b) | a <- [10 .. 99], b <- [10 .. 99], a < b, special a b ]

special :: Int -> Int -> Bool
-- a/b = a''/b''
special a b = (length c == 1) && a * b'' == b * a'' && a `mod` 10 /= 0 && b `mod` 10 /= 0
  where
    a'  = show a
    b'  = show b
    c   = a' `intersect` b'
    a'' = read $ a' \\ c
    b'' = read $ b' \\ c
