13
$\begingroup$

There has been a water incident on the top floor of a building, and one apartment has suffered some water damage. As in, a lot of water damage. The entire apartment is filled waist deep with dihydrogen monoxide. As a contractor, you are tasked with getting the liquid out. All plumbing is out of order due to the aforementioned incident, and there is no feasible way to get any pumping equipment up into the apartment. The only way the get the water out is to break some walls and floors to allow the water to flow freely into a well on the ground floor (marked red).

You propose a way to get the water out along the hallways to avoid flooding any of the other apartments. However, the landlord will have to pay for repairs on the rooms used to pass the water through, and the price is solely dependent on the affected area (i.e. repairing one square of the hallway costs the same as repairing one square of an apartment). For that reason, the landlord will gladly allow you to pass through another apartment if that means a smaller overall area will be used to get the water out.

Rules:

  • You can make a hole in the wall or floor of any room (apartment or hallway) currently containing water, but not the outer walls of the building.
  • Once a hole is made on a wall piece, the water spreads out through it to fill the available area evenly.
  • Once a hole is made on a floor piece, all of the water flows down to the next floor below and fills the available area evenly.
  • Once the water reaches the well, all of it will flow in and the mission is complete.
  • There is no extra cost in fixing holes made on walls/floors, so make as many holes as is necessary to get the water out.
  • Water does not flow upwards.
  • There is no elevator or stairwell, because who thinks of those things when drawing a building.

How many squares will the landlord need to repair after you've gotten the water out? While keeping the number of squares at a minimum, what is the minimum number of other apartments (gray rectangles) that you must temporarily fill with water?

Initial situation

enter image description here

Rejected proposal (Holes are marked with X's)

enter image description here

$\endgroup$
8
  • 2
    $\begingroup$ dihydrogen monoxide. wow +1. and optimization tag? $\endgroup$ Aug 13, 2019 at 9:18
  • $\begingroup$ what is the cost of repairing a wall piece?? 0? $\endgroup$ Aug 13, 2019 at 9:20
  • $\begingroup$ @OmegaKrypton Thanks, tag added. The cost of repairing holes made on walls/floors is zero. I'll add a mention about that in the description. $\endgroup$
    – Jafe
    Aug 13, 2019 at 9:26
  • $\begingroup$ in the rejected proposal, why will all hallway grids be flooded? wont all water go through the hole directly? $\endgroup$ Aug 13, 2019 at 9:28
  • $\begingroup$ @OmegaKrypton Hmm, true. The idea was to make the holes one by one starting where the water is now, but that doesn't really appear in the rules as written... $\endgroup$
    – Jafe
    Aug 13, 2019 at 9:48

2 Answers 2

8
$\begingroup$

I may need some clarification on counting but I think I've found a solution in which the landlord needs to repair 38 squares while filling just 3 other apartments with water.

Solution

enter image description here

Partial Reasoning

Except for the 5th floor and the 1st floor, every floor has its 3rd column as entirely hallway. This means that we need to either enter the hallway on some floor that is not the 1st or we need to flood the apartment on the left on the 1st floor.

In the latter case, the most efficient way to get to the well from the first floor is to break through to the apartment at the top and go straight down over the well. This would damage 20 squares on the first floor. We must flood at least four squares on each of the other floors but, since the four square apartment on the 2nd floor is not linked to either of the four square apartments on the 3rd floor, this means at least one of the floors will have to have at least six squares flooded. There is a 38 square solution in this case which floods 5 other apartments as shown:
enter image description here
In the former case, we must choose which hallway to flood. The hallway on the 4th floor has just 11 squares, 4 less than the next smallest (that is not the 1st floor). With this choice, it is not too difficult to find a path which passes through just one apartment on each of the other floors.
Furthermore, if we try to flood the hallway on any other floor, we find we are forced into making decisions which flood more than 38 squares.

$\endgroup$
2
  • $\begingroup$ This is the intended answer. It would be nice to know how you arrived at the solution, though. $\endgroup$
    – Jafe
    Aug 13, 2019 at 12:18
  • $\begingroup$ @jafe I'll try to add some reasoning about why I came to this conclusion $\endgroup$
    – hexomino
    Aug 13, 2019 at 13:02
0
$\begingroup$

28 squares (not counting the already flooded top floor apartment or ground floor hallway - 48 if you include them) and three apartments.

Holes are marked in pink
enter image description here
5th floor hole: One of the top two squares in the flooded apartment. This floods the 4th floor hallway (11 squares)
4th floor hole: End of the hallway on the right edge of the building. This floods the apartment in the bottom right corner (9 squares)
3rd floor hole: Middle of that apartment. This floods the apartment in the bottom right corner (4 squares)
2nd floor hole: Top right of that apartment. This floods the apartment in the bottom right corner (4 squares)
1st floor hole: One of the top two squares in the apartment. This floods the ground floor hallway

$\endgroup$
3
  • $\begingroup$ Why would the ground floor hallway not count? $\endgroup$
    – El-Guest
    Aug 14, 2019 at 1:43
  • $\begingroup$ hexomino did not count the ground floor. $\endgroup$ Aug 14, 2019 at 2:22
  • $\begingroup$ Hexomino’s hole in the first floor was directly above the well, so the water went straight from the first floor into the well — it didn’t flood the rest of the ground floor, @EugeneStyer. $\endgroup$
    – El-Guest
    Aug 14, 2019 at 11:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.