Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Walking Paths with Complex Numbers.
def rotate(vector, angle): rotation_matrix = [ [cos(angle), -sin(angle)], [sin(angle), cos(angle)] ] return rotation_matrix * vector position = (0, 0) velocity = (0, 1) for instruction in [x.strip() for x in input.split(",")]: direction = instruction[0] distance = int(instruction[1:]) angle = 90 if direction == 'L' else -90 velocity = rotate(velocity, angle) position += velocity * distance print position