Guest User

Untitled

a guest
Sep 25th, 2016
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 KB | None | 0 0
  1. Escape Pods
  2. ===========
  3.  
  4. You've blown up the LAMBCHOP doomsday device and broken the bunnies out of Lambda's prison - and now you need to escape from the space station as quickly and as orderly as possible! The bunnies have all gathered in various locations throughout the station, and need to make their way towards the seemingly endless amount of escape pods positioned in other parts of the station. You need to get the numerous bunnies through the various rooms to the escape pods. Unfortunately, the corridors between the rooms can only fit so many bunnies at a time. What's more, many of the corridors were resized to accommodate the LAMBCHOP, so they vary in how many bunnies can move through them at a time.
  5.  
  6. Given the starting room numbers of the groups of bunnies, the room numbers of the escape pods, and how many bunnies can fit through at a time in each direction of every corridor in between, figure out how many bunnies can safely make it to the escape pods at a time at peak.
  7.  
  8. Write a function answer(entrances, exits, path) that takes an array of integers denoting where the groups of gathered bunnies are, an array of integers denoting where the escape pods are located, and an array of an array of integers of the corridors, returning the total number of bunnies that can get through at each time step as an int. The entrances and exits are disjoint and thus will never overlap. The path element path[A][B] = C describes that the corridor going from A to B can fit C bunnies at each time step. There are at most 50 rooms connected by the corridors and at most 2000000 bunnies that will fit at a time.
  9.  
  10. For example, if you have:
  11. entrances = [0, 1]
  12. exits = [4, 5]
  13. path = [
  14. [0, 0, 4, 6, 0, 0], # Room 0: Bunnies
  15. [0, 0, 5, 2, 0, 0], # Room 1: Bunnies
  16. [0, 0, 0, 0, 4, 4], # Room 2: Intermediate room
  17. [0, 0, 0, 0, 6, 6], # Room 3: Intermediate room
  18. [0, 0, 0, 0, 0, 0], # Room 4: Escape pods
  19. [0, 0, 0, 0, 0, 0], # Room 5: Escape pods
  20. ]
  21.  
  22. Then in each time step, the following might happen:
  23. 0 sends 4/4 bunnies to 2 and 6/6 bunnies to 3
  24. 1 sends 4/5 bunnies to 2 and 2/2 bunnies to 3
  25. 2 sends 4/4 bunnies to 4 and 4/4 bunnies to 5
  26. 3 sends 4/6 bunnies to 4 and 4/6 bunnies to 5
  27.  
  28. So, in total, 16 bunnies could make it to the escape pods at 4 and 5 at each time step. (Note that in this example, room 3 could have sent any variation of 8 bunnies to 4 and 5, such as 2/6 and 6/6, but the final answer remains the same.)
  29.  
  30. Languages
  31. =========
  32.  
  33. To provide a Python solution, edit solution.py
  34. To provide a Java solution, edit solution.java
  35.  
  36. Test cases
  37. ==========
  38.  
  39. Inputs:
  40. (int list) entrances = [0]
  41. (int list) exits = [3]
  42. (int) path = [[0, 7, 0, 0], [0, 0, 6, 0], [0, 0, 0, 8], [9, 0, 0, 0]]
  43. Output:
  44. (int) 6
  45.  
  46. Inputs:
  47. (int list) entrances = [0, 1]
  48. (int list) exits = [4, 5]
  49. (int) path = [[0, 0, 4, 6, 0, 0], [0, 0, 5, 2, 0, 0], [0, 0, 0, 0, 4, 4], [0, 0, 0, 0, 6, 6], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]
  50. Output:
  51. (int) 16
Add Comment
Please, Sign In to add comment