# Puzzle 30) Rohit and the squares game

Submitted by Abhishek Jain, on September 30, 2017

**Puzzle**

Rohit and his friend playing a simple game of squares .This game consists of nine small squares within a large square (as shown below) and provide a box of matchsticks. The game is, placing one matchstick at a time alternately, to enclose more small squares than his friend. For every small square that he enclose he score one point and get an extra move. Twelve matchsticks are already placed, both of them made six moves each, and, as he had made the first move, it is now Rohit’s turn to place a matchstick.

**Question**

What is the best line of play for Rohit in order to enclose most small squares and win the game?

If Rohit play FG his friend will play BF and score one point. Then, as his friend has the right to play again, he will score another with EF and again with IJ, and still again with GK. If he now plays CD, Rohit have nothing better than DH (scoring one), but, as Rohit have to play again, he was compelled, whatever they do, to give him all the rest. So his friend will win by 8 to 1-a bad defeat for Rohit. What move should Rohit have to make instead of that disastrous FG? There is room for a lot of skillful play in the game, and it can never end in a draw.

**Answer**

Rohit should play HL. His friend may play MN, and then Rohit play CD. (If his friend had played CD, Rohit should have replied MN, leaving the same position.) The best his friendcan now do is DH (scoring one), but, as he has to play again, Rohit win the remaining eight squares.

TOP Interview Coding Problems/Challenges

- Run-length encoding (find/print frequency of letters in a string)
- Sort an array of 0's, 1's and 2's in linear time complexity
- Checking Anagrams (check whether two string is anagrams or not)
- Relative sorting algorithm
- Finding subarray with given sum
- Find the level in a binary tree with given sum K
- Check whether a Binary Tree is BST (Binary Search Tree) or not
- 1[0]1 Pattern Count
- Capitalize first and last letter of each word in a line
- Print vertical sum of a binary tree
- Print Boundary Sum of a Binary Tree
- Reverse a single linked list
- Greedy Strategy to solve major algorithm problems
- Job sequencing problem
- Root to leaf Path Sum
- Exit Point in a Matrix
- Find length of loop in a linked list
- Toppers of Class
- Print All Nodes that don't have Sibling
- Transform to Sum Tree
- Shortest Source to Destination Path

Comments and Discussions