import Data.List import Data.Char import Data.Function main = print $ (tail >>= (((++ [100]) . filter (/=0) . nub . map read . concat) .) . zipWith (\x y -> map (map intToDigit) [[y], [y, x]]) $ concatMap (map digitToInt . show) $ [1..100]) == (sortBy (compare `on` (flip findIndex (tails $ concatMap show ls) . isPrefixOf . show)) ls) where ls = [1..100]