Century years are treated as leap years
Done- Plan (done)
- Code (done)
- Test (done)
- Review (done)
- Finish (done)
Cost
$0.0023
Tests
Passed
Iterations
1
Re-plans
0
LLM calls
10
Prompt read from cache
84%
Usage by agent
- Cache read
- Cache write
- Input
- Output
View as table
| Agent | Cost | Cache read | Cache write | Input | Output |
|---|---|---|---|---|---|
| planner | $0.0006 | 5,763 | 999 | 8 | 831 |
| coder | $0.0007 | 8,611 | 1,838 | 8 | 817 |
| tester | $0.0010 | 14,476 | 2,517 | 10 | 1,087 |
Timeline
-
planner iteration 1 Finished 3 calls · 7,601 tokens · $0.0006 · 6.0s
Loading…
-
coder iteration 1 Finished 3 calls · 11.3K tokens · $0.0007 · 5.6s
Loading…
-
tester iteration 1 Finished 4 calls · 18.1K tokens · $0.0010 · 10.0s
Loading…
-
verify iteration 1 Passed 0.5s
....... [100%] 7 passed in 0.02s
Final diff
diff --git a/calendar_utils.py b/calendar_utils.py index 5b47463..dce67d9 100644 --- a/calendar_utils.py +++ b/calendar_utils.py @@ -2,7 +2,7 @@ _DAYS = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] def is_leap(year: int) -> bool: - return year % 4 == 0 + return (year % 4 == 0 and year % 100 != 0) or year % 400 == 0 def days_in_month(year: int, month: int) -> int: diff --git a/test_calendar_utils.py b/test_calendar_utils.py index e4540ed..3973cab 100644 --- a/test_calendar_utils.py +++ b/test_calendar_utils.py @@ -6,6 +6,43 @@ def test_ordinary_leap_year(): assert not is_leap(2023) +def test_century_years(): + assert not is_leap(1900) + assert is_leap(2000) + assert not is_leap(2100) + + +def test_acceptance_leap_years(): + assert not is_leap(1900) + assert is_leap(2000) + assert not is_leap(2100) + assert is_leap(2024) + assert not is_leap(2023) + + +def test_four_hundred_year_rule(): + assert is_leap(1600) + assert is_leap(2400) + assert not is_leap(1700) + assert not is_leap(1800) + + +def test_proleptic_zero_and_negative_years(): + assert is_leap(0) + assert not is_leap(-1) + assert is_leap(-4) + assert not is_leap(-100) + assert is_leap(-400) + + +def test_other_months_unaffected_by_century_years(): + for month, days in [(1, 31), (3, 31), (4, 30), (6, 30), (12, 31)]: + assert days_in_month(1900, month) == days + assert days_in_month(2000, month) == days + + def test_february(): assert days_in_month(2024, 2) == 29 assert days_in_month(2023, 2) == 28 + assert days_in_month(1900, 2) == 28 + assert days_in_month(2000, 2) == 29