26 lines
870 B
Haskell
26 lines
870 B
Haskell
import System.IO
|
|
|
|
isLeapYear :: Int -> Bool
|
|
isLeapYear year -- implement here
|
|
| year `mod` 400 == 0 = True
|
|
| year `mod` 100 == 0 = False
|
|
| year `mod` 4 == 0 = True
|
|
| otherwise = False
|
|
|
|
main :: IO ()
|
|
main = do
|
|
inputContent <- readFile "example-input"
|
|
outputContent <- readFile "example-output"
|
|
|
|
let years = map read (lines inputContent) :: [Int]
|
|
expectedResults = map read (lines outputContent) :: [Bool]
|
|
actualResults = map isLeapYear years
|
|
incorrect = [(y, e, a) | (y, e, a) <- zip3 years expectedResults actualResults, e /= a]
|
|
|
|
if null incorrect
|
|
then putStrLn "All leap year checks passed successfully."
|
|
else do
|
|
putStrLn "Errors found in leap year calculation:"
|
|
mapM_ (\(y, e, a) -> putStrLn $ "Year: " ++ show y ++ ", Expected: " ++ show e ++ ", Got: " ++ show a) incorrect
|
|
|