|
|
|
|
|
by deckar01
3490 days ago
|
|
Here is the pseudo-code for matrix rotation for comparison: 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
|
|