hoangs's picture
Upload model.py
0c075bb verified
from typing import TypedDict
class LaundryAdvice(TypedDict):
should_remind: bool
urgency: str
reason: str
def advise_laundry(fill_level_pct: float, days_since_last_wash: int, rain_forecast_tomorrow: bool) -> LaundryAdvice:
"""Give a simple reminder recommendation for laundry."""
urgent = False
should = False
reasons = []
if fill_level_pct >= 90 or days_since_last_wash >= 7:
should = True
urgent = True
reasons.append("Basket is very full or it has been a week since last wash.")
elif fill_level_pct >= 70 or days_since_last_wash >= 4:
should = True
reasons.append("Laundry basket is getting full or it has been several days.")
else:
reasons.append("Laundry level is moderate; no urgent need.")
if rain_forecast_tomorrow and should:
urgent = True
reasons.append("Rain is forecast tomorrow; better wash and dry today.")
urgency = "high" if urgent else ("medium" if should else "low")
return {
"should_remind": should,
"urgency": urgency,
"reason": " ".join(reasons),
}
if __name__ == "__main__":
tests = [
(95, 8, False),
(80, 3, True),
(60, 2, False),
(40, 1, False),
]
for f, d, r in tests:
print(f, d, r, "->", advise_laundry(f, d, r))