adding RLOU/RLUD -> Graph

This commit is contained in:
2025-08-19 23:55:07 +02:00
parent 4c805d85ca
commit 8987e95775
4 changed files with 54 additions and 76 deletions

View File

@@ -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