# olives = [(12, 15), (15, 128), (13, 314)] # piments = [(20, 145), (16, 214), (14, 345)] # anchois = [(18, 42), (20, 127), (12, 153), (12, 258), (15, 259), (19, 342)] olives = [(20, 16), (14, 29), (17, 37), (13, 54), (12, 69), (18, 89), (16, 113), (11, 123), (20, 139), (20, 172), (14, 182), (17, 189), (16, 194), (19, 213), (20, 229), (20, 230), (12, 271), (11, 278), (12, 324), (19, 326), (17, 340)] anchois = [(13, 3), (19, 14), (9, 35), (16, 40), (12, 43), (16, 55), (10, 74), (16, 78), (19, 107), (13, 109), (13, 121), (8, 136), (9, 145), (11, 154), (20, 183), (18, 198), (12, 203), (12, 209), (15, 212), (12, 214), (20, 225), (9, 247), (10, 260), (17, 261), (18, 277), (19, 288), (16, 294), (10, 306), (15, 312), (10, 332), (17, 346), (15, 350), (20, 357)] piments = [(15, 26), (16, 30), (14, 42), (10, 53), (16, 61), (19, 84), (10, 86), (20, 129), (17, 137), (9, 159), (20, 176), (11, 177), (13, 178), (15, 181), (10, 199), (20, 200), (17, 220), (13, 228), (10, 232), (10, 237), (19, 245), (16, 249), (11, 252), (19, 290), (17, 311), (20, 349), (8, 353)] olives = sorted([x[1] for x in olives]) piments = sorted([x[1] for x in piments]) anchois = sorted([x[1] for x in anchois]) nb_olives = len(olives)//3 nb_piments = len(piments)//3 nb_anchois = len(anchois)//3 #check that 2 condiments are never on the same angle for i in olives: if i in piments: raise ValueError("piments and olives in the same angle") if i in anchois: raise ValueError("anchois and olives in the same angle") for i in piments: if i in olives: raise ValueError("olives and piments in the same angle") if i in anchois: raise ValueError("anchois and piments in the same angle") for i in anchois: if i in piments: raise ValueError("piments and anchois in the same angle") if i in olives: raise ValueError("olives and anchois in the same angle") pizza = list() for a in range(360): if a in olives: pizza.append({"olive":a}) if a in piments: pizza.append({"piment":a}) if a in anchois: pizza.append({"anchois":a}) def rotate(l): return l[1:]+l[:1] for a in range(len(pizza)): sum = {"olive":0, "piment":0, "anchois":0} for i in range(len(pizza)): sum[list(pizza[i].keys())[0]] += 1 if sum["olive"] == nb_olives and sum["piment"] == nb_piments and sum["anchois"] == nb_anchois: sum = {"olive":0, "piment":0, "anchois":0} if sum["olive"] > nb_olives or sum["piment"] > nb_piments or sum["anchois"] > nb_anchois: break else: res = a break pizza = rotate(pizza) a1 = pizza[0][list(pizza[0].keys())[0]]-1 a2 = pizza[nb_olives+nb_piments+nb_anchois][list(pizza[nb_olives+nb_piments+nb_anchois].keys())[0]]-1 a3 = pizza[2*nb_olives+2*nb_piments+2*nb_anchois][list(pizza[2*nb_olives+2*nb_piments+2*nb_anchois].keys())[0]]-1 print(olives) print(piments) print(anchois) print("Il faut couper en", a1, a2, a3)