Skip to content

Commit d42b438

Browse files
refactor 353
1 parent 75c7499 commit d42b438

File tree

1 file changed

+0
-48
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+0
-48
lines changed

src/main/java/com/fishercoder/solutions/_353.java

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -5,54 +5,6 @@
55
import java.util.LinkedList;
66
import java.util.Set;
77

8-
/**
9-
* Design a Snake game that is played on a device with screen size = width x height. Play the game online if you are not familiar with the game.
10-
* <p>
11-
* The snake is initially positioned at the top left corner (0,0) with length = 1 unit.
12-
* <p>
13-
* You are given a list of food's positions in row-column order. When a snake eats the food, its length and the game's score both increase by 1.
14-
* <p>
15-
* Each food appears one by one on the screen. For example, the second food will not appear until the first food was eaten by the snake.
16-
* <p>
17-
* When a food does appear on the screen, it is guaranteed that it will not appear on a block occupied by the snake.
18-
* <p>
19-
* Example:
20-
* Given width = 3, height = 2, and food = [[1,2],[0,1]].
21-
* <p>
22-
* Snake snake = new Snake(width, height, food);
23-
* <p>
24-
* Initially the snake appears at position (0,0) and the food at (1,2).
25-
* <p>
26-
* |S| | |
27-
* | | |F|
28-
* <p>
29-
* snake.move("R"); -> Returns 0
30-
* <p>
31-
* | |S| |
32-
* | | |F|
33-
* <p>
34-
* snake.move("D"); -> Returns 0
35-
* <p>
36-
* | | | |
37-
* | |S|F|
38-
* <p>
39-
* snake.move("R"); -> Returns 1 (Snake eats the first food and right after that, the second food appears at (0,1) )
40-
* <p>
41-
* | |F| |
42-
* | |S|S|
43-
* <p>
44-
* snake.move("U"); -> Returns 1
45-
* <p>
46-
* | |F|S|
47-
* | | |S|
48-
* <p>
49-
* snake.move("L"); -> Returns 2 (Snake eats the second food)
50-
* <p>
51-
* | |S|S|
52-
* | | |S|
53-
* <p>
54-
* snake.move("U"); -> Returns -1 (Game over because snake collides with border)
55-
*/
568
public class _353 {
579
public class SnakeGame {
5810
private Set<Integer> set;//Use a set to hold all occupied points for the snake body, this is for easy access for the case of eating its own body

0 commit comments

Comments
 (0)