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) | |
| | Returns:
"board:<br>{<br> ".........",<br> ".....4...",<br> ".........",<br> "......5..",<br> ".........",<br> ".........",<br> "......3..",<br> ".........",<br> "........."<br>}<br>nextThree:<br> "545"<br>" | |
|
1) | |
| | Returns:
"board:<br>{<br> ".........",<br> ".........",<br> ".......5.",<br> "3........",<br> ".........",<br> ".........",<br> ".........",<br> "....7....",<br> "........."<br>}<br>nextThree:<br> "773"<br>" | |
|
2) | |
| | Returns:
"board:<br>{<br> "..6.....4",<br> ".........",<br> ".........",<br> ".........",<br> ".........",<br> "...1.....",<br> ".........",<br> ".........",<br> "........."<br>}<br>nextThree:<br> "154"<br>" | |
|
3) | |
| | Returns:
"board:<br>{<br> ".........",<br> ".........",<br> ".........",<br> ".........",<br> "7........",<br> ".........",<br> ".........",<br> ".........",<br> "..6....2."<br>}<br>nextThree:<br> "563"<br>" | |
|
4) | |
| | Returns:
"board:<br>{<br> ".6.......",<br> ".....6...",<br> ".4.......",<br> ".........",<br> ".........",<br> ".........",<br> ".........",<br> ".........",<br> "........."<br>}<br>nextThree:<br> "745"<br>" | |
|
5) | |
| | Returns:
"board:<br>{<br> ".........",<br> ".........",<br> ".6.4.....",<br> "........6",<br> ".........",<br> ".........",<br> ".........",<br> ".........",<br> "........."<br>}<br>nextThree:<br> "151"<br>" | |
|
6) | |
| | Returns:
"board:<br>{<br> ".........",<br> ".........",<br> "......3..",<br> "..3......",<br> ".........",<br> ".........",<br> "..2......",<br> ".........",<br> "........."<br>}<br>nextThree:<br> "455"<br>" | |
|
7) | |
| | Returns:
"board:<br>{<br> ".........",<br> ".........",<br> ".....1...",<br> ".........",<br> ".6.......",<br> "......5..",<br> ".........",<br> ".........",<br> "........."<br>}<br>nextThree:<br> "527"<br>" | |
|
8) | |
| | Returns:
"board:<br>{<br> ".2.......",<br> ".........",<br> ".........",<br> ".........",<br> "...6.....",<br> ".........",<br> ".......1.",<br> ".........",<br> "........."<br>}<br>nextThree:<br> "564"<br>" | |
|
9) | |
| | Returns:
"board:<br>{<br> "........2",<br> ".........",<br> ".........",<br> ".........",<br> ".....2...",<br> ".........",<br> ".........",<br> "....5....",<br> "........."<br>}<br>nextThree:<br> "624"<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.