Advertisement
philRG

ReadMe Fantastic Bits

Jan 19th, 2021
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. https://www.codingame.com/ide/puzzle/fantastic-bits
  2.  
  3. Description sommaire du problème hongrois:
  4. https://www.developpez.net/forums/blogs/283256-f-leb/b17/python-problemes-daffectation-methode-hongroise/
  5.  
  6. Implementation choice in this challenge:
  7.  
  8. - First, we build a 2d matrix representing distances between each wizard and each snaffle
  9.  
  10. distances---s1------s2-----s3------s4-------s5------s6------s7
  11.  
  12. wiz_1-------50------70-----100-----120------80------150-----200
  13.  
  14. wiz_2-------130-----20------5------179------20------30------40
  15.  
  16. - Second, we create a dictionary to create an association from each wizard to a distinct snaffle describing the cost matrix in term of distance/duration of moves:
  17.  
  18. `costs[(0, i), (1, j)] = matrix[0][i] + matrix[1][j] (i, j going from 1 to snaffles_count and i != j)
  19. `
  20.  
  21. - Third, we choose the best combination to optimize global team effort (extracts the dictionary key (tuple) of minimum cost value)
  22.  
  23. `best_combination = min(costs)`
  24.  
  25. `i, j = best_combination[0][1], best_combination[1][1]`
  26.  
  27. - Finally, we extract the snaffle target for each wizard:
  28.  
  29. `wiz_1.target, wiz_2.target = snaffles[i], snaffles[j]`
  30.  
  31.  
  32. Replays:
  33. - Ligue Bois 2: https://www.codingame.com/replay/496545129
  34. - Ligue Bois 1 (with bludgers): https://www.codingame.com/share-replay/496563891
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement