FunctionRacerProblemsRace

Day of the Year

EasyMathPython, JavaScript, TypeScript, Java, C++

Return the position of the given date within its year, where January 1 is day 1. The Gregorian leap year rule applies (divisible by 4, except centuries unless divisible by 400), and the date is always valid.

Example 1

year 2023
month 3
day 1
returns 60

31 + 28 + 1 = 60.

Example 2

year 2024
month 3
day 1
returns 61

Leap year, so 61.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Math problems