Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
numpy solution in 3rd party category for Shooting Range by kazuki.h
import numpy as np
def shot(*points):
a, b, p, q = map(np.array, points)
M = np.array([b-a, p-q]).T
if np.linalg.det(M) == 0: return -1
t, s = np.dot(np.linalg.inv(M), p-a)
return round(200*(0.5-abs(t-0.5))) if 0 <= t <= 1 and s > 0 else -1
Dec. 20, 2021
Comments: