Marathon Match 5 - Marathon Match 5

Key Information

Register
Submit
The challenge is finished.

Challenge Overview

Problem Statement

    

Linez is a single-player board game played on a 9x9 grid. On each turn, the player must move one of the numbers on the board to an empty cell where a clear path (consisting of horizontally connected or vertically connected empty cells) exists between the new position and the old. If five or more same numbers are aligned in a row, column, or diagonal, they will be removed from the board. The player will gain 10+k*(k-5)/2 points (k being the number of removals) and can make another move. Otherwise, three more numbers will be placed onto the board at randomly chosen positions before the player can move again. The objective is to score as many points as possible before the whole board fills up. (An online version of the Linez game is available at http://linez.varten.net/.)

Your task is to write a class to play the Linez game. The method nextMove will be given the board configuration and the next three numbers. board will contain 9 Strings representing the rows of the board from top to bottom. Each element will contain 9 characters. Each character will be '1' to '7' representing the number on that cell, or '.' if that position is unoccupied. nextThree will contain 3 characters. Each element of nextThree will be '1' to '7' representing the number to be added to the board next turn. The return value of nextMove must contain 4 characters, the first two representing the original position of the number to be moved, the next two representing the target position. For example, to move the number "4" from "I8" to "F6" as shown below, return "I8F6".

You will have a total of 20 seconds for each test case. The memory limit is 64MB. Your final score will be the mean score on all the test cases.

 

Definition

    
Class:Linez
Method:nextMove
Parameters:String[], String
Returns:String
Method signature:String nextMove(String[] board, String nextThree)
(be sure your method is public)
    
 

Notes

-Each number of nextThree will be chosen uniformly between 1 and 7, inclusive.
-Each empty cell has an equal probability to be chosen when the next number is added to the board.
-If your solution crashes, runs out of time, or tries to make an invalid move it will receive the points it has made so far for that test case.
 

Examples

0)
    
"149738788"
Returns: 
"board:<br>{<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;.....4...&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;......5..&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;......3..&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;<br>}<br>nextThree:<br>&nbsp;&nbsp;&quot;545&quot;<br>"
1)
    
"1982697456"
Returns: 
"board:<br>{<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;.......5.&quot;,<br>&nbsp;&nbsp;&quot;3........&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;....7....&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;<br>}<br>nextThree:<br>&nbsp;&nbsp;&quot;773&quot;<br>"
2)
    
"2060431272"
Returns: 
"board:<br>{<br>&nbsp;&nbsp;&quot;..6.....4&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;...1.....&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;<br>}<br>nextThree:<br>&nbsp;&nbsp;&quot;154&quot;<br>"
3)
    
"1077274560"
Returns: 
"board:<br>{<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;7........&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;..6....2.&quot;<br>}<br>nextThree:<br>&nbsp;&nbsp;&quot;563&quot;<br>"
4)
    
"825809896"
Returns: 
"board:<br>{<br>&nbsp;&nbsp;&quot;.6.......&quot;,<br>&nbsp;&nbsp;&quot;.....6...&quot;,<br>&nbsp;&nbsp;&quot;.4.......&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;<br>}<br>nextThree:<br>&nbsp;&nbsp;&quot;745&quot;<br>"
5)
    
"1911009"
Returns: 
"board:<br>{<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;.6.4.....&quot;,<br>&nbsp;&nbsp;&quot;........6&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;<br>}<br>nextThree:<br>&nbsp;&nbsp;&quot;151&quot;<br>"
6)
    
"149738789"
Returns: 
"board:<br>{<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;......3..&quot;,<br>&nbsp;&nbsp;&quot;..3......&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;..2......&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;<br>}<br>nextThree:<br>&nbsp;&nbsp;&quot;455&quot;<br>"
7)
    
"1109944003"
Returns: 
"board:<br>{<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;.....1...&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;.6.......&quot;,<br>&nbsp;&nbsp;&quot;......5..&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;<br>}<br>nextThree:<br>&nbsp;&nbsp;&quot;527&quot;<br>"
8)
    
"1732993602"
Returns: 
"board:<br>{<br>&nbsp;&nbsp;&quot;.2.......&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;...6.....&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;.......1.&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;<br>}<br>nextThree:<br>&nbsp;&nbsp;&quot;564&quot;<br>"
9)
    
"1438702088"
Returns: 
"board:<br>{<br>&nbsp;&nbsp;&quot;........2&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;.....2...&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;,<br>&nbsp;&nbsp;&quot;....5....&quot;,<br>&nbsp;&nbsp;&quot;.........&quot;<br>}<br>nextThree:<br>&nbsp;&nbsp;&quot;624&quot;<br>"

This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2020, TopCoder, Inc. All rights reserved.