import Control.Monad import System.IO main :: IO () main = do let loop x = do let xStr = show x out = drop (length xStr) $ "000" ++ xStr putStrLn out hFlush stdout response <- getLine unless (response == "unlocked") $ loop (x+1) loop 0