Remove duplicate Queue elements

This commit is contained in:
Your Average Code 2024-01-25 01:30:27 +01:00
parent 8fafea3cdf
commit 7e5d807862
3 changed files with 0 additions and 15 deletions

View File

@ -78,11 +78,6 @@ public class EscapeBot extends Bot {
queue.add(new Move(start + directions[i][0], start + directions[i][1], commands[i])); queue.add(new Move(start + directions[i][0], start + directions[i][1], commands[i]));
} }
queue.add(new Move(start, start - 1, '^'));
queue.add(new Move(start, start + 1, '>'));
queue.add(new Move(start + 1, start, '>'));
queue.add(new Move(start - 1, start, '<'));
while (!queue.isEmpty()) { while (!queue.isEmpty()) {
Move move = queue.poll(); Move move = queue.poll();
if (move.x < 0 || move.x >= size || move.y < 0 || move.y >= size || visited[move.x][move.y]) continue; if (move.x < 0 || move.x >= size || move.y < 0 || move.y >= size || visited[move.x][move.y]) continue;

View File

@ -96,11 +96,6 @@ public class RumbleBot extends Bot {
queue.add(new Move(start + directions[i][0], start + directions[i][1], commands[i])); queue.add(new Move(start + directions[i][0], start + directions[i][1], commands[i]));
} }
queue.add(new Move(start, start - 1, '^'));
queue.add(new Move(start, start + 1, '>'));
queue.add(new Move(start + 1, start, '>'));
queue.add(new Move(start - 1, start, '<'));
while (!queue.isEmpty()) { while (!queue.isEmpty()) {
Move move = queue.poll(); Move move = queue.poll();
if (move.x < 0 || move.x >= size || move.y < 0 || move.y >= size || visited[move.x][move.y]) continue; if (move.x < 0 || move.x >= size || move.y < 0 || move.y >= size || visited[move.x][move.y]) continue;

View File

@ -99,11 +99,6 @@ public class SnakeBot extends Bot {
queue.add(new Move(start + directions[i][0], start + directions[i][1], commands[i])); queue.add(new Move(start + directions[i][0], start + directions[i][1], commands[i]));
} }
queue.add(new Move(start, start - 1, '^'));
queue.add(new Move(start, start + 1, '>'));
queue.add(new Move(start + 1, start, '>'));
queue.add(new Move(start - 1, start, '<'));
while (!queue.isEmpty()) { while (!queue.isEmpty()) {
Move move = queue.poll(); Move move = queue.poll();
if (move.x < 0 || move.x >= size || move.y < 0 || move.y >= size || visited[move.x][move.y]) continue; if (move.x < 0 || move.x >= size || move.y < 0 || move.y >= size || visited[move.x][move.y]) continue;