My code passes all of the test cases except for #7. I downloaded the .txt file for that test case and performed some experiments. Here is what I found:
(1) The range of x values is [-63, 63].
(2) The range of y values is [-63, 63].
(3) Every house but one has a house at y = -63 and y = 63.
So, with the following conditions, I calculate the worst case:
(1) at every x location there is a house at y = 63
(2) at every x location there is a house at y = -63
(3) lay horizontal cable at y = 0 intercept
(1) the cable length in the x direction = 63 - ( -63 ) = 126
(2) the cable length in the y direction = 126 houses * ( 63 - ( -63 ) ) = 15876
(3) the total cable length would be 126 + 15876 = 16002.
The problem is that Test case #7 appears to want me to enter 3142894 for the answer.
Does anyone have any ideas of what the discrepancy is?