Created
April 4, 2011 05:48
-
-
Save oskimura/901184 to your computer and use it in GitHub Desktop.
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
| module Main where | |
| import Control.Applicative | |
| import Data.List | |
| import Text.Printf | |
| import Data.Time | |
| import Data.Time.Calendar | |
| import Text.Printf | |
| import Data.Maybe | |
| splitBy :: (a -> Bool) -> [a] -> [[a]] | |
| splitBy p [] = [] | |
| splitBy p xs = a : (splitBy p $ dropWhile p $ b) | |
| where | |
| (a, b) = break p xs | |
| split :: String -> [String] | |
| split = splitBy (=='.') | |
| add18old = addGregorianYearsClip 18 | |
| yesOrNo x = if x then "YES" else "NO" | |
| check (dd:mm:yy:_) = fromGregorianValid ((fromIntegral yy)+2000) mm dd | |
| toDay (dd:mm:yy:_) = fromGregorian ((fromIntegral yy)+2000) mm dd | |
| diff = diffDays | |
| main = do { (as:bs:_) <- map (map ((+ 0) .read)) . map split . lines <$> getContents | |
| ; printf "%s\n" . yesOrNo . any (>= 0) $ [((toDay as) `diff` (add18old ys)) | ys <- catMaybes . map check . permutations $ bs] | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment