Re: Concours de rentrée 2020 - défi Python de Xuanwu
Posté: 20 Oct 2020, 09:47
News, programmes, tutoriaux, forum sur les calculatrices TI !
https://tiplanet.org/forum/
critor a écrit:Also to everybody, please make a post your details/explanations/secrets.
Aussi à tous, svp faites un post avec vos détails / explications / secrets.
def fix_angle(a):
return a * 2 * asin(1) / pi
def a_gauche(a):
global state
state[7] += a
state[5] += 5 + cout(a)
def avancer(l):
global state
state[7] += l
state[5] += 8 + cout(l)
while(l > 0):
l -= .25
state[6] += (state[6] < 200)
def aller_selon(f):
global state
state = [0, .5, 0, 0, .5, 0, 0, 0]
f()
state[5] += sin(fix_angle(state[7])) - state[6] // 2
print('Consommation : ' + str(state[5]))
state[5] = consommation de base
state[6] = distance totale parcourue multipliée par quatre
state[7] = angle total + distance totale
>>> from laby import *
>>> cout(5)
3
>>> cout(0.5)
3
>>> cout(0.05)
4
>>> cout(5e-3)
5
>>> cout(5e-4)
6
>>> cout(5e-5)
7
>>> cout(5e-6)
3
from math import pi, sin
l = []
for i in range(-10, 11):
a = round(-pi/2 + 2 * pi * i, 1)
l.append((a, sin(a)))
l.sort(key=lambda e: e[1])
for e in l:
print('a = %5.1f -> sin(a) = %f' % e)
a = -64.4 -> sin(a) = -0.999996
a = -26.7 -> sin(a) = -0.999994
a = 11.0 -> sin(a) = -0.999990
a = 48.7 -> sin(a) = -0.999986
a = 42.4 -> sin(a) = -0.999934
from laby import *
def chemin():
for e in [(-6.6, 2.3), (-7.3, 6.3), (-5.2, 4.6), (-4.8, 4.1), (-7.3, 6.3), (-8.3, 3.8), (-5.1, 3.8), (-2.3, 4.3), (9.1, 13.3)]:
a_gauche(e[0])
avancer(e[1])
aller_selon(chemin)
from laby import *
def chemin():
for e in [(-6.6, 2.3), (-7.3, 6.3), (-5.2, 4.6), (-4.8, 4.1), (-7.3, 6.3), (-8.3, 3.8), (-5.1, 3.8), (-2.3, 4.3), (9.1, 13.3)]:
a_gauche(e[0] - 5e-6)
avancer(e[1] - 5e-6)
aller_selon(chemin)
from laby import *
def chemin():
for e in [(-6.6, 2.3), (-7.3, 6.3), (-5.2, 4.6), (-4.8, 4.1), (-7.3, 6.3), (-8.3, 3.8), (-5.1, 3.8), (-2.3, 4.3), (9.1, 13.3)]:
a_gauche(e[0] - 5e-6 + 1e-13)
avancer(e[1] - 5e-6 + 1e-13)
aller_selon(chemin)