In the loggers link problem each log can be cut down into smaller logs of size greater than 1, but for some of the size of there may be chance the log can be cut down in different number of times for example log of size 4 can be cut down in 2 ways (3,1)->(1.5,1.5) or (2,2)->(1,1)(1,1) .As in question it is mentioned that both the players will play optimally then according both the possible case must be considered.
I have taken a single test case of
here as Alice makes the first move Alice should win as she will choose the best way to cut log of size 4 so that she can win. The cutting moves would be
- First alice will cut log of size 4 to (3,1)
- Now for Bob he has only 2 options cutting log of size 2 or 3 if he choose 2 in the next move Alice will cut the last log and she would win.
But in most of the accepted solution the answer to this test case is Bob.
I cant understand how to consider such case in coding.
Please help me in this matter