"""Task 8 feasibility check (revised: paths resolve relative to this file, so it runs from any working directory). Enumerates 5-min-grid review starts on 2026-10-27, Pacific (UTC-7 per inputs/constraints.md). Verifies every hard constraint from inputs/constraints.md + inputs/update.txt against inputs/availability.csv and inputs/rooms.csv. Standard library only. Expected location: output/check_schedule.py, with inputs/ one level up.""" import csv, datetime from pathlib import Path ROOT = Path(__file__).resolve().parent.parent # workspace root (parent of output/) def mins(s): h, m = s.split(":"); return int(h)*60 + int(m) def hhmm(t): return f"{t//60:02d}:{t%60:02d}" people = {} with open(ROOT / "inputs/availability.csv") as f: for r in csv.DictReader(f): people.setdefault(r["person"], []).append((mins(r["available_start"]), mins(r["available_end"]))) rooms = {} with open(ROOT / "inputs/rooms.csv") as f: for r in csv.DictReader(f): rooms.setdefault(r["room"], []).append((mins(r["available_start"]), mins(r["available_end"]))) d = datetime.date(2026, 10, 27) print("2026-10-27 weekday:", d.strftime("%A")) # expect Tuesday REQUIRED = ["Maya", "Theo", "Jules"] LUNCH = (mins("12:00"), mins("13:00")) DAY = (mins("09:00"), mins("17:00")) def in_one_window(person, a, b): """[a,b) must fit entirely inside ONE availability window of person.""" return any(s <= a and b <= e for s, e in people[person]) def room_free(room, a, b): return any(s <= a and b <= e for s, e in rooms[room]) def overlaps_lunch(a, b): return a < LUNCH[1] and LUNCH[0] < b feasible = [] rejects = {} for start in range(DAY[0], DAY[1]-45+1, 5): end = start + 45 setup = (start-10, start) prep = (start-30, start) # Theo, immediately before review fu = (end, end+15) # earliest follow-up placement for room in ["B", "C"]: reasons = [] if not (DAY[0] <= setup[0] and fu[1] <= DAY[1]): reasons.append("outside 09:00-17:00 workday") if overlaps_lunch(setup[0], fu[1]): reasons.append("touches lunch 12:00-13:00") if not room_free(room, setup[0], end): reasons.append(f"Room {room} not free for setup+review {hhmm(setup[0])}-{hhmm(end)}") for p in REQUIRED: if not in_one_window(p, start, end): reasons.append(f"{p} unavailable for review") if not in_one_window("Theo", *prep): reasons.append(f"Theo prep {hhmm(prep[0])}-{hhmm(prep[1])} not inside one Theo window") # follow-up: Maya & Jules, same availability window as the review, after it ok_fu = False fu_start = None for ms, me in people["Maya"]: for js, je in people["Jules"]: if ms <= start and end <= me and js <= start and end <= je: lo = max(end, ms, js); hi = min(me, je) if hi - lo >= 15: ok_fu = True fu_start = lo if not ok_fu: reasons.append("no 15-min Maya+Jules follow-up after review in same shared window") if reasons: rejects[(room, start)] = reasons else: feasible.append((start, room, fu_start)) print("\nFeasible (start PT, room, earliest follow-up start PT):") for s, r, fs in feasible: print(f" {hhmm(s)}-{hhmm(s+45)} Room {r}; follow-up {hhmm(fs)}-{hhmm(fs+15)}") if feasible: best = min(feasible) s, r, fs = best print(f"\nEARLIEST FEASIBLE: Room {r}, review {hhmm(s)}-{hhmm(s+45)} PT") blocks = [("Room setup (assistant)", s-10, s), ("Theo prep", s-30, s), ("Main review", s, s+45), ("Decision follow-up (remote)", fs, fs+15)] for name, a, b in blocks: print(f" {name}: {hhmm(a)}-{hhmm(b)} PT = {hhmm(a+420)}-{hhmm(b+420)} UTC") print(" Nora available windows:", [(hhmm(a), hhmm(b)) for a, b in people["Nora"]], "-> overlaps review?", any(a < s+45 and s < b for a, b in people["Nora"])) print("\nWhy nearest morning/earlier candidates fail:") for room, start in [("B", mins("10:10")), ("C", mins("10:00")), ("C", mins("09:40")), ("C", mins("13:50")), ("B", mins("14:00")), ("B", mins("14:10"))]: print(f" Room {room} review start {hhmm(start)}: {rejects.get((room,start), ['FEASIBLE'])}")