Ejemplo n.º 1
0
def follow_line(instructions):
    pos = Coord(0, 0)
    for inst in instructions.split(','):
        direction = inst[0]
        distance = int(inst[1:])
        for _ in range(distance):
            if direction == 'U':
                pos = pos.up()
            elif direction == 'R':
                pos = pos.right()
            elif direction == 'D':
                pos = pos.down()
            elif direction == 'L':
                pos = pos.left()
            yield pos