Every man in a village of 100 married couples has cheated on his wife. Every wife in the village instantly knows when a man other than her husband has cheated, but does not know when her own husband has. The village has a law that does not allow for adultery. Any wife who can prove that her husband is unfaithful must kill him that very day. The women of the village would never disobey this law. One day, the queen of the village visits and annoces that at least one husband has benn unfaithful. What happens?
This question will be solved with recursion.
Lets say there is only one couple, on the same day wife kills the man.
if there are 2 couples, on second day, both the wives kill the men. Because, on the first day each wife waited for the other man to get killed but it did not happen.
So, if there is 100 couple, after 100 days all men will be killed.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks