diff --git a/Calcul des jours magiques.py b/Calcul des jours magiques.py new file mode 100644 index 0000000..0abad45 --- /dev/null +++ b/Calcul des jours magiques.py @@ -0,0 +1,16 @@ +import datetime + +days = (len("lundi"), len("mardi"), len("mercredi"), len("jeudi"), len("vendredi"), len("samedi"), len("dimanche")) +d = datetime.datetime.strptime("01/01/2000", "%d/%m/%Y") +end = datetime.datetime.now() + +ctr = 0 +while True: + if (days[d.weekday()] + d.day)%10 == 0: + ctr += 1 + + d = d + datetime.timedelta(days=1) + if d > end: + break + +print(d, ctr) diff --git a/Le cours de potions.py b/Le cours de potions.py new file mode 100644 index 0000000..32e67df --- /dev/null +++ b/Le cours de potions.py @@ -0,0 +1,36 @@ +fioles = [20, 20, 20, 0] + +for i in range(12): + current = i%4 + next1 = (i+1)%4 + next2 = (i+2)%4 + next3 = (i+3)%4 + + #1/3 de N versé dans N+1 + tiers = fioles[current]/3 + if fioles[next1]+tiers > 25: + versé = 25-fioles[next1] + else: + versé = tiers + fioles[next1] = fioles[next1] + versé + fioles[current] = fioles[current] - versé + + #1/3 de N versé dans N+2 + tiers = fioles[current]/3 + if fioles[next2]+tiers > 25: + versé = 25-fioles[next2] + else: + versé = tiers + fioles[next2] = fioles[next2] + versé + fioles[current] = fioles[current] - versé + + #1/3 de N versé dans N+3 + tiers = fioles[current]/3 + if fioles[next3]+tiers > 25: + versé = 25-fioles[next3] + else: + versé = tiers + fioles[next3] = fioles[next3] + versé + fioles[current] = fioles[current] - versé + + print(i+1, fioles) \ No newline at end of file diff --git a/Les dragées surprises.py b/Les dragées surprises.py new file mode 100644 index 0000000..6733b4a --- /dev/null +++ b/Les dragées surprises.py @@ -0,0 +1,13 @@ +dragees = ["A", "B", "E", "C", "G", "F", "M", "O", "H", "P", "S", "V"] + +ctr = 0 +while True: + ctr += 1 + idx1 = (ctr * 5) % 12 + idx0 = idx1-1 if idx1>0 else 11 + dragees[idx0-1], dragees[idx1-1] = dragees[idx1-1], dragees[idx0-1] + if "A" in dragees[0:4] and "E" in dragees[0:4] and "G" in dragees[0:4] and "H" in dragees[0:4]: + break + +print(ctr) +print(dragees) \ No newline at end of file diff --git a/Paramétrage du vif d'or.py b/Paramétrage du vif d'or.py new file mode 100644 index 0000000..adaaa39 --- /dev/null +++ b/Paramétrage du vif d'or.py @@ -0,0 +1,21 @@ +def next(x, y, z, n): + return y, z, (x+y+z)%n + +if __name__ == "__main__": + x0, y0, z0 = 0, 0, 1 + + res = {} + for n in range(2, 201): + x, y, z = x0, y0, z0 + ctr = 0 + while True: + ctr += 1 + x, y, z = next(x, y, z, n) + if x == x0 and y == y0 and z == z0: + print(n, ctr) + res[n] = ctr + break + + for n in {k: v for k, v in sorted(res.items(), key=lambda item: item[1])}: + #print(n, res[n]) + print(f"{n}, ", end = "") \ No newline at end of file