As shown in the image, there is a river running between 2 banks. There are 9 islands in the river, and these land masses are connected by 18 bridges. The inhabitants can only use these bridges to get across the river (no swimming, boats, etc. are allowed).
One day, an extremely heavy storm destroys at least one of the bridges, which prevents the inhabitants from crossing directly between the connected land masses. Out of the cases where at least one bridge is destroyed, in how many cases can the inhabitants still cross between the two banks?
Hint:
The trick used to solve
the previous problem
cannot be used here. Good luck!
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
The matrix A stores the number of bridges between each pair of locations. From the starting bank, pick a bridge to any of the islands.
Case 1: That bridge is destroyed, then just delete that bridge from A, and compute f.
Case 2: That bridge is not destroyed, then that island may as well be on the bank, so I imagine moving that island to the bank, (along with any bridges coming off that island). Then compute f.
Then we add the 2 results together and repeat this process. This ends when the starting bank is not connected to any islands. Then if a is the number of bridges between the 2 banks, there are 2 a − 1 subsets of those bridges which could be destroyed, and if b is the number of other bridges, there are 2 b subsets of those which could be destroyed. So the number of subsets of bridges which could be destroyed is 2 b ( 2 a − 1 )
Here's my MATLAB code. The matrix A stores the number of bridges between locations. The first and last rows/columns correspond to the starting and ending banks.
We have to remember to subtract 1 at the end since we don't want to count the case where no bridges are destroyed.
To set up A I used the code below, but there are only 18 edges, so you could just add them one at a time.