Initial release
This commit is contained in:
48
Balade sur un échiquier.py
Normal file
48
Balade sur un échiquier.py
Normal file
@@ -0,0 +1,48 @@
|
||||
import requests
|
||||
|
||||
GET = "https://pydefis.callicode.fr/defis/BaladeEchiquier/get/Cavogrenier/4e9be"
|
||||
POST = "https://pydefis.callicode.fr/defis/BaladeEchiquier/post/Cavogrenier/4e9be"
|
||||
|
||||
|
||||
res = requests.get(GET)
|
||||
contents = res.text.splitlines()
|
||||
|
||||
print(res.text)
|
||||
print("***")
|
||||
|
||||
sig = contents[0]
|
||||
input = contents[1]
|
||||
|
||||
direction = 0 #0 = N, E = 1, S = 2, O = 3
|
||||
|
||||
cases = {"A1":""}
|
||||
pos = (1,1)
|
||||
for c in input:
|
||||
print(c, end=" ==> ")
|
||||
if c == "A":
|
||||
if direction == 0:
|
||||
pos = (pos[0], pos[1]+1)
|
||||
elif direction == 1:
|
||||
pos = (pos[0]+1, pos[1])
|
||||
elif direction == 2:
|
||||
pos = (pos[0], pos[1]-1)
|
||||
else:
|
||||
pos = (pos[0]-1, pos[1])
|
||||
elif c == "D":
|
||||
direction = (direction+1)%4
|
||||
elif c == "G":
|
||||
direction = (direction-1)%4
|
||||
else:
|
||||
raise ValueError("incorect char in input")
|
||||
print(chr(pos[0]+ord('A')-1)+str(pos[1]))
|
||||
cases[chr(pos[0]+ord('A')-1)+str(pos[1])] = ""
|
||||
|
||||
solution = str(len(cases))+chr(pos[0]+ord('A')-1)+str(pos[1])
|
||||
|
||||
print("solution:", solution)
|
||||
|
||||
param = {'sig':sig, 'rep':solution}
|
||||
res = requests.post(POST, verify=False, data=param)
|
||||
|
||||
print(res)
|
||||
print(res.text)
|
||||
Reference in New Issue
Block a user