# This program recursively prints all paths # to a given target (x, y) position. # Prints all paths from (x, y) to target (tx, ty) # that can be made by going N, E, or NE by one step. def travel(tx, ty, x = 0, y = 0, path = ""): if x == tx and y == ty: print(path) elif x <= tx and y <= ty: travel(tx, ty, x, y + 1, path + "N ") travel(tx, ty, x + 1, y, path + "E ") travel(tx, ty, x + 1, y + 1, path + "NE ") def main(): x = int(input("Target x? ")) y = int(input("Target y? ")) travel(x, y) main()