2023-11-15 02:41:07 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import toyrobot
|
|
|
|
|
|
|
|
|
|
|
|
def feed_file(filename: str, robot: toyrobot.Robot):
|
|
|
|
with open(filename) as f:
|
|
|
|
for line in f:
|
|
|
|
line = line.strip()
|
|
|
|
print(line)
|
|
|
|
robot.interpret_command(line)
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
print("a)")
|
|
|
|
feed_file("example_a.txt", toyrobot.Robot())
|
|
|
|
print()
|
|
|
|
|
|
|
|
print("b)")
|
|
|
|
feed_file("example_b.txt", toyrobot.Robot())
|
|
|
|
print()
|
|
|
|
|
|
|
|
print("c)")
|
|
|
|
feed_file("example_c.txt", toyrobot.Robot())
|
|
|
|
print()
|
|
|
|
|
|
|
|
print("d)")
|
|
|
|
feed_file("example_d.txt", toyrobot.Robot())
|
|
|
|
print()
|
|
|
|
|
|
|
|
print("e)")
|
|
|
|
feed_file("example_e.txt", toyrobot.Robot())
|
|
|
|
print()
|
|
|
|
|
|
|
|
print("f)")
|
|
|
|
feed_file("example_f.txt", toyrobot.Robot())
|
|
|
|
print()
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|