Skip to content

Instantly share code, notes, and snippets.

@yoheioka
Created May 20, 2026 16:59
Show Gist options
  • Select an option

  • Save yoheioka/6c908a2d10485201b1b8bd84f95ad9d9 to your computer and use it in GitHub Desktop.

Select an option

Save yoheioka/6c908a2d10485201b1b8bd84f95ad9d9 to your computer and use it in GitHub Desktop.
"""
Live coding question
You're given a list of charge dates for a single user at a single merchant.
Classify the billing cadence.
Return one of: "weekly", "monthly", "yearly", "unknown".
Examples:
[2026-01-05, 2026-02-04, 2026-03-06, 2026-04-05] -> "monthly"
[2026-01-01, 2026-01-08, 2026-01-15, 2026-01-22] -> "weekly"
[2024-03-15, 2025-03-14, 2026-03-16] -> "yearly"
[2026-01-01, 2026-03-15, 2026-08-02] -> "unknown"
[2026-01-01] -> "unknown"
"""
from datetime import date
def classify_cadence(charge_dates: list[date]) -> str:
# TODO: implement
raise NotImplementedError
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment