Puzzling Asked by Dr Xorile on April 5, 2021
Do you have what it takes to compete in the famous Vega Classic?
Looking for skilled navigators. Apply below.
You have a craft that is capable of 10m/s$^2$ acceleration in any direction, and we’re looking for the fasted time from Vega Starship 1 to Vega Starship 2 around the beacon.
The rules of the race:
Please supply your commands in this format:
$[[(t_0,t_1),(a_{x,0},a_{y,0})]$,
$[(t_1,t_2),(a_{x,1},a_{y,1})]$,
…
$[(t_{n-1},t_n),(a_{x,n-1},a_{y,n-1})]]$
where $t_0 = 0$, $t_n$ is your total time, and $t_k$ is the time of your $k$th adjustment. And the $k$th acceleration component is such that $a_{x,k}^2+a_{y,k}^2leq a^2$. Your acceleration can also be provided as an angle in radians, where 0 is to the right, and $pi/2$ is straight up. Such a co-ordinate would look like this: $[(t_k,t_{k+1}),theta_k]$. You can mix and match.
Or, feel free to justify your answer in your own way! But it may take longer to adjudicate.
Note, we’re assuming non-relativistic velocities here.
Here’s python code for evaluating a solution in the given format. Final position should be within 1m of the target, and the velocity should be "close to zero" meaning substantially less than 1.
import numpy as np
def race(commands):
L1 = 1e6 #m - horizontal distance
L2 = 1e8 #m - vertical distance
a = 10 #m/s^2
x,y,vx,vy = 0,0,0,0
for cmd in commands:
if type(cmd[1]) is tuple or type(cmd[1]) is list:
#cmd[1] is acceleration components
assert abs(cmd[1][0]**2 + cmd[1][1]**2 - a**2)<0.00001
ax,ay = cmd[1]
else:
#cmd[1] is acceleration angle
ax,ay = a*np.cos(cmd[1]), a*np.sin(cmd[1])
burnTime = cmd[0][1]-cmd[0][0]
dt = burnTime / int(burnTime+1)
for i in range(int(burnTime+1)):
x,y,vx,vy = x + vx*dt + 0.5*ax*dt**2,y + vy*dt + 0.5*ay*dt**2,vx + ax*dt,vy + ay*dt
if x<L1 and y>0:
print("Warning:",x,y,vx,vy)
print("Time:",cmd[0][1])
print("Final position & velocity:",x,y,vx,by)
For reference, my current record has a current output of:
Final position & velocity: 1000000.0000009941 100000000.16834144 2.41069386675008e-10 -3.068626813984565e-06
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP