# Solution for “Empty and Divide” problem

Problem statement:

There are two boxes. Initially, one box contains $m$ chips and the other contains n chips. Such a position is denoted by (m,n), where m > 0 and n > 0. The two players alternate moving. A move consists of emptying one of the boxes, and dividing the contents of the other between the two boxes with at least one chip in each box. There is a unique terminal position, namely (1, 1). Last player to move wins. Find all P-positions.

# SPOJ PALIN solution

Solution for problem http://www.spoj.com/problems/PALIN/ from SPOJ website.

Sometimes I stuck solving some problems from there (usually because my code either add unneeded new line or doesn’t add needed new line and I am finding what is wrong by trial and error), so here is working solution for PALIN that can save you time if you encounter some strange Wrong Answer or NZEC errors. Continue reading

# SPOJ COINS solution

Solution for problem http://www.spoj.com/problems/COINS/ from SPOJ website.

Sometimes I stuck solving some problems from there (usually because my code either add unneeded new line or doesn’t add needed new line and I am finding what is wrong by trial and error), so here is working solution for COINS that can save you time if you encounter some strange Wrong Answer or NZEC errors. Continue reading

# SPOJ LASTDIG solution

Solution for problem http://www.spoj.com/problems/LASTDIG/ from SPOJ website.

Sometimes I stuck solving some problems from there (usually because my code either add unneeded new line or doesn’t add needed new line and I am finding what is wrong by trial and error), so here is working solution for LASTDIG that can save you time if you encounter some strange Wrong Answer or NZEC errors. Continue reading