adding RLOU/RLUD -> Graph
This commit is contained in:
27
app/tools.py
27
app/tools.py
@@ -2662,3 +2662,30 @@ def text_to_ook(eingabetext):
|
||||
for z in short_ook:
|
||||
ook_txt += f"Ook{z} "
|
||||
return f":blue[Short-Ook:] \n{short_ook} \n \n:blue[Ook:] \n{ook_txt}"
|
||||
|
||||
def rlou_to_graph(eingabetext):
|
||||
eingabetext = eingabetext.rstrip()
|
||||
if eingabetext == "":
|
||||
return hilfetexte.rlou_to_graph, None
|
||||
else:
|
||||
if "O" in eingabetext.upper():
|
||||
moves = {'R': (1, 0), 'L': (-1, 0), 'O': (0, 1), 'U': (0, -1)}
|
||||
elif "D" in eingabetext.upper():
|
||||
moves = {'R': (1, 0), 'L': (-1, 0), 'U': (0, 1), 'D': (0, -1)}
|
||||
else:
|
||||
return (":red[Es wurde weder ein O oder ein D gefunden um festzustellen ob RLOU oder RLUD verwendet werden"
|
||||
"soll]"), None
|
||||
directions_list = eingabetext.split()
|
||||
x, y = 0, 0
|
||||
path = []
|
||||
for directions in directions_list:
|
||||
part = [(x,y)]
|
||||
for d in directions.upper():
|
||||
if d in moves:
|
||||
dx, dy = moves[d]
|
||||
x += dx
|
||||
y += dy
|
||||
part.append((x, y))
|
||||
path.append(part)
|
||||
x += 3
|
||||
return f":blue[Graph:]", path
|
||||
|
||||
Reference in New Issue
Block a user