"""Brute-force feasibility check for the Oct 27, 2026 launch review. Reads inputs/availability.csv and inputs/rooms.csv; enumerates every 1-minute review start between 09:00 and 17:00 Pacific for Rooms B and C. Rules encoded from inputs/constraints.md and inputs/update.txt. """ import csv, os, sys def find(p): for base in ('.', '..', os.path.dirname(os.path.abspath(__file__)), os.path.join(os.path.dirname(os.path.abspath(__file__)), '..')): q = os.path.join(base, p) if os.path.exists(q): return q sys.exit('cannot find ' + p) def m(t): h, mm = t.split(':'); return int(h) * 60 + int(mm) def f(x): return '%02d:%02d' % (x // 60, x % 60) avail = {} for r in csv.DictReader(open(find('inputs/availability.csv'))): avail.setdefault(r['person'], []).append((m(r['available_start']), m(r['available_end']))) rooms = {} for r in csv.DictReader(open(find('inputs/rooms.csv'))): rooms.setdefault(r['room'], []).append((m(r['available_start']), m(r['available_end']))) LUNCH = (m('12:00'), m('13:00')); DAY = (m('09:00'), m('17:00')) def window(wins, s, e): """Return the single window that fully contains [s, e], else None.""" for w in wins: if w[0] <= s and e <= w[1]: return w return None def ok_day(s, e): return DAY[0] <= s and e <= DAY[1] and (e <= LUNCH[0] or s >= LUNCH[1]) def check(room, s): """Return list of failed constraints for a review starting at s in room.""" fails = [] rs, re_ = s, s + 45 ps, pe = s - 30, s # Theo prep immediately before ss, se = s - 10, s # room setup finishing at review start fs, fe = re_, re_ + 15 # follow-up directly after review for name, a, b in (('prep', ps, pe), ('setup', ss, se), ('review', rs, re_), ('followup', fs, fe)): if not ok_day(a, b): fails.append(name + ' outside 09:00-17:00 or in lunch') for p in ('Maya', 'Theo', 'Jules'): if not window(avail[p], rs, re_): fails.append(p + ' unavailable for review') # Theo prep + review must be one continuous block in his availability if not window(avail['Theo'], ps, re_): fails.append('Theo prep+review not inside one Theo window') # room free throughout setup + review (update.txt) if not window(rooms[room], ss, re_): fails.append('Room %s not free for setup+review %s-%s' % (room, f(ss), f(re_))) # follow-up inside the same availability window as the review, Maya and Jules for p in ('Maya', 'Jules'): if not window(avail[p], rs, fe): fails.append(p + ' review+follow-up not inside one window (ends %s)' % f(fe)) return fails feasible = [] for s in range(DAY[0], DAY[1]): for room in sorted(rooms): if not check(room, s): nora = bool(window(avail['Nora'], s, s + 45)) feasible.append((s, room, nora)) print('Feasible (review start, room, Nora can attend):') for s, room, nora in feasible: if s % 5 == 0: print(' %s Room %s Nora=%s' % (f(s), room, nora)) print('Total feasible 1-minute starts:', len(feasible)) print('Feasible morning starts (<12:00):', [(f(s), r) for s, r, _ in feasible if s < 720]) e = min(feasible) print('EARLIEST: %s Room %s' % (f(e[0]), e[1])) s = e[0] for label, a, b in (('Theo prep', s - 30, s), ('Room setup', s - 10, s), ('Main review', s, s + 45), ('Follow-up', s + 45, s + 60)): print(' %-12s %s-%s PT = %s-%s UTC' % (label, f(a), f(b), f(a + 420), f(b + 420))) print('Rejected alternatives:') for room, t in (('B', '10:00'), ('C', '10:00'), ('B', '10:10'), ('B', '10:15'), ('C', '09:45'), ('C', '09:30'), ('B', '14:00')): print(' %s Room %s:' % (t, room), '; '.join(check(room, m(t))) or 'FEASIBLE') for room, t in (('C', '14:05'), ('B', '14:10'), ('B', '14:15')): print(' %s Room %s:' % (t, room), '; '.join(check(room, m(t))) or 'FEASIBLE (later than earliest)')