Advertisement
Guest User

truc de ouf (#2) with function to *help* to find time of encounter between 2 spiders

a guest
May 1st, 2022
37
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.76 KB | None
  1. # Tableau des points de rencontres:
  2. # (spider 1, spider 2, Hero) = (n° de tour, distance entre les 2 araignées, coordonnées du point de rencontre pour pouvoir faire le Wind)
  3. # https://www.codingame.com/share-replay/630295305
  4.  
  5. def time_when_spiders_are_closest_discord(s1: Spider, s2: Spider) -> int:
  6.     # minimize (dx + vx * t) ** 2 + (dy + vy * t ) ** 2
  7.     dx, dy = s1.location - s2.location  # relative position
  8.     vx, vy = s1.velocity - s2.velocity  # relative velocity
  9.     return -(dx * vx + dy * vy) / 400 ** 2
  10.  
  11.  
  12. def time_when_spiders_are_closest(s1: Spider, s2: Spider) -> int:
  13.     relative_location = s1.location - s2.location  # relative position
  14.     relative_velocity = s1.velocity - s2.velocity  # relative velocity
  15.     return -np.dot(relative_velocity, relative_location) / 400 ** 2
  16.  
  17. [((16, 29, 2), (1, 1901, '[3901. 5091.]')),
  18.  ((29, 16, 2), (1, 1901, '[3901. 5091.]')),
  19.  ((12, 29, 1), (3, 5579, '[5345.  -13.]')),
  20.  ((29, 12, 1), (3, 5579, '[5345.  -13.]')),
  21.  ((11, 29, 1), (3, 5837, '[5520. -241.]')),
  22.  ((29, 11, 1), (3, 5837, '[5520. -241.]')),
  23.  ((24, 23, 1), (4, 2362, '[5926. 3576.]')),
  24.  ((23, 24, 1), (4, 2362, '[5926. 3576.]')),
  25.  ((24, 23, 2), (4, 2362, '[5926. 3576.]')),
  26.  ((23, 24, 2), (4, 2362, '[5926. 3576.]')),
  27.  ((7, 19, 2), (4, 4761, '[ 238. 3718.]')),
  28.  ((19, 7, 2), (4, 4761, '[ 238. 3718.]')),
  29.  ((15, 24, 2), (4, 5939, '[-138. 5552.]')),
  30.  ((24, 15, 2), (4, 5939, '[-138. 5552.]')),
  31.  ((18, 27, 0), (5, 1513, '[13244.  6234.]')),
  32.  ((27, 18, 0), (5, 1513, '[13244.  6234.]')),
  33.  ((19, 24, 2), (5, 2002, '[3336. 1370.]')),
  34.  ((24, 19, 2), (5, 2002, '[3336. 1370.]')),
  35.  ((19, 24, 1), (5, 2002, '[4630.  598.]')),
  36.  ((24, 19, 1), (5, 2002, '[4630.  598.]')),
  37.  ((16, 26, 1), (8, 2722, '[3149. 1677.]')),
  38.  ((26, 16, 1), (8, 2722, '[3149. 1677.]')),
  39.  ((16, 26, 2), (8, 2722, '[3149. 1677.]')),
  40.  ((26, 16, 2), (8, 2722, '[3149. 1677.]')),
  41.  ((16, 24, 2), (10, 4244, '[ 301. 2971.]')),
  42.  ((24, 16, 2), (10, 4244, '[ 301. 2971.]')),
  43.  ((16, 24, 1), (10, 4244, '[2697.  -45.]')),
  44.  ((24, 16, 1), (10, 4244, '[2697.  -45.]')),
  45.  ((7, 24, 1), (12, 6244, '[ 6954. -3106.]')),
  46.  ((24, 7, 1), (12, 6244, '[ 6954. -3106.]')),
  47.  ((7, 24, 2), (12, 6244, '[ 6954. -3106.]')),
  48.  ((24, 7, 2), (12, 6244, '[ 6954. -3106.]')),
  49.  ((26, 29, 0), (16, 4591, '[3858. 2486.]')),
  50.  ((29, 26, 0), (16, 4591, '[3858. 2486.]')),
  51.  ((26, 29, 1), (16, 4591, '[3858. 2486.]')),
  52.  ((29, 26, 1), (16, 4591, '[3858. 2486.]')),
  53.  ((26, 29, 2), (16, 4591, '[3858. 2486.]')),
  54.  ((29, 26, 2), (16, 4591, '[3858. 2486.]')),
  55.  ((29, 24, 0), (17, 6011, '[2356.  675.]')),
  56.  ((24, 29, 0), (17, 6011, '[2356.  675.]')),
  57.  ((29, 24, 1), (17, 6011, '[2356.  675.]')),
  58.  ((24, 29, 1), (17, 6011, '[2356.  675.]')),
  59.  ((29, 24, 2), (17, 6011, '[2356.  675.]')),
  60.  ((24, 29, 2), (17, 6011, '[2356.  675.]'))]
  61.  
Advertisement
RAW Paste Data Copied
Advertisement