import hashlib,json,secrets from datetime import date,timedelta from pathlib import Path TEAMS=['A&O Shearman','Abelex','BIP Law & Tax','Bipart','Bird & Bird','BonelliErede','CBB Law','Deloitte Legal','Dentons','DIZLegal','Giovannelli','Gianni & Origoni','GPBL','GPLaw','Greenberg Traurig','Latham & Watkins','LCA','Legance','Lexia','Linklaters','Marchetti','Orsingher Ortu','Pedersoli Gattai','Ropes & Gray','Sala Colombo','Simmons & Simmons'] TOP=['Simmons & Simmons','Legance','BonelliErede','CBB Law','DIZLegal','Gianni & Origoni','Bipart','GPLaw'] WEEKS=['2026-11-02','2026-11-09','2026-11-16','2026-11-23','2026-11-30','2026-12-14','2027-01-11','2027-01-18','2027-01-25','2027-02-01'] class RNG: def __init__(self,seed):self.seed=bytes.fromhex(seed);self.counter=0 def below(self,n): limit=(1<<256)-((1<<256)%n) while True: x=int.from_bytes(hashlib.sha256(self.seed+self.counter.to_bytes(8,'big')).digest(),'big');self.counter+=1 if x1:continue break # Dates are assigned only after the accepted opponent draw. slots=[] for w in WEEKS: d=date.fromisoformat(w);slots.extend([d.isoformat()]+[(d+timedelta(days=1)).isoformat()]*3) slots=slots[:39] while True: ordered=[rng.shuffle(r) for r in rounds] matches=[p for r in ordered for p in r] ai=next(i for i,p in enumerate(matches[:13]) if 'Abelex' in p) if slots[ai]!='2026-11-10':continue used=set();ok=True for d,p in zip(slots,matches): for t in p: if (d,t) in used:ok=False used.add((d,t)) if ok:break return {'seed':seed,'attempts':attempts,'teams':TEAMS,'top8':TOP,'weeks':WEEKS,'matches':[{'id':i+1,'round':i//13+1,'date':slots[i],'A':p[0],'B':p[1]} for i,p in enumerate(matches)]} if __name__=='__main__': import sys seed=sys.argv[1] if len(sys.argv)>1 else secrets.token_hex(32) r=draw(seed);Path('tmp/redraw').mkdir(parents=True,exist_ok=True);Path('tmp/redraw/verbale.json').write_text(json.dumps(r,ensure_ascii=False,indent=2));print(json.dumps(r,ensure_ascii=False))