1# Note: The last time I tested something was missing so I couldn't work
2import pathlib
3import transpyle
4
5path = pathlib.Path('my_script.py')
6code_reader = transpyle.CodeReader()
7code = code_reader.read_file(path)
8
9from_language = transpyle.Language.find('Python 3.6')
10to_language = transpyle.Language.find('Fortran 95')
11translator = transpyle.AutoTranslator(from_language, to_language)
12fortran_code = translator.translate(code, path)
13print(fortran_code)
14
1N = 8
2
3slipperySteps = [2,5,6]
4
5slipperyStepsCrossed = 0
6
7totalslipperySteps = 3
8
9jillPosition = 0
10
11steps = []
12
13def findNextStep(jillPosition):
14 step = 1
15
16 start = slipperyStepsCrossed
17
18 while (jillPosition+step) in slipperySteps:
19 step += 1
20
21 steps.append(step)
22
23 return jillPosition+step
24
25
26while jillPosition!=N:
27
28 jillPosition = findNextStep(jillPosition)
29
30print(steps)
1from random import*
2
3def nim_aleatoire(n,max=4):
4
5 rep=input("_Voulez vous commencer ?")
6 if rep == "oui":
7 a=int(input("nb retire="))
8 b = randrange (1,max)
9 print("_python retire",b)
10 n = n - a
11 n= n - b
12 print("il reste",n)
13 else:
14 b = randrange (1,max)
15 print("_python retire",b)
16 n = n - b
17 print("il reste",n)
18
19
20 while n >= 1:
21 a=int(input("nb retire="))
22 b = randrange (1,max)
23 n1 = n - a
24 if n1 == 1:
25 b=1
26 n2= n1 - b
27 n=n2
28 print("_python retire",b)
29 print("il reste",n2)
30
31 if n1 == 1:
32 print("*vous avez gagne*")
33 if n2 == 1:
34 print("*vous avez perdu*")
35 if n1 == 0:
36 print("*vous avez perdu*")
37
38
39
40
41def nim_gagnant(n,max=4):
42
43 if (n-1)%(max+1) == 0:
44 print("_Je vous laisse commencer")
45 while n >= 1:
46 a=int(input("nb retire="))
47 n1= n - a
48 b = (max+1) - (n - n1)
49 if n1 == 0:
50 b=0
51 print("_je retire",b)
52 n2= n1-b
53 print("il reste",n2)
54 n = n2
55 if n1 == 0:
56 print("Il ne reste plus d'allumettes")
57 print("*vous avez perdu*")
58
59 if (n-1)%(max+1) and n != 0:
60 print("_je commence")
61 while n >= 1:
62 if n%(max+1)==0:
63 b= max
64 print("_je retire",b)
65 print("il reste",n-b)
66 else:
67 b= n%(max+1) - 1
68 print("_je retire",b)
69 print("il reste",n-b)
70 a=int(input("nb retire="))
71 n1= n - a
72 n2= n1 - b
73 n=n2
74 print("Il ne reste plus d'allumettes")
75 print("*vous avez perdu*")