-
-
Save idkravitz/5849473 to your computer and use it in GitHub Desktop.
Задача A. В ожидании Нового года
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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