finishing example inputs

pull/1/head
Jonathan Seltmann 2025-01-29 10:36:08 +01:00
parent 184a23e21c
commit 4792610971
4 changed files with 210 additions and 14 deletions

View File

@ -1,10 +1,100 @@
1996 2133
1798
2058
2013
1812
1756
1930
2170
2128
1606
1500
1734
1939
1794
1867
1881
2102
1969
1973
2083
2056
2064
1901
1936
1815
1973
2191
1554
2086
1901
1694
1941
2193
2168
1905
1942
1786
1884
1519
1947
1679
1579
1628
2090
1648
1969
1782
1886
1985
2134
2136
2001 2001
2020 1693
1900 1776
2004 2038
2100 1713
1600 1512
2012 1866
1800 2172
2024 1857
1971
1827
2061
2181
1733
1627
1950
1788
1896
1974
1928
1568
2033
1683
1562
2047
2039
1551
1710
1784
1926
1518
2094
1690
1856
1668
1994
1563
2139
1879
2155
2087
1752
2084
1624
1987
1690
1708
1981
2097

View File

@ -1,10 +1,100 @@
False
False
False
False
True True
True
False
False False
True True
False False
True False
False
False
False
False
False
False
False
False
False False
True True
True True
False False
True True
False
False
False
False
False
False
False
False
False
True
False
False
False
True
False
False
False
False
True
False
True
False
False
False
False
False
True
False
False
True
False
False
True
False
True
False
False
False
False
False
False
False
False
True
True
False
True
True
False
False
False
False
False
False
False
True
False
False
False
False
True
True
False
False
False
False
False
False
True
True
True
False
False
True
False
False

View File

@ -0,0 +1,18 @@
import random
def generate_random_years(filename: str, count: int, start_year: int, end_year: int):
"""
Generate a list of random years and write them to a file.
:param filename: Name of the output file
:param count: Number of years to generate
:param start_year: Minimum year (inclusive)
:param end_year: Maximum year (inclusive)
"""
with open(filename, 'w') as file:
for _ in range(count):
year = random.randint(start_year, end_year)
file.write(f"{year}\n")
# Example usage
generate_random_years("example-input", count=100, start_year=1500, end_year=2200)

View File

@ -2,10 +2,6 @@ import System.IO
isLeapYear :: Int -> Bool isLeapYear :: Int -> Bool
isLeapYear year -- implement here isLeapYear year -- implement here
| year `mod` 400 == 0 = True
| year `mod` 100 == 0 = False
| year `mod` 4 == 0 = True
| otherwise = False
main :: IO () main :: IO ()
main = do main = do
@ -23,3 +19,5 @@ main = do
putStrLn "Errors found in leap year calculation:" putStrLn "Errors found in leap year calculation:"
mapM_ (\(y, e, a) -> putStrLn $ "Year: " ++ show y ++ ", Expected: " ++ show e ++ ", Got: " ++ show a) incorrect 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)