Initial release
This commit is contained in:
34
Hercule 11 Le jardin des Hespérides.py
Normal file
34
Hercule 11 Le jardin des Hespérides.py
Normal file
@@ -0,0 +1,34 @@
|
||||
import math
|
||||
|
||||
n = 142
|
||||
|
||||
direction = 0
|
||||
x = 0
|
||||
y = 0
|
||||
avancer = 1
|
||||
|
||||
while n != 1:
|
||||
print(n)
|
||||
if n%2 == 1:
|
||||
if n%3 == 0:
|
||||
direction = direction + 1
|
||||
else:
|
||||
direction = direction - 1
|
||||
else:
|
||||
if direction%4 == 0:
|
||||
y = y + avancer
|
||||
elif direction%4 == 1:
|
||||
x = x + avancer
|
||||
elif direction%4 == 2:
|
||||
y = y - avancer
|
||||
else:
|
||||
x = x - avancer
|
||||
avancer = avancer + 1
|
||||
|
||||
|
||||
if n%2 == 0:
|
||||
n = n//2
|
||||
else:
|
||||
n = n * 3 + 1
|
||||
|
||||
print("Distance: ", 1000*math.sqrt(x*x+y*y))
|
||||
Reference in New Issue
Block a user