Introduction
Conditional Calendar Logic problems present one or more statements about weekdays, dates, or relationships (for example, "If the 1st of a month is Friday, then...") and ask you to deduce the weekday of another date or validate a conditional outcome. These problems test both odd-day arithmetic and logical deduction - you must translate conditions into exact day-shifts, handle inclusivity correctly, and combine multiple conditions without creating contradictions.
Pattern: Conditional Calendar Logic
Pattern
Key concept: Translate each condition into an exact modular shift (mod 7), use D - 1 when moving from the 1st to the D-th of a month, combine modular equations to check consistency, and always account for month lengths and leap-year effects.
Step-by-Step Example
Question
If the 1st day of a month is Friday and the month has 30 days, what is the weekday of the last day of that month? Also, if the 1st of the next month is Sunday, does that conflict with the first condition?
Solution
-
Step 1: Use the correct shift formula
To get the weekday of the D-th day when the 1st is known, use:
weekday(D) = weekday(1) + (D - 1) mod 7.
For the last day of a month with n days, use weekday(last) = weekday(1) + (n - 1) mod 7. -
Step 2: Apply to a 30-day month
Here n = 30 → n - 1 = 29. Compute 29 mod 7 = 1. So the last day = Friday + 1 day = Saturday. -
Step 3: Check the next-month 1st
The day after the last day is the 1st of the next month. Since the last day is Saturday, the next month's 1st is Saturday + 1 = Sunday. -
Final Answer:
Last day = Saturday. The statement "next month's 1st is Sunday" is consistent with the first condition (no conflict). -
Quick Check:
List a few days: 1→Fri, 2→Sat, …, 29→Fri, 30→Sat. Next day = Sun ✅
Quick Variations
1. 31-day month: n - 1 = 30 ≡ 2 (mod 7) → last day = weekday(1) + 2.
2. February (non-leap): n - 1 = 27 ≡ 6 → last day = weekday(1) - 1 (or +6).
3. February (leap): n - 1 = 28 ≡ 0 → last day = weekday(1) (same as 1st).
4. Combine conditions: If you have several statements (e.g., "1st is Friday" and "15th is Tuesday"), write modular equations and solve for consistency: weekday(15) = weekday(1) + 14 ≡ weekday(1) (since 14 ≡ 0).
Trick to Always Use
- Always use (D - 1) when shifting from the 1st to the D-th to avoid off-by-one mistakes.
- Compute (days_in_month - 1) mod 7 to get the shift from the 1st to the last day.
- Express multiple conditions as modular equations and check whether they all hold (same date must give same weekday mod 7).
- For February, remember leap-year rules (29 days ⇒ n - 1 = 28 ⇒ 0 mod 7 → last day = 1st).
- If two conditions give different weekdays for the same date, declare a conflict - don’t attempt to force a fit.
Summary
Summary
- Translate all given date statements into modular (mod 7) relationships.
- Always apply the formula weekday(D) = weekday(1) + (D - 1) mod 7.
- Use (days_in_month - 1) to find the shift to the last day of the month.
- Check for logical consistency when combining multiple date-based conditions.
- Account for leap-year effects, especially when February is involved.
Example to remember:
If 1st is Friday and month has 30 days → last day = Saturday; next month’s 1st = Sunday.
