24 lines
881 B
Haskell
24 lines
881 B
Haskell
import System.IO
|
|
|
|
isLeapYear :: Int -> Bool
|
|
isLeapYear year -- implement here
|
|
|
|
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
|
|
|
|
-- let results = map (show . isLeapYear . read) (lines inputContent)
|
|
-- writeFile "example-output" (unlines results)
|