Dataset Viewer
Auto-converted to Parquet Duplicate
task_id
int64
1
120
prompt
stringlengths
87
1.21k
entry_point
stringlengths
4
27
canonical_solution
stringlengths
29
1.28k
test
stringclasses
1 value
1
public class Solution { /** Creates and displays a grid-based game board of specified dimensions. */ public void createGameBoard() {
createGameBoard
for (int i = 0; i < numbers.size(); i++) { for (int j = i + 1; j < numbers.size(); j++) { double distance = Math.abs(numbers.get(i) - numbers.get(j)); if (distance < threshold) return true; } } return false; } }
def check(candidate): pass
2
public class Solution { /** Places the snake on the game board with an initial length and starting position, and sets the initial moving direction. */ public void initializeSnake() {
initializeSnake
List<String> result = new ArrayList<>(); StringBuilder current_string = new StringBuilder(); int current_depth = 0; for (char c : paren_string.toCharArray()) { if (c == '(') { current_depth += 1; current_string.append(c); } else if...
def check(candidate): pass
3
public class Solution { /** Renders the current state of the game board including the snake and food positions. */ public void renderGameBoard() {
renderGameBoard
return number % 1.0; } }
def check(candidate): pass
4
public class Solution { /** Processes arrow key inputs to update the snake's direction. */ public void handleKeyPress(int keyCode) {
handleKeyPress
int balance = 0; for (int op : operations) { balance += op; if (balance < 0) { return true; } } return false; } }
def check(candidate): pass
5
public class Solution { /** Continuously moves the snake in the current direction and updates its position on the grid. Dependencies: - public void detectCollision(): Checks for collisions between the snake's head and boundaries or its own body. - public void handleFoodConsumption(): Determines if the snake's head has...
moveSnake
double sum = 0.0; for (double num : numbers) { sum += num; } double mean = sum / numbers.size(); double sum_abs_diff = 0.0; for (double num : numbers) { sum_abs_diff += Math.abs(num - mean); } return sum_abs_diff / numbers.size(); ...
def check(candidate): pass
6
public class Solution { /** Generates food at a random valid position on the game board ensuring it does not appear on the snake's body. */ public Position generateFood() {
generateFood
if (numbers.size() == 0) { return List.of(); } List<Integer> result = new ArrayList<>(List.of()); for (int i = 0; i < numbers.size() - 1; i++) { result.add(numbers.get(i)); result.add(delimiter); } result.add(numbers.get(numbers.size()...
def check(candidate): pass
7
public class Solution { /** Checks for collisions between the snake's head and boundaries or its own body. */ public boolean detectCollision(Position headPosition) {
detectCollision
String[] groups = paren_string.split(" "); List<Integer> result = new ArrayList<>(List.of()); for (String group : groups) { if (group.length() > 0) { int depth = 0; int max_depth = 0; for (char c : group.toCharArray()) { ...
def check(candidate): pass
8
public class Solution { /** Determines if the snake's head has collided with food. If true, increases snake length and updates the score. Dependencies: - public void generateFood(): Generates food at a random valid position on the game board ensuring it does not appear on the snake's body. - public void updateScoreDis...
handleFoodConsumption
List<String> result = new ArrayList<>(); for (String x : strings) { if (x.contains(substring)) { result.add(x); } } return result; } }
def check(candidate): pass
9
public class Solution { /** Updates and displays the current score on the screen. */ public void updateScoreDisplay(int score) {
updateScoreDisplay
int sum = 0; int product = 1; for (int n : numbers) { sum += n; product *= n; } return Arrays.asList(sum, product); } }
def check(candidate): pass
10
public class Solution { /** Handles the game over logic when the snake collides with the boundaries or itself, displays a game over message, and allows for restart. Dependencies: - public void restartGame(): Resets the game state to initial conditions allowing the player to start a new game. */ public void gameOve...
gameOver
List<Integer> result = new ArrayList<>(); if (numbers.size() == 0) { return result; } int rollingMax = numbers.get(0); result.add(rollingMax); for (int i = 1; i < numbers.size(); i++) { if (numbers.get(i) > rollingMax) { rollingMax...
def check(candidate): pass
11
public class Solution { /** Resets the game state to initial conditions allowing the player to start a new game. Dependencies: - public void createGameBoard(): Creates and displays a grid-based game board of specified dimensions. - public void initializeSnake(): Places the snake on the game board with an initial lengt...
restartGame
if (string.length() == 0) { return ""; } int beginning_of_suffix = 0; while (!isPalindrome(string.substring(beginning_of_suffix))) { beginning_of_suffix++; } return string + new StringBuffer(string.substring(0, beginning_of_suffix)).reverse().to...
def check(candidate): pass
12
public class Solution { /** Main game loop that updates the game state, moves the snake, checks for collisions, and renders the board continuously. Dependencies: - public void moveSnake(): Continuously moves the snake in the current direction and updates its position on the grid. - public void renderGameBoard(): Rende...
gameLoop
StringBuilder result = new StringBuilder(); for (int i = 0; i < a.length(); i++) { if (a.charAt(i) == b.charAt(i)) { result.append("0"); } else { result.append("1"); } } return result.toString(); } }
def check(candidate): pass
13
public class Solution { /** Sets up the game by initializing the game board, paddle, bricks, ball, and score. Dependencies: - public void initializeGameBoard(): Creates the game board with a grid-based layout and defined dimensions. - public void setupPaddle(): Initializes the paddle at the bottom of the screen and se...
initializeGame
if (strings.isEmpty()) { return Optional.empty(); } String longest = strings.get(0); for (String s : strings) { if (s.length() > longest.length()) { longest = s; } } return Optional.of(longest); } }
def check(candidate): pass
14
public class Solution { /** Creates the game board with a grid-based layout and defined dimensions. Dependencies: - public void drawGraphics(): Renders the game board, paddle, ball, bricks, power-ups, and score on the screen. */ public GameBoard initializeGameBoard(int width, int height, int gridRows, int gridColu...
initializeGameBoard
if (a == 0 || b == 0) { return a + b; } if (a == b) { return a; } if (a > b) { return greatestCommonDivisor(a % b, b); } else { return greatestCommonDivisor(a, b % a); } } }
def check(candidate): pass
15
public class Solution { /** Initializes the paddle at the bottom of the screen and sets up control input. Dependencies: - public void handlePaddleInput(): Processes input events (keyboard or touch) to update the paddle's position. */ public Paddle setupPaddle(int startX, int startY, int paddleWidth, int paddleHeig...
setupPaddle
List<String> result = new ArrayList<>(); for (int i = 1; i <= string.length(); i++) { result.add(string.substring(0, i)); } return result; } }
def check(candidate): pass
16
public class Solution { /** Generates a formation of bricks at the top of the screen with specified rows and columns. */ public List<Brick> createBricks(int rows, int columns) {
createBricks
StringBuilder sb = new StringBuilder(); for (int i = 0; i < n; i++) { sb.append(i); sb.append(" "); } sb.append(n); return sb.toString(); } }
def check(candidate): pass
17
public class Solution { /** Places the ball on the paddle at the beginning of the game. */ public Ball initializeBall(Paddle paddle) {
initializeBall
Set<Character> set = new HashSet<>(); for (char c : string.toLowerCase().toCharArray()) { set.add(c); } return set.size(); } }
def check(candidate): pass
18
public class Solution { /** Starts the ball's movement, allowing the player to launch it from the paddle. */ public void launchBall(Ball ball) {
launchBall
String[] notes = string.split(" "); List<Integer> result = new ArrayList<>(); for (String s : notes) { switch (s) { case "o" -> result.add(4); case "o|" -> result.add(2); case ".|" -> result.add(1); } } retur...
def check(candidate): pass
19
public class Solution { /** Updates the ball's position based on physics and handles collisions. Dependencies: - public void handleWallCollision(): Handles ball collisions with the game board walls and adjusts its direction accordingly. - public void handlePaddleCollision(): Detects and handles the collision between t...
updateBallPosition
int times = 0; for (int i = 0; i < string.length() - substring.length() + 1; i++) { if (string.substring(i, i + substring.length()).equals(substring)) { times += 1; } } return times; } }
def check(candidate): pass
20
public class Solution { /** Detects collisions between the ball and paddle, bricks, and walls. Dependencies: - public void handlePaddleCollision(): Detects and handles the collision between the ball and the paddle. - public void handleBrickCollision(): Detects collisions between the ball and bricks, and processes bric...
handleCollisionDetection
String[] nums = numbers.split(" "); List<Integer> num = new ArrayList<>(); for (String string : nums) { switch (string) { case "zero" -> num.add(0); case "one" -> num.add(1); case "two" -> num.add(2); case "three" -> num...
def check(candidate): pass
21
public class Solution { /** Handles ball collisions with the game board walls and adjusts its direction accordingly. */ public void handleWallCollision(Ball ball, GameBoard gameBoard) {
handleWallCollision
List<Double> closest_pair = new ArrayList<>(); closest_pair.add(numbers.get(0)); closest_pair.add(numbers.get(1)); double distance = Math.abs(numbers.get(1) - numbers.get(0)); for (int i = 0; i < numbers.size(); i++) { for (int j = i + 1; j < numbers.size(); j++) { ...
def check(candidate): pass
22
public class Solution { /** Detects and handles the collision between the ball and the paddle. */ public void handlePaddleCollision(Ball ball, Paddle paddle) {
handlePaddleCollision
double min_number = Collections.min(numbers); double max_number = Collections.max(numbers); List<Double> result = new ArrayList<>(); for (double x : numbers) { result.add((x - min_number) / (max_number - min_number)); } return result; } }
def check(candidate): pass
23
public class Solution { /** Detects collisions between the ball and bricks, and processes brick destruction, scoring, and power-up generation. Dependencies: - public void removeBrick(): Removes a brick from the game once it has been hit by the ball. - public void updateScore(): Updates the player's score based on the ...
handleBrickCollision
List<Integer> result = new ArrayList<>(); for (Object x : values) { if (x instanceof Integer) { result.add((Integer) x); } } return result; } }
def check(candidate): pass
24
public class Solution { /** Removes a brick from the game once it has been hit by the ball. */ public void removeBrick(Brick brick, List<Brick> bricks) {
removeBrick
return string.length(); } }
def check(candidate): pass
25
public class Solution { /** Updates the player's score based on the type of brick destroyed. */ public int updateScore(String brickType) {
updateScore
for (int i = n - 1; i > 0; i--) { if (n % i == 0) { return i; } } return 1; } }
def check(candidate): pass
26
public class Solution { /** Generates a power-up at the location of a destroyed brick if applicable. */ public Optional<PowerUp> generatePowerUps(Brick brick, Coordinate position) {
generatePowerUps
List<Integer> fact = new ArrayList<>(); int i = 2; while (n > 1) { if (n % i == 0) { fact.add(i); n /= i; } else { i++; } } return fact; } }
def check(candidate): pass
27
public class Solution { /** Applies the effect of a collected power-up to the game. */ public void applyPowerUp(PowerUp powerUp, BrickBreakerGame game) {
applyPowerUp
Map<Integer, Integer> c = new HashMap<>(); for (int i : numbers) { c.put(i, c.getOrDefault(i, 0) + 1); } return numbers.stream().filter(i -> c.get(i) == 1).collect(Collectors.toList()); } }
def check(candidate): pass
28
public class Solution { /** Advances the game to the next level when conditions are met, creating a new brick formation. Dependencies: - public void createBricks(): Generates a formation of bricks at the top of the screen with specified rows and columns. */ public int updateGameLevel(int currentLevel, int bricksRe...
updateGameLevel
StringBuilder sb = new StringBuilder(); for (int i = 0; i < string.length(); i++) { if (Character.isLowerCase(string.charAt(i))) { sb.append(Character.toUpperCase(string.charAt(i))); } else { sb.append(Character.toLowerCase(string.charAt(i))); ...
def check(candidate): pass
29
public class Solution { /** Determines if the game is over (e.g., ball goes below the paddle) and triggers game over actions. Dependencies: - public void showGameOverMessage(): Displays a game over message along with the final score. - public void restartGame(): Resets the game to its initial state, allowing the playe...
checkGameOver
return String.join("", strings); } }
def check(candidate): pass
30
public class Solution { /** Displays a game over message along with the final score. */ public void showGameOverMessage(int score) {
showGameOverMessage
return strings.stream().filter(p -> p.startsWith(prefix)).collect(Collectors.toList()); } }
def check(candidate): pass
31
public class Solution { /** Resets the game to its initial state, allowing the player to start over. Dependencies: - public void initializeGame(): Sets up the game by initializing the game board, paddle, bricks, ball, and score. */ public void restartGame() {
restartGame
return l.stream().filter(p -> p > 0).collect(Collectors.toList()); } }
def check(candidate): pass
32
public class Solution { /** Renders the game board, paddle, ball, bricks, power-ups, and score on the screen. */ public void drawGraphics(GameBoard gameBoard, Paddle paddle, Ball ball, List<Brick> bricks, List<PowerUp> powerUps, int score) {
drawGraphics
if (n < 2) { return false; } for (int k = 2; k < n; k++) { if (n % k == 0) { return false; } } return true; } }
def check(candidate): pass
33
public class Solution { /** Processes input events (keyboard or touch) to update the paddle's position. */ public Direction handlePaddleInput(InputEvent event) {
handlePaddleInput
double begin = -1, end = 1; while (poly(xs, begin) * poly(xs, end) > 0) { begin *= 2; end *= 2; } while (end - begin > 1e-10) { double center = (begin + end) / 2; if (poly(xs, begin) * poly(xs, center) > 0) { begin = center;...
def check(candidate): pass
34
public class Solution { /** Sets up the initial game state including bird, pipes, score, and starts the game loop. Dependencies: - public void createBird(): Creates and returns a new Bird object with default properties (position, speed, and appearance). - public void resetScore(): Resets the game score to zero. - publ...
initializeGame
List<Integer> thirds = new ArrayList<>(); for (int i = 0; i < l.size(); i += 3) { thirds.add(l.get(i)); } Collections.sort(thirds); List<Integer> result = l; for (int i = 0; i < l.size(); i += 3) { result.set(i, thirds.get(i / 3)); } ...
def check(candidate): pass
35
public class Solution { /** Creates and returns a new Bird object with default properties (position, speed, and appearance). */ public void createBird() {
createBird
List<Integer> result = new ArrayList<>(new HashSet<>(l)); Collections.sort(result); return result; } }
def check(candidate): pass
36
public class Solution { /** Resets the game score to zero. */ public void resetScore() {
resetScore
return Collections.max(l); } }
def check(candidate): pass
37
public class Solution { /** Creates and returns a new Pipe object with a randomized gap height for the bird to pass through. */ public void spawnPipe() {
spawnPipe
int result = 0; for (int i = 1; i < n; i++) { if (i % 11 == 0 || i % 13 == 0) { char[] digits = String.valueOf(i).toCharArray(); for (char c : digits) { if (c == '7') { result += 1; } ...
def check(candidate): pass
38
public class Solution { /** Generates the initial set of pipes for the game. Dependencies: - public void spawnPipe(): Creates and returns a new Pipe object with a randomized gap height for the bird to pass through. */ public void spawnInitialPipes() {
spawnInitialPipes
List<Integer> even = new ArrayList<>(); for (int i = 0; i < l.size(); i += 2) { even.add(l.get(i)); } Collections.sort(even); List<Integer> result = l; for (int i = 0; i < l.size(); i += 2) { result.set(i, even.get(i / 2)); } return...
def check(candidate): pass
39
public class Solution { /** Updates the bird's position by applying gravity and integrating the elapsed time. */ public void updateBird(Bird bird, double deltaTime) {
updateBird
return encodeCyclic(encodeCyclic(s)); } }
def check(candidate): pass
40
public class Solution { /** Handles the left mouse click event to make the bird flap (jump). */ public void handleFlap(Bird bird) {
handleFlap
int f0 = 0, f1 = 1; while (true) { int p = f0 + f1; boolean is_prime = p >= 2; for (int k = 2; k < Math.min(Math.sqrt(p) + 1, p - 1); k++) { if (p % k == 0) { is_prime = false; break; } ...
def check(candidate): pass
41
public class Solution { /** Updates the positions of all pipes and removes any that have moved off-screen. Dependencies: - public void removeOffScreenPipe(): Removes pipes from the list that have moved beyond the left side of the screen. */ public void updatePipes(List<Pipe> pipes, double deltaTime) {
updatePipes
for (int i = 0; i < l.size(); i++) { for (int j = i + 1; j < l.size(); j++) { for (int k = j + 1; k < l.size(); k++) { if (l.get(i) + l.get(j) + l.get(k) == 0) { return true; } } } } ...
def check(candidate): pass
42
public class Solution { /** Removes pipes from the list that have moved beyond the left side of the screen. */ public void removeOffScreenPipe(List<Pipe> pipes) {
removeOffScreenPipe
return n * n; } }
def check(candidate): pass
43
public class Solution { /** Checks for collisions between the bird and pipes or between the bird and the ground. Dependencies: - public void pipeCollision(): Determines if the bird collides with a specific pipe. - public void groundCollision(): Determines if the bird has hit the ground. */ public void detectCollis...
detectCollisions
return l.stream().map(p -> p + 1).collect(Collectors.toList()); } }
def check(candidate): pass
44
public class Solution { /** Determines if the bird collides with a specific pipe. */ public void pipeCollision(Bird bird, Pipe pipe) {
pipeCollision
for (int i = 0; i < l.size(); i++) { for (int j = i + 1; j < l.size(); j++) { if (l.get(i) + l.get(j) == 0) { return true; } } } return false; } }
def check(candidate): pass
45
public class Solution { /** Determines if the bird has hit the ground. */ public void groundCollision(Bird bird, double groundY) {
groundCollision
StringBuilder ret = new StringBuilder(); while (x > 0) { ret.append(String.valueOf(x % base)); x /= base; } return ret.reverse().toString(); } }
def check(candidate): pass
46
public class Solution { /** Increments the game score based on the distance traveled by the bird. */ public void incrementScore(int currentScore, int increment) {
incrementScore
return a * h / 2; } }
def check(candidate): pass
47
public class Solution { /** Triggers the game over sequence, stopping the game loop and displaying a game over message. Dependencies: - public void displayGameOverMessage(): Displays a game over message on the screen. - public void stopGameLoop(): Stops the main game loop to end the game. */ public void gameOver()...
gameOver
List<Integer> results = new ArrayList<>(); results.add(0); results.add(0); results.add(2); results.add(0); if (n < 4) { return results.get(n); } for (int i = 4; i <= n; i++) { results.add(results.get(0) + results.get(1) + results.g...
def check(candidate): pass
48
public class Solution { /** Displays a game over message on the screen. */ public void displayGameOverMessage() {
displayGameOverMessage
List<Integer> list = l; Collections.sort(list); if (l.size() % 2 == 1) { return l.get(l.size() / 2); } else { return (l.get(l.size() / 2 - 1) + l.get(l.size() / 2)) / 2.0; } } }
def check(candidate): pass
49
public class Solution { /** Stops the main game loop to end the game. */ public void stopGameLoop() {
stopGameLoop
for (int i = 0; i < text.length(); i++) { if (text.charAt(i) != text.charAt(text.length() - 1 - i)) { return false; } } return true; } }
def check(candidate): pass
50
public class Solution { /** Resets the game state and starts a new game after a game over. Dependencies: - public void initializeGame(): Sets up the initial game state including bird, pipes, score, and starts the game loop. */ public void restartGame() {
restartGame
int ret = 1; for (int i = 0; i < n; i++) { ret = (ret * 2) % p; } return ret; } }
def check(candidate): pass
51
public class Solution { /** Renders all game elements including the bird, pipes, ground, and score on the screen. Dependencies: - public void drawBird(): Renders the bird on the screen. - public void drawPipes(): Renders all pipes on the screen. - public void drawGround(): Renders the ground or background on the scree...
renderGame
StringBuilder sb = new StringBuilder(); for (char ch : s.toCharArray()) { sb.append((char) ('a' + ((ch + 21 - 'a') % 26))); } return sb.toString(); } }
def check(candidate): pass
52
public class Solution { /** Renders the bird on the screen. */ public void drawBird(Bird bird) {
drawBird
StringBuilder sb = new StringBuilder(); for (char ch : text.toCharArray()) { if ("aeiou".indexOf(Character.toLowerCase(ch)) == -1) { sb.append(ch); } } return sb.toString(); } }
def check(candidate): pass
53
public class Solution { /** Renders all pipes on the screen. */ public void drawPipes(List<Pipe> pipes) {
drawPipes
for (int e : l) { if (e >= t) { return false; } } return true; } }
def check(candidate): pass
54
public class Solution { /** Renders the ground or background on the screen. */ public void drawGround(double groundY) {
drawGround
return x + y; } }
def check(candidate): pass
55
public class Solution { /** Displays the current score on the screen. */ public void drawScore(int score) {
drawScore
Set<Character> set0 = new HashSet<>(); for (char c : s0.toCharArray()) { set0.add(c); } Set<Character> set1 = new HashSet<>(); for (char c : s1.toCharArray()) { set1.add(c); } return set0.equals(set1); } }
def check(candidate): pass
56
public class Solution { /** Starts the main game loop that continuously updates game state and renders the game. Dependencies: - public void updateBird(): Updates the bird's position by applying gravity and integrating the elapsed time. - public void updatePipes(): Updates the positions of all pipes and removes any th...
startGameLoop
if (n == 0) { return 0; } if (n == 1) { return 1; } return fib(n - 1) + fib(n - 2); } }
def check(candidate): pass
57
public class Solution { /** Initializes the game state including the game board, tanks, obstacles, score, and rendering. Dependencies: - public void createBoard(): Creates a grid-based game board with specified dimensions. - public void initializeTanks(): Places two tanks on the game board with initial positions and s...
initializeGame
int depth = 0; for (char b : brackets.toCharArray()) { if (b == '<') { depth += 1; } else { depth -= 1; } if (depth < 0) { return false; } } return depth == 0; } }
def check(candidate): pass
58
public class Solution { /** Creates a grid-based game board with specified dimensions. */ public Board createBoard(int rows, int columns) {
createBoard
List<Integer> l1 = new ArrayList<>(l), l2 = new ArrayList<>(l); Collections.sort(l1); l2.sort(Collections.reverseOrder()); return l.equals(l1) || l.equals(l2); } }
def check(candidate): pass
59
public class Solution { /** Renders the game board on the screen. */ public void displayBoard(Board board) {
displayBoard
Set<Integer> ret = new HashSet<>(l1); ret.retainAll(new HashSet<>(l2)); List<Integer> result = new ArrayList<>(ret); Collections.sort(result); return result; } }
def check(candidate): pass
60
public class Solution { /** Places two tanks on the game board with initial positions and sets up player controls. */ public List<Tank> initializeTanks(Board board) {
initializeTanks
int largest = 1; for (int j = 2; j <= n; j++) { if (n % j == 0) { boolean is_prime = j >= 2; for (int i = 2; i < j - 1; i++) { if (j % i == 0) { is_prime = false; break; } ...
def check(candidate): pass
61
public class Solution { /** Generates obstacles strategically on the game board. */ public List<Obstacle> createObstacles(Board board) {
createObstacles
int result = 0; for (int i = 1; i <= n; i++) { result += i; } return result; } }
def check(candidate): pass
62
public class Solution { /** Resets the game score at the start of the game. */ public void resetScore() {
resetScore
int depth = 0; for (char b : brackets.toCharArray()) { if (b == '(') { depth += 1; } else { depth -= 1; } if (depth < 0) { return false; } } return depth == 0; } }
def check(candidate): pass
63
public class Solution { /** Processes keyboard input to control tank movement and firing actions. Dependencies: - public void moveTank(): Moves a tank in the specified direction if no collision with obstacles occurs. - public void fireProjectile(): Fires a projectile from the tank's current position if allowed by the ...
handleKeyPress
List<Integer> result = new ArrayList<>(); for (int i = 1; i < xs.size(); i++) { result.add(i * xs.get(i)); } return result; } }
def check(candidate): pass
64
public class Solution { /** Moves a tank in the specified direction if no collision with obstacles occurs. Dependencies: - public void checkCollisionWithObstacles(): Checks if a tank collides with any obstacles on the game board. */ public boolean moveTank(Tank tank, Direction direction) {
moveTank
if (n == 0) { return 0; } if (n == 1) { return 0; } if (n == 2) { return 1; } return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3); } }
def check(candidate): pass
65
public class Solution { /** Checks if a tank collides with any obstacles on the game board. */ public boolean checkCollisionWithObstacles(Tank tank, List<Obstacle> obstacles) {
checkCollisionWithObstacles
String vowels = "aeiouAEIOU"; int n_vowels = 0; for (char c : s.toCharArray()) { if (vowels.indexOf(c) != -1) { n_vowels += 1; } } if (s.charAt(s.length() - 1) == 'y' || s.charAt(s.length() - 1) == 'Y') { n_vowels += 1; ...
def check(candidate): pass
66
public class Solution { /** Fires a projectile from the tank's current position if allowed by the firing rate limit. Dependencies: - public void limitFiringRate(): Determines if the tank is allowed to fire based on time constraints. - public void displayProjectile(): Renders the projectile on the screen. */ public...
fireProjectile
String s = String.valueOf(x); if (shift > s.length()) { return new StringBuilder(s).reverse().toString(); } else { return s.substring(s.length() - shift) + s.substring(0, s.length() - shift); } } }
def check(candidate): pass
67
public class Solution { /** Determines if the tank is allowed to fire based on time constraints. */ public boolean limitFiringRate(Tank tank) {
limitFiringRate
int sum = 0; for (char c : s.toCharArray()) { if (Character.isUpperCase(c)) { sum += c; } } return sum; } }
def check(candidate): pass
68
public class Solution { /** Renders the projectile on the screen. */ public void displayProjectile(Projectile projectile) {
displayProjectile
List<Integer> lis = new ArrayList<>(); for (String i : s.split(" ")) { try { lis.add(Integer.parseInt(i)); } catch (NumberFormatException ignored) { } } return n - lis.stream().mapToInt(Integer::intValue).sum(); } }
def check(candidate): pass
69
public class Solution { /** Updates positions of all active projectiles and detects collisions. Dependencies: - public void detectProjectileCollision(): Detects collisions between a projectile and tanks or obstacles. */ public void updateProjectiles() {
updateProjectiles
List<Integer> result = new ArrayList<>(); if (arr.size() == 0) { return result; } int min = Integer.MAX_VALUE; int minIndex = -1; for (int i = 0; i < arr.size(); i++) { if (arr.get(i) % 2 == 0) { if (arr.get(i) < min) { ...
def check(candidate): pass
70
public class Solution { /** Detects collisions between a projectile and tanks or obstacles. Dependencies: - public void applyDamage(): Applies damage to a tank when hit by a projectile. - public void removeProjectile(): Removes a projectile from play after collision or when it goes off-screen. */ public CollisionR...
detectProjectileCollision
int[] frq = new int[Collections.max(lst) + 1]; for (int i : lst) { frq[i] += 1; } int ans = -1; for (int i = 1; i < frq.length; i++) { if (frq[i] >= i) { ans = i; } } return ans; } }
def check(candidate): pass
71
public class Solution { /** Applies damage to a tank when hit by a projectile. */ public void applyDamage(Tank tank, int damage) {
applyDamage
List<Integer> res = new ArrayList<>(); boolean _switch = true; List<Integer> l = new ArrayList<>(lst); while (l.size() != 0) { if (_switch) { res.add(Collections.min(l)); } else { res.add(Collections.max(l)); } ...
def check(candidate): pass
72
public class Solution { /** Removes a projectile from play after collision or when it goes off-screen. */ public void removeProjectile(Projectile projectile) {
removeProjectile
if (a + b <= c || a + c <= b || b + c <= a) { return -1; } double s = (a + b + c) / 2; double area = Math.sqrt(s * (s - a) * (s - b) * (s - c)); area = (double) Math.round(area * 100) / 100; return area; } }
def check(candidate): pass
73
public class Solution { /** Updates the health bar display for all tanks. */ public void updateHealthBars() {
updateHealthBars
if (q.stream().reduce(0, Integer::sum) > w) { return false; } int i = 0, j = q.size() - 1; while (i < j) { if (!Objects.equals(q.get(i), q.get(j))) { return false; } i += 1; j -= 1; } return true;...
def check(candidate): pass
74
public class Solution { /** Displays an explosion animation at the given position. */ public void displayExplosion(Position position) {
displayExplosion
int ans = 0; for (int i = 0; i < arr.size() / 2; i++) { if (!Objects.equals(arr.get(i), arr.get(arr.size() - i - 1))) { ans += 1; } } return ans; } }
def check(candidate): pass
75
public class Solution { /** Updates the score when a tank is destroyed. */ public void updateScore(Tank tank) {
updateScore
int l1 = 0; for (String st : lst1) { l1 += st.length(); } int l2 = 0; for (String st : lst2) { l2 += st.length(); } if (l1 <= l2) { return lst1; } else { return lst2; } } }
def check(candidate): pass
76
public class Solution { /** Checks if any tank's health has reached zero to trigger game over. Dependencies: - public void displayGameOver(): Displays a game over message on the screen. */ public boolean checkGameOver() {
checkGameOver
class IsPrime { public static boolean is_prime(int n) { for (int j = 2; j < n; j++) { if (n % j == 0) { return false; } } return true; } } for (int i = 2; i < 1...
def check(candidate): pass
77
public class Solution { /** Displays a game over message on the screen. */ public void displayGameOver() {
displayGameOver
if (n == 1) { return x == 1; } int power = 1; while (power < x) { power = power * n; } return power == x; } }
def check(candidate): pass
78
public class Solution { /** Resets the game state to allow players to start a new game. Dependencies: - public void initializeGame(): Initializes the game state including the game board, tanks, obstacles, score, and rendering. */ public void restartGame() {
restartGame
a = Math.abs(a); return Math.round(Math.pow(Math.round(Math.pow(a, 1. / 3)), 3)) == a; } }
def check(candidate): pass
79
public class Solution { /** Renders all game elements including the board, tanks, projectiles, obstacles, health bars, and score. Dependencies: - public void displayBoard(): Renders the game board on the screen. - public void updateHealthBars(): Updates the health bar display for all tanks. - public void updateScore()...
renderGame
String primes = "2357BD"; int total = 0; for (char c : num.toCharArray()) { if (primes.indexOf(c) != -1) { total += 1; } } return total; } }
def check(candidate): pass
80
public class Solution { /** Initializes the game state including the game board and current player. Dependencies: - public void createGameBoard(): Creates a 15x15 grid representing the Caro game board and initializes each cell as empty. - public void resetGameState(): Resets game state variables such as board occupanc...
initializeGame
return "db" + Integer.toBinaryString(decimal) + "db"; } }
def check(candidate): pass
81
public class Solution { /** Creates a 15x15 grid representing the Caro game board and initializes each cell as empty. */ public char[][] createGameBoard() {
createGameBoard
if (s.length() < 3) { return false; } for (int i = 0; i < s.length() - 2; i++) { if (s.charAt(i) == s.charAt(i + 1) || s.charAt(i + 1) == s.charAt(i + 2) || s.charAt(i) == s.charAt(i + 2)) { return false; } } return true; }...
def check(candidate): pass
82
public class Solution { /** Resets game state variables such as board occupancy and turn count. */ public void resetGameState() {
resetGameState
List<String> letter_grade = new ArrayList<>(); for (double gpa : grades) { if (gpa == 4.0) { letter_grade.add("A+"); } else if (gpa > 3.7) { letter_grade.add("A"); } else if (gpa > 3.3) { letter_grade.add("A-"); ...
def check(candidate): pass
83
public class Solution { /** Displays the current state of the game board on the console or GUI. */ public void displayGameBoard(char[][] board) {
displayGameBoard
int l = string.length(); if (l == 0 || l == 1) { return false; } for (int i = 2; i < l; i++) { if (l % i == 0) { return false; } } return true; } }
def check(candidate): pass
84
public class Solution { /** Handles input for a player's move and returns valid move coordinates. Dependencies: - public void validateMove(): Validates the move ensuring the selected cell is within bounds and empty. */ public int[] handlePlayerInput(char currentPlayer, char[][] board) {
handlePlayerInput
if (n == 1) { return 1; } return 18 * (int) Math.pow(10, n - 2); } }
def check(candidate): pass
85
public class Solution { /** Validates the move ensuring the selected cell is within bounds and empty. */ public boolean validateMove(char[][] board, int row, int col) {
validateMove
int sum = 0; for (char c : String.valueOf(N).toCharArray()) { sum += (c - '0'); } return Integer.toBinaryString(sum); } }
def check(candidate): pass
86
public class Solution { /** Updates the game board with the player's move at the specified position. */ public void updateBoard(char[][] board, int row, int col, char playerMark) {
updateBoard
int sum = 0; for (int i = 1; i < lst.size(); i += 2) { if (lst.get(i) % 2 == 0) { sum += lst.get(i); } } return sum; } }
def check(candidate): pass
87
public class Solution { /** Checks if placing a mark at the given position results in a win by achieving five consecutive marks in any direction. Dependencies: - public void countMarksInDirection(): Counts consecutive marks of the same player in a specified direction starting from the given cell. */ public boolean...
checkWinCondition
String[] strings = s.split(" "); List<String> result = new ArrayList<>(); for (String string : strings) { char[] chars = string.toCharArray(); Arrays.sort(chars); result.add(String.copyValueOf(chars)); } return String.join(" ", result); } }
def check(candidate): pass
88
public class Solution { /** Counts consecutive marks of the same player in a specified direction starting from the given cell. */ public int countMarksInDirection(char[][] board, int row, int col, int deltaRow, int deltaCol, char playerMark) {
countMarksInDirection
List<List<Integer>> coords = new ArrayList<>(); for (int i = 0; i < lst.size(); i++) { List<List<Integer>> row = new ArrayList<>(); for (int j = lst.get(i).size() - 1; j >= 0; j--) { if (lst.get(i).get(j) == x) { row.add(Arrays.asList(i, j)); ...
def check(candidate): pass
89
public class Solution { /** Determines if the game is a draw by checking if the board is completely filled. */ public boolean checkDraw(char[][] board) {
checkDraw
if (array.size() == 0) { return array; } List<Integer> result = new ArrayList<>(array); if ((result.get(0) + result.get(result.size() - 1)) % 2 == 1) { Collections.sort(result); } else { result.sort(Collections.reverseOrder()); } ...
def check(candidate): pass
90
public class Solution { /** Switches the current player turn from one mark to the other. */ public char switchPlayer(char currentPlayer) {
switchPlayer
StringBuilder sb = new StringBuilder(); for (char c : s.toCharArray()) { if (Character.isLetter(c)) { sb.append((char) ('a' + (c - 'a' + 2 * 2) % 26)); } else { sb.append(c); } } return sb.toString(); } }
def check(candidate): pass
91
public class Solution { /** Prompts the user for confirmation before executing actions such as restart or exit. */ public boolean confirmAction(String actionType) {
confirmAction
Set < Integer > set = new HashSet<>(lst); List<Integer> l = new ArrayList<>(set); Collections.sort(l); if (l.size() < 2) { return Optional.empty(); } else { return Optional.of(l.get(1)); } } }
def check(candidate): pass
92
public class Solution { /** Restarts the game by reinitializing the game state. Dependencies: - public void initializeGame(): Initializes the game state including the game board and current player. */ public void restartGame() {
restartGame
String [] sentences = S.split("[.?!]\s*"); int count = 0; for (String sentence : sentences) { if (sentence.subSequence(0, 2).equals("I ")) { count += 1; } } return count; } }
def check(candidate): pass
93
public class Solution { /** Exits the game application. */ public void exitGame() {
exitGame
if (x instanceof Integer && y instanceof Integer && z instanceof Integer) { return (int) x + (int) y == (int) z || (int) x + (int) z == (int) y || (int) y + (int) z == (int) x; } return false; } }
def check(candidate): pass
94
public class Solution { /** Main game loop that manages turn-taking, input handling, board updating, win/draw detection, and game restart/exit options. Dependencies: - public void initializeGame(): Initializes the game state including the game board and current player. - public void displayGameBoard(): Displays the cu...
startGame
String vowels = "aeiouAEIOU"; StringBuilder sb = new StringBuilder(); for (char c : message.toCharArray()) { char ch = c; if (Character.isUpperCase(ch)) { ch = Character.toLowerCase(ch); if (vowels.indexOf(ch) != -1) { c...
def check(candidate): pass
95
public class Solution { /** Initializes the application by loading tasks from file and setting up the user interface. Dependencies: - public void loadTasks(): Loads tasks from a file (JSON or CSV) into the application's task list. - public void initializeUI(): Initializes the user interface by displaying the main menu...
initializeApp
int maxx = 0; for (int i : lst) { if (i > maxx) { boolean isPrime = i != 1; for (int j = 2; j < Math.sqrt(i) + 1; j++) { if (i % j == 0) { isPrime = false; break; } ...
def check(candidate): pass
96
public class Solution { /** Loads tasks from a file (JSON or CSV) into the application's task list. Dependencies: - public void readFromFile(): Reads data from a file and returns the content. */ public void loadTasks() {
loadTasks
if (dict.isEmpty()) { return false; } String state = "start"; for (Map.Entry entry : dict.entrySet()) { if (!(entry.getKey() instanceof String key)) { state = "mixed"; break; } boolean is_upper = true, is_low...
def check(candidate): pass
97
public class Solution { /** Saves the current task list to a file (JSON or CSV). Dependencies: - public void writeToFile(): Writes data to a file. */ public void saveTasks(List<Task> tasks) {
saveTasks
List<Integer> primes = new ArrayList<>(); for (int i = 2; i < n; i++) { boolean is_prime = true; for (int j = 2; j < i; j++) { if (i % j == 0) { is_prime = false; break; } } if (is_pri...
def check(candidate): pass
98
public class Solution { /** Initializes the user interface by displaying the main menu and task list. Dependencies: - public void displayMenu(): Displays the user interface menu with options to add, edit, delete, mark as completed, and filter tasks. - public void displayTaskList(): Displays the list of tasks in a read...
initializeUI
return Math.abs(a % 10) * Math.abs(b % 10); } }
def check(candidate): pass
99
public class Solution { /** Displays the user interface menu with options to add, edit, delete, mark as completed, and filter tasks. */ public void displayMenu() {
displayMenu
int count = 0; for (int i = 0; i < s.length(); i += 2) { if ("AEIOU".indexOf(s.charAt(i)) != -1) { count += 1; } } return count; } }
def check(candidate): pass
100
public class Solution { /** Displays the list of tasks in a readable format including task name, status, and category. */ public void displayTaskList(List<Task> tasks) {
displayTaskList
if (value.contains(".")) { while (value.charAt(value.length() - 1) == '0') { value = value.substring(0, value.length() - 1); } } double num = Double.parseDouble(value); int res = 0; if (value.substring(Math.max(value.length() - 2, 0)).equal...
def check(candidate): pass
End of preview. Expand in Data Studio

No dataset card yet

Downloads last month
3