Guest User

Untitled

a guest
Oct 21st, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. We have some rooms in our datacenter, and we need to connect them all with a single cooling duct.
  2.  
  3. Here are the rules:
  4.  
  5. The datacenter is represented by a 2D grid.
  6. Rooms we own are represented by a 0.
  7. Rooms we do not own are represented by a 1.
  8. The duct has to start at the air intake valve, which is represented by a 2.
  9. The duct has to end at the air conditioner, which is represented by a 3.
  10. The duct cannot go in multiple directions out of the intake or the AC - they must be the two endpoints of the duct.
  11. The duct must pass through each room exactly once.
  12. The duct cannot pass through rooms we do not own.
  13. The duct can connect between rooms horizontally or vertically but not diagonally.
  14. Here is an example datacenter:
  15.  
  16. 2 0 0 0
  17.  
  18. 0 0 0 0
  19.  
  20. 0 0 3 1
  21.  
  22. There are two possible ways to run the duct here:
  23.  
  24. 2--0--0--0
  25. |
  26. 0--0--0--0
  27. |
  28. 0--0--3 1
  29. or
  30.  
  31. 2 0--0--0
  32. | | |
  33. 0 0 0--0
  34. | | |
  35. 0--0 3 1
  36. Write a program to compute the number of possible ways to run the duct. For the above example, the correct answer is 2.
Add Comment
Please, Sign In to add comment