A programming contest about the Candy Crush Saga game

Chia sẻ bởi Nguyễn Nhật Nam | Ngày 16/10/2018 | 48

Chia sẻ tài liệu: A programming contest about the Candy Crush Saga game thuộc Tư liệu tham khảo

Nội dung tài liệu:

CANDY CRUSH SAGA
Candy Crush Saga is a free-to-play match-three puzzle video game released by King on April 12, 2012. is considered one of the first and most successful uses of a freemium model. In the game, players complete levels by swapping coloured pieces of candy on a game board to make a match of three or more of the same color, eliminating those candies from the board and replacing them with new ones, which could potentially create further matches. Matches of four or more candies create unique candies that act as power-ups with larger board-clearing abilities.
SCORE TABLE
Task no.
Number of tests
Total marks
Time limits
Score for each test:

1
22
25
1s
Test 1-7 worth 4 points
Test 8-19 worth 1 points/test
Test 20-22 worth 3 points/test

2
39
30
1s
Logic test: 36 tests, each failed test decrease 10% score
Performance test: 3 tests, each failed test decrease 20% score
0 point if number of passed tests < 26

3
34
45
1s
Logic test: 31 tests, each failed test decrease 12% score
Performance test: 3 tests, each failed test decrease 24% score
0 point if number of passed tests < 23

TASK 1: FILE NAME: CANDYCRUSH1.???
Determine whether the given gameboard contains a set of 3 or more consecutive candies of the same color in either a row or a column.
EXAMPLES
With input…
the output should be…
because…

gameboard =
[["R","B","G"], ["R","Y","B"], ["R","O","Y"]]
true
There is a column with three candies of color R (red).

gameboard=
[["Y","R","Y"], ["R","Y","R"], ["Y","R","Y"]]
false
There is no set of three consecutive candies of the same color in either a row or a column.

gameboard = [["Y","O","R","G","Y"], ["G","P","R","O","B"], ["R","B","R","B","G"], ["B","O","R","P","P"], ["P","G","O","Y","R"]]
true
There is a column with four candies of color R (red).

INPUT/OUTPUT
[input] array.array.char gameboard
A 2D matrix of characters, with each character representing a color: `R` (red), `B`(blue), `G` (green), `Y` (yellow), `P` (purple), `O` (orange).
Guaranteed constraints: 1 ≤ gameboard.length ≤ 200, 1 ≤ gameboard[i].length ≤ 200, 3 ≤ gameboard.length ≤ 200 || 3 ≤ gameboard[i].length ≤ 200 .
[output] boolean
Return true if the gameboard contains at least three consecutive candies of the same color either in a row or in a column, otherwise return false.
TASK 2: FILE NAME: CANDYCRUSH2.???
Let candyCrush1 be a boolean function that returns true if the gameboard contains a set of three or more consecutive candies of the same color in a row or in a column, and false otherwise.
Your task is to check if a move from the given cell in the given direction is valid, such that after the move is made candyCrush1(newGameboard) will be true. It`s guaranteed that the move is made inside the gameboard, so you don`t have to handle test cases like moving from cell [0,0] to the left. It`s also guaranteed that there`s no set of 3 candies of the same color in a row or a column, i.e. candyCrush1(gameboard) is false.
EXAMPLES
With input…
the output should be…
because…

gameboard = [[`R`,`G`,`G`,`B`],
[`B`,`O`,`G`,`G`],
[`P`,`O`,`B`,`P`],
[`Y`,`B`,`Y`,`O`]]
cell = [0, 1] 
direction = `D`
true
After the move, the gameboard will look like the following:
[[`R`,`O`,`G`,`B`],
[`B`,`G`,`G`,`G`],
[`P`,`O`,`B`,`P`],
[`Y`,`B`,`Y`,`O`]]
There`s a row of three consecutive in the first (0-based) row, so the answer is true.

gameboard = [[`R`,`G`,`G`,`B`],
[`B`,`O`,`G`,`G`],
[`P`,`O`,`B`,`P`],
[`Y`,`B`,`Y`,`O`]]
cell = [1, 1] 
direction = `U`
true
This test case is similar to the previous one, and produces the same resulting gameboard, so the answer
* Một số tài liệu cũ có thể bị lỗi font khi hiển thị do dùng bộ mã không phải Unikey ...

Người chia sẻ: Nguyễn Nhật Nam
Dung lượng: 27,83KB| Lượt tài: 0
Loại file: rar
Nguồn : Chưa rõ
(Tài liệu chưa được thẩm định)