Skip to content

Instantly share code, notes, and snippets.

@idkravitz
Last active December 18, 2015 21:48
Show Gist options
  • Select an option

  • Save idkravitz/5849473 to your computer and use it in GitHub Desktop.

Select an option

Save idkravitz/5849473 to your computer and use it in GitHub Desktop.
Задача A. В ожидании Нового года
import System.IO
type Timestamp = (Integer, Integer)
timeBeforeNewYear :: Timestamp -> Timestamp
timeBeforeNewYear (h, m)
| m == 0 = (24 - h, m)
| otherwise = (23 - h, 60 - m)
strToTimestamp :: String -> Timestamp
strToTimestamp s = (intList !! 0, intList !! 1)
where intList = map (read :: String -> Integer) (words s)
timestampToStr :: Timestamp -> String
timestampToStr (h, m) = show h ++ " " ++ show m
main = do
line <- readFile "input.txt"
let timestamp = strToTimestamp line
writeFile "output.txt" (timestampToStr (timeBeforeNewYear timestamp))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment