qid
stringlengths
2
6
ground_truth_solution
stringlengths
249
4.55k
ground_truth_diagram_description
stringlengths
759
3.88k
test_script
stringlengths
839
9.64k
function_signature
stringlengths
218
1.05k
diagram
imagewidth (px)
596
1.02k
capability_aspects
dict
task_type
stringclasses
6 values
q1
def solution(red_triangle: tuple, orange_dots: list) -> int: """ Determine the number of iterations required to absorb all the orange dots. Parameters: red_triangle (tuple): The coordinates of the red triangle (x0, y0). orange_dots (list): A list of tuples, where each tuple represents the coordinat...
# Problem Description This is a geometric transformation problem on a grid where we need to simulate the absorption of orange dots by purple lines emanating from a red triangle. The goal is to calculate the minimum number of iterations needed to convert all orange dots into purple dots, following specific geometric rul...
def test(): test_cases = [ ((2, 2), [(2, 4)], 1), ((3, 0), [(3, 1), (3, 2), (3, 3)], 1), ((0, 3), [(1, 3), (2, 3), (4, 3)], 1), ((2, 2), [(1, 1), (0, 0), (3, 3)], 1), ((2, 2), [(0, 2), (2, 4), (4, 4), (2, 0)], 3), ((2, 2), [], 0), ((0, 0), [(1, 1), (2, 2), (3,...
def solution(red_triangle: tuple, orange_dots: list) -> int: """ Determine the number of iterations required to absorb all the orange dots. Parameters: red_triangle (tuple): The coordinates of the red triangle (x0, y0). orange_dots (list): A list of tuples, where each tuple represents the coordinat...
{ "Common Sense": null, "Data Structures": [ "Matrix" ], "Dynamic Patterns": [ "Propagation" ], "Geometric Objects": [ "Coordinate System", "Point", "Line", "Grid", "Triangle" ], "Mathematical Operations": null, "Spatial Transformations": null, "Topological Relations": [ ...
Iterative Calculation
q1-2
def solution(red_triangle: tuple, orange_dots: list) -> int: """ Determine the number of iterations required to absorb all the orange dots. Parameters: red_triangle (tuple): The coordinates of the red triangle (x0, y0). orange_dots (list): A list of tuples, where each tuple represents the coordinat...
# Problem Description This problem involves a grid-based transformation where we need to simulate the absorption of orange dots by purple lines emanating from a red triangle. The goal is to calculate the minimum number of iterations required to convert all orange dots into purple dots, following specific geometric rule...
def test(): test_cases = [ ((2, 2), [(2, 4)], 1), ((3, 0), [(3, 1), (3, 2), (3, 3)], 1), ((0, 3), [(1, 3), (2, 3), (4, 3)], 1), ((3, 1), [(3, 0), (3, 2), (3, 3)], 2), ((2, 3), [(1, 3), (0, 3), (4, 3)], 2), ((2, 2), [(1, 1), (0, 0), (3, 3)], 2), ((2, 2), [(0, 2...
def solution(red_triangle: tuple, orange_dots: list) -> int: """ Determine the number of iterations required to absorb all the orange dots. Parameters: red_triangle (tuple): The coordinates of the red triangle (x0, y0). orange_dots (list): A list of tuples, where each tuple represents the coordinat...
{ "Common Sense": null, "Data Structures": [ "Matrix" ], "Dynamic Patterns": [ "Propagation" ], "Geometric Objects": [ "Coordinate System", "Point", "Line", "Grid", "Triangle" ], "Mathematical Operations": null, "Spatial Transformations": null, "Topological Relations": [ ...
Iterative Calculation
q1-3
def solution(red_triangle: tuple, orange_dots: list) -> int: """ Determine the number of iterations required to absorb all the orange dots. Parameters: red_triangle (tuple): The coordinates of the red triangle (x0, y0). orange_dots (list): A list of tuples, where each tuple represents the coordinat...
# Problem Description This problem involves a grid where a red triangle and several orange dots are placed. The goal is to determine the number of iterations required to convert all orange dots into purple dots. Each iteration involves drawing a line through the red triangle, and any orange dot that lies on this line i...
def test(): test_cases = [ ((2, 2), [(2, 4)], 2), ((3, 0), [(3, 1), (3, 2), (3, 3)], 2), ((0, 3), [(1, 3), (2, 3), (4, 3)], 2), ((2, 2), [(1, 1), (0, 0), (3, 3)], 2), ((2, 2), [(0, 2), (2, 4), (4, 4), (2, 0)], 6), ((2, 2), [], 0), ((0, 0), [(1, 1), (2, 2), (3...
def solution(red_triangle: tuple, orange_dots: list) -> int: """ Determine the number of iterations required to absorb all the orange dots. Parameters: red_triangle (tuple): The coordinates of the red triangle (x0, y0). orange_dots (list): A list of tuples, where each tuple represents the coordinat...
{ "Common Sense": null, "Data Structures": [ "Matrix" ], "Dynamic Patterns": [ "Propagation" ], "Geometric Objects": [ "Coordinate System", "Point", "Line", "Grid", "Triangle" ], "Mathematical Operations": null, "Spatial Transformations": null, "Topological Relations": [ ...
Iterative Calculation
q10
from typing import List def solution(n: int) -> List[List[int]]: """ Given an n x n grid, determine the coordinates of a specific pattern that is formed on the grid. Parameters: n (int): The dimensions of the grid (which is an n*n 2D matrix). n is always an odd number. Returns: ...
# Problem Description This is a grid pattern generation problem where we need to: - Create an n×n grid (where n is always odd) - Place black cells (represented as 1) in specific positions - Fill remaining cells with white (represented as 0) - Return the resulting grid as a 2D matrix - The pattern follows a specific rul...
def reference(n): grid = [[0 for _ in range(n)] for _ in range(n)] # Middle index mid = n // 2 # Set the center grid[mid][mid] = 1 # Set the diagonals for i in range(mid + 1): if (i-mid) % 2 == 1: continue grid[i][i] = 1 grid[i][n-1-i] = 1 ...
from typing import List def solution(n: int) -> List[List[int]]: """ Given an n x n grid, determine the coordinates of a specific pattern that is formed on the grid. Parameters: n (int): The dimensions of the grid (which is an n*n 2D matrix). n is always an odd number. Returns: ...
{ "Common Sense": null, "Data Structures": [ "Matrix" ], "Dynamic Patterns": [ "Concentric Arrangement", "Cross Pattern" ], "Geometric Objects": [ "Square", "Grid" ], "Mathematical Operations": null, "Spatial Transformations": [ "Scaling" ], "Topological Relations": [ "...
Expansion
q10-2
from typing import List def solution(n: int) -> List[List[int]]: """ Given an n x n grid, determine the coordinates of a specific pattern that is formed on the grid. Parameters: n (int): The dimensions of the grid (which is an n*n 2D matrix). n is always an odd number. Returns: ...
# Problem Description This is a grid pattern generation problem where we need to: - Create an n×n grid (where n is always odd) - Place black cells (represented as 1) in specific positions - Fill remaining cells with white (represented as 0) - Return the resulting grid as a 2D matrix - The pattern follows a specific rul...
def reference(n): grid = [[0 for _ in range(n)] for _ in range(n)] # Middle index mid = n // 2 # Set the center grid[mid][mid] = 1 # Set the diagonals for i in range(mid + 1): if (i-mid) % 2 == 1: continue grid[i][mid] = 1 grid[mid][i] = 1 ...
from typing import List def solution(n: int) -> List[List[int]]: """ Given an n x n grid, determine the coordinates of a specific pattern that is formed on the grid. Parameters: n (int): The dimensions of the grid (which is an n*n 2D matrix). n is always an odd number. Returns: ...
{ "Common Sense": null, "Data Structures": [ "Matrix" ], "Dynamic Patterns": [ "Concentric Arrangement", "Cross Pattern" ], "Geometric Objects": [ "Square", "Grid" ], "Mathematical Operations": null, "Spatial Transformations": [ "Scaling" ], "Topological Relations": [ "...
Expansion
q10-3
from typing import List def solution(n: int) -> List[List[int]]: """ Given an n x n grid, determine the coordinates of a specific pattern that is formed on the grid. Parameters: n (int): The dimensions of the grid (which is an n*n 2D matrix). n is always an odd number. Returns: ...
# Problem Description This is a grid pattern generation problem where we need to: - Create an n×n grid (where n is always odd) - Place black cells (represented as 1) in specific positions - Fill remaining cells with white (represented as 0) - Return the resulting grid as a 2D matrix - The pattern follows a specific rul...
def reference(n): grid = [[0 for _ in range(n)] for _ in range(n)] # Middle index mid = n // 2 # Set the center grid[mid][mid] = 0 # Set the diagonals for i in range(mid + 1): if (i-mid) % 2 == 0: continue grid[i][i] = 1 grid[i][n - 1 - i] =...
from typing import List def solution(n: int) -> List[List[int]]: """ Given an n x n grid, determine the coordinates of a specific pattern that is formed on the grid. Parameters: n (int): The dimensions of the grid (which is an n*n 2D matrix). n is always an odd number. Returns: ...
{ "Common Sense": null, "Data Structures": [ "Matrix" ], "Dynamic Patterns": [ "Concentric Arrangement", "Cross Pattern" ], "Geometric Objects": [ "Square", "Grid" ], "Mathematical Operations": null, "Spatial Transformations": [ "Scaling" ], "Topological Relations": [ "...
Expansion
q100
from typing import Tuple import math def solution(coordinate: Tuple[int, int]) -> int: """ Determines the color of the zone at the given coordinate. The colors follow an infinitely repeating pattern. Args: coordinate: A tuple (x, y) representing the coordinate point Returns: 0 for...
# Problem Description This is a coordinate-based zone coloring problem where we need to determine the color of a point given its (x,y) coordinates. The plane is divided into alternating black and white circular rings, with special rules for different quadrants. The coloring pattern depends on: 1. The distance from the ...
def test(): test_cases = [ ((0.5, 0.5), 1), ((0.5, -0.5),0), ((3, 2), 0), ((-1, 1), 1), ((5, -3), 1), ((5, -4), 0), ((2, 2), 1), ((4, 3), 3), ((7, 7), 0), ((23009853, 23009853), 1), ((-23009853, -23009853), 1), ((99238...
from typing import Tuple import math def solution(coordinate: Tuple[int, int]) -> int: """ Determines the color of the zone at the given coordinate. The colors follow an infinitely repeating pattern. Args: coordinate: A tuple (x, y) representing the coordinate point Returns: 0 for...
{ "Common Sense": null, "Data Structures": null, "Dynamic Patterns": [ "Alternation", "Concentric Arrangement" ], "Geometric Objects": [ "Point", "Circle", "Distance", "Radius", "Coordinate System" ], "Mathematical Operations": [ "Value Comparison" ], "Spatial Transform...
Validation
q100-2
from typing import Tuple import math def solution(coordinate: Tuple[int, int]) -> int: """ Determines the color of the zone at the given coordinate. The colors follow an infinitely repeating pattern. Args: coordinate: A tuple (x, y) representing the coordinate point Returns: 0 for...
# Problem Description This is a coordinate-based zone coloring problem where we need to determine the color of a point given its (x,y) coordinates. The plane is divided into alternating black and white circular rings, with special rules for different quadrants. The coloring pattern depends on: 1. The distance from the ...
def test(): test_cases = [ ((0.5, 0.5), 0), ((0.5, -0.5),1), ((3, 2), 1), ((-1, 1), 0), ((5, -3), 0), ((5, -4), 1), ((2, 2), 0), ((4, 3), 3), ((7, 7), 1), ((23009853, 23009853), 0), ((-23009853, -23009853), 0), ((99238...
from typing import Tuple import math def solution(coordinate: Tuple[int, int]) -> int: """ Determines the color of the zone at the given coordinate. The colors follow an infinitely repeating pattern. Args: coordinate: A tuple (x, y) representing the coordinate point Returns: 0 for...
{ "Common Sense": null, "Data Structures": null, "Dynamic Patterns": [ "Alternation", "Concentric Arrangement" ], "Geometric Objects": [ "Point", "Circle", "Distance", "Radius", "Coordinate System" ], "Mathematical Operations": [ "Value Comparison" ], "Spatial Transform...
Validation
q100-3
from typing import Tuple import math def solution(coordinate: Tuple[int, int]) -> int: """ Determines the color of the zone at the given coordinate. The colors follow an infinitely repeating pattern. Args: coordinate: A tuple (x, y) representing the coordinate point Returns: 0 for...
# Problem Description This is a coordinate-based zone coloring problem where we need to determine the color of a point given its (x,y) coordinates. The plane is divided into alternating black and white circular rings, with special rules. The coloring pattern depends on: 1. The distance from the origin (0,0) 2. Whether ...
def test(): test_cases = [ ((0.5, 0.5), 0), ((0.5, 1.5),1), ((3, 2), 1), ((1, 1), 1), ((5, 3), 1), ((5, 4), 0), ((2, 2), 0), ((4, 3), 3), ((7, 7), 1), ((23009853, 23009853), 0), ((23009853, 23009853), 0), ((992384, 223...
from typing import Tuple import math def solution(coordinate: Tuple[int, int]) -> int: """ Determines the color of the zone at the given coordinate. The colors follow an infinitely repeating pattern. Args: coordinate: A tuple (x, y) representing the coordinate point Returns: 0 for...
{ "Common Sense": null, "Data Structures": null, "Dynamic Patterns": [ "Alternation", "Concentric Arrangement" ], "Geometric Objects": [ "Point", "Circle", "Distance", "Radius", "Coordinate System" ], "Mathematical Operations": [ "Value Comparison" ], "Spatial Transform...
Validation
q11
from typing import Tuple def layer(x: int, y: int) -> int: """ Determine the layer of a point based on its coordinates. Parameters: x (int): The x-coordinate of the point. y (int): The y-coordinate of the point. Returns: int: The layer of the point. """ return max(x, y...
# Problem Description This is a point relationship classification problem in a layered grid system. Given two points in a coordinate system, we need to determine their relationship, which falls into one of three categories (A, B, or C) based on their relative layer positions. The layers are organized as concentric squa...
def test(): test_cases = [ ((2, 0), (2, 1), 'A'), ((0, 0), (4, 0), 'C'), ((1, 0), (2, 0), 'B'), ((0, 0), (0, 0), 'A'), ((3, 10), (4, 4), 'C'), ((5, 6), (7, 4), 'B'), ((9, 9), (9, 10), 'B'), ((999, 1002), (1000, 1000), 'C'), ((0, 0), (0, 1), 'B'...
from typing import Tuple def solution(point1: Tuple[int, int], point2: Tuple[int, int]) -> str: """ Determine the relationship between two points based on their layers. Parameters: point1 (Tuple[int, int]): The coordinates of the first point, where both x and y are non-negative integers. ...
{ "Common Sense": null, "Data Structures": null, "Dynamic Patterns": [ "Linear Increment", "Concentric Arrangement", "Layered Structure" ], "Geometric Objects": [ "Line", "Arrow", "Point", "Coordinate System", "Grid" ], "Mathematical Operations": [ "Value Comparison" ...
Validation
q11-2
from typing import Tuple def solution(point1: Tuple[int, int], point2: Tuple[int, int]) -> str: """ Determine the relationship between two points based on their layers. Parameters: point1 (Tuple[int, int]): The coordinates of the first point, where both x and y are non-negative integers. ...
# Problem Description This problem involves determining the relationship between two points in a layered coordinate system. The layers are organized in a triangular grid pattern, expanding outward from the origin. Given two points, we need to classify their relationship into one of three categories: "A" (Same Layer), "...
def test(): test_cases = [ ((2, 0), (2, 1), 'B'), ((1, 1), (0, 2), 'A'), ((0, 3), (1, 2), 'A'), ((0, 0), (4, 0), 'C'), ((1, 0), (2, 0), 'B'), ((0, 0), (0, 0), 'A'), ((3, 10), (4, 4), 'C'), ((5, 6), (7, 4), 'A'), ((9, 9), (9, 10), 'B'), ...
from typing import Tuple def solution(point1: Tuple[int, int], point2: Tuple[int, int]) -> str: """ Determine the relationship between two points based on their layers. Parameters: point1 (Tuple[int, int]): The coordinates of the first point, where both x and y are non-negative integers. ...
{ "Common Sense": null, "Data Structures": null, "Dynamic Patterns": [ "Linear Increment", "Concentric Arrangement", "Layered Structure" ], "Geometric Objects": [ "Line", "Arrow", "Point", "Coordinate System", "Grid" ], "Mathematical Operations": [ "Value Comparison" ...
Validation
q11-3
from typing import Tuple def layer(x: int, y: int) -> int: """ Determine the layer of a point based on its coordinates. Parameters: x (int): The x-coordinate of the point. y (int): The y-coordinate of the point. Returns: int: The layer of the point. """ return min(x, y...
# Problem Description This problem involves determining the relationship between two points on a coordinate grid based on their respective layers. The grid is divided into layers, with each layer forming a square perimeter around the origin. The relationship between the points can be one of three types: - "A": Points a...
def test(): test_cases = [ ((2, 0), (2, 1), 'B'), ((0, 0), (4, 0), 'A'), ((1, 0), (2, 0), 'A'), ((0, 0), (0, 0), 'A'), ((3, 10), (4, 4), 'B'), ((5, 6), (7, 4), 'B'), ((9, 9), (9, 10), 'A'), ((999, 1002), (1000, 1000), 'B'), ((0, 0), (0, 1), 'A'...
from typing import Tuple def solution(point1: Tuple[int, int], point2: Tuple[int, int]) -> str: """ Determine the relationship between two points based on their layers. Parameters: point1 (Tuple[int, int]): The coordinates of the first point, where both x and y are non-negative integers. ...
{ "Common Sense": null, "Data Structures": null, "Dynamic Patterns": [ "Linear Increment", "Concentric Arrangement", "Layered Structure" ], "Geometric Objects": [ "Line", "Arrow", "Point", "Coordinate System", "Grid" ], "Mathematical Operations": [ "Value Comparison" ...
Validation
q12
from typing import List def solution(input_matrix: List[List[str]]) -> List[List[str]]: """ Transform the input matrix based on the pattern shown in the figure Parameters: input_matrix (List[List[str]]): Input matrix as a 2d array. Returns: output_matrix (List[List[str]]): Out...
# Problem Description The problem requires implementing a matrix transformation function that takes a NxN input matrix and produces a NxN output matrix following specific rotation patterns. The transformation appears to involve both repositioning and rearranging elements in a systematic way. # Visual Facts 1. Matrix D...
def test(): test_cases = [ [['1', '2', '3'], ['4', '#', '6'], ['D', '8', 'a']], [['1', 'a'], ['3', '#']], [['4', '@', '1', '8'], ['#', 'a', 'Q', '&'], ['9', '?', '&', '%'], ['b', '$', 'F', 't']], [['6', '@', '2', '1'], ['9', '#', 'Q', '1'], ['9', '4', '5', '4'], ['1', '1', '1', '1']]...
from typing import List def solution(input_matrix: List[List[str]]) -> List[List[str]]: """ Transform the input matrix based on the pattern shown in the figure Parameters: input_matrix (List[List[str]]): Input matrix as a 2d array. Returns: output_matrix (List[List[str]]): Out...
{ "Common Sense": null, "Data Structures": [ "Matrix" ], "Dynamic Patterns": null, "Geometric Objects": [ "Line", "Grid", "Arrow" ], "Mathematical Operations": null, "Spatial Transformations": [ "Rotation" ], "Topological Relations": [ "Boundary", "Adjacency" ] }
Transformation
q12-2
from typing import List def solution(input_matrix: List[List[str]]) -> List[List[str]]: """ Transform the input matrix based on the pattern shown in the figure Parameters: input_matrix (List[List[str]]): Input matrix as a 2d array. Returns: output_matrix (List[List[str]]): Out...
# Problem Description The problem requires implementing a matrix transformation function that takes a NxN input matrix and produces a NxN output matrix. The transformation appears to be a reflection or mirroring operation around a vertical axis that runs through the center of the matrix. # Visual Facts 1. Matrix Prope...
def test(): test_cases = [ [['1', '2', '3'], ['4', '#', '6'], ['D', '8', 'a']], [['1', 'a'], ['3', '#']], [['4', '@', '1', '8'], ['#', 'a', 'Q', '&'], ['9', '?', '&', '%'], ['b', '$', 'F', 't']], [['6', '@', '2', '1'], ['9', '#', 'Q', '1'], ['9', '4', '5', '4'], ['1', '1', '1', '1']]...
from typing import List def solution(input_matrix: List[List[str]]) -> List[List[str]]: """ Transform the input matrix based on the pattern shown in the figure Parameters: input_matrix (List[List[str]]): Input matrix as a 2d array. Returns: output_matrix (List[List[str]]): Out...
{ "Common Sense": null, "Data Structures": [ "Matrix" ], "Dynamic Patterns": [ "Mirror Symmetry", "Mirror Reflection" ], "Geometric Objects": [ "Line", "Grid", "Arrow" ], "Mathematical Operations": null, "Spatial Transformations": [ "Rotation", "Flipping" ], "Topolo...
Transformation
q12-3
from typing import List def solution(input_matrix: List[List[str]]) -> List[List[str]]: """ Transform the input matrix based on the pattern shown in the figure Parameters: input_matrix (List[List[str]]): Input matrix as a 2d array. Returns: output_matrix (List[List[str]]): Out...
Let me analyze your problem: # Problem Description The problem requires implementing a matrix transformation function that takes a NxN input matrix and produces a NxN output matrix. The transformation appears to be a horizontal flip or reflection around a horizontal axis that runs through the middle of the matrix. # ...
def test(): test_cases = [ [['1', '2', '3'], ['4', '#', '6'], ['D', '8', 'a']], [['1', 'a'], ['3', '#']], [['4', '@', '1', '8'], ['#', 'a', 'Q', '&'], ['9', '?', '&', '%'], ['b', '$', 'F', 't']], [['6', '@', '2', '1'], ['9', '#', 'Q', '1'], ['9', '4', '5', '4'], ['1', '1', '1', '1']]...
from typing import List def solution(input_matrix: List[List[str]]) -> List[List[str]]: """ Transform the input matrix based on the pattern shown in the figure Parameters: input_matrix (List[List[str]]): Input matrix as a 2d array. Returns: output_matrix (List[List[str]]): Out...
{ "Common Sense": null, "Data Structures": [ "Matrix" ], "Dynamic Patterns": [ "Mirror Symmetry", "Mirror Reflection" ], "Geometric Objects": [ "Line", "Grid", "Arrow" ], "Mathematical Operations": null, "Spatial Transformations": [ "Rotation", "Flipping" ], "Topolo...
Transformation
q13
import heapq def solution(nodes: dict, edges: list, start: str, end: str) -> int: """ Given the nodes and edges of a graph, determine the minimum path cost from a given starting node to an ending node. Please observe the example graph in the image to deduce the pattern calculating the path cost between two...
# Problem Description This is a graph pathfinding problem where we need to: - Find the minimum cost path between two given nodes in an undirected weighted graph - Each node has an associated value - Each edge has a cost - The total path cost must follow a specific pattern based on the nodes' values and edge costs - We ...
def test(): nodes = {'A': 10, 'B': 3, 'C': -2, 'D': -8, 'E': -6, 'F': 4} connections = [('A', 'B'), ('B', 'C'), ('B', 'D'), ('D', 'E'), ('D', 'F')] pairs = [('A', 'C'), ('B', 'E'), ('A', 'F'), ('A', 'D'), ('A', 'E'), ('B', 'F')] expected_results = [18, 25, 36, 24, 38, 23] for index, (start, end...
def solution(nodes: dict, edges: list, start: str, end: str) -> int: """ Given the nodes and edges of a graph, determine the minimum path cost from a given starting node to an ending node. Please observe the example graph in the image to deduce the pattern calculating the path cost between two nodes. I...
{ "Common Sense": null, "Data Structures": [ "Undirected Graph", "Path" ], "Dynamic Patterns": null, "Geometric Objects": null, "Mathematical Operations": [ "Absolute Value", "Basic Arithmetic" ], "Spatial Transformations": null, "Topological Relations": [ "Adjacency", "Connect...
Direct Calculation
q13-2
import heapq def solution(nodes: dict, edges: list, start: str, end: str) -> int: """ Given the nodes and edges of a graph, determine the minimum path cost from a given starting node to an ending node. Please observe the example graph in the image to deduce the pattern calculating the path cost between two...
# Problem Description This problem involves finding the minimum cost path between two nodes in an undirected weighted graph. Each node has an associated value, and each edge has a cost. The goal is to determine the minimum cost required to travel from a given starting node to an ending node, following a specific patter...
def test(): nodes = {'A': 10, 'B': 3, 'C': -2, 'D': -8, 'E': -6, 'F': 4} connections = [('A', 'B'), ('B', 'C'), ('B', 'D'), ('D', 'E'), ('D', 'F')] pairs = [('A', 'C'), ('B', 'E'), ('A', 'F'), ('A', 'D'), ('A', 'E'), ('B', 'F')] expected_results = [36, 72, 86, 54, 102, 56] for index, (start, en...
def solution(nodes: dict, edges: list, start: str, end: str) -> int: """ Given the nodes and edges of a graph, determine the minimum path cost from a given starting node to an ending node. Please observe the example graph in the image to deduce the pattern calculating the path cost between two nodes. I...
{ "Common Sense": null, "Data Structures": [ "Undirected Graph", "Path" ], "Dynamic Patterns": null, "Geometric Objects": null, "Mathematical Operations": [ "Absolute Value", "Basic Arithmetic" ], "Spatial Transformations": null, "Topological Relations": [ "Adjacency", "Connect...
Direct Calculation
q13-3
import heapq def solution(nodes: dict, edges: list, start: str, end: str) -> int: """ Given the nodes and edges of a graph, determine the minimum path cost from a given starting node to an ending node. Please observe the example graph in the image to deduce the pattern calculating the path cost between two...
# Problem Description This is a graph pathfinding problem where we need to: - Find the minimum cost path between two given nodes in an undirected weighted graph. - Each node has an associated value. - Each edge has a cost. - The total path cost must follow a specific pattern based on the nodes' values and edge costs. -...
def test(): nodes = {'A': 10, 'B': 3, 'C': -2, 'D': -8, 'E': -6, 'F': 4} connections = [('A', 'B'), ('B', 'C'), ('B', 'D'), ('D', 'E'), ('D', 'F')] pairs = [('A', 'C'), ('B', 'E'), ('A', 'F'), ('A', 'D'), ('A', 'E'), ('B', 'F')] expected_results = [12, 13, 30, 18, 20, 23] for index, (start, end...
def solution(nodes: dict, edges: list, start: str, end: str) -> int: """ Given the nodes and edges of a graph, determine the minimum path cost from a given starting node to an ending node. Please observe the example graph in the image to deduce the pattern calculating the path cost between two nodes. I...
{ "Common Sense": null, "Data Structures": [ "Undirected Graph", "Path" ], "Dynamic Patterns": null, "Geometric Objects": null, "Mathematical Operations": [ "Basic Arithmetic", "Value Comparison" ], "Spatial Transformations": null, "Topological Relations": [ "Adjacency", "Conne...
Direct Calculation
q14
def solution(start: tuple[int, int], target: tuple[int, int], direction: tuple[int, int]) -> bool: """ Determines whether the ball can reach the target. Parameters: - start: Tuple[int, int], represents the initial position of the ball (x, y). - target: Tuple[int, int], represents the position of th...
# Problem Description This is a ball trajectory problem where we need to determine if a ball starting from a given position with an initial direction can reach a target position after bouncing off the boundaries of a 10x10 grid. The ball follows the law of reflection (angle of incidence equals angle of reflection) when...
def test(): test_cases = [ [(8, 7), (6, 9), (1, -1), True], [(8, 7), (6, 10), (1, -1), False], [(8, 7), (9, 6), (1, -1), True], [(0, 0), (1, 1), (1, 0), False], [(0, 0), (2, 2), (1, 1), True], [(0, 0), (0, 1), (0, 1), True], [(2, 1), (6, 10),...
def solution(start: tuple[int, int], target: tuple[int, int], direction: tuple[int, int]) -> bool: """ Determines whether the ball can reach the target. Parameters: - start: Tuple[int, int], represents the initial position of the ball (x, y). - target: Tuple[int, int], represents the position of th...
{ "Common Sense": null, "Data Structures": [ "Path" ], "Dynamic Patterns": [ "Bouncing" ], "Geometric Objects": [ "Grid", "Arrow", "Point", "Line", "Coordinate System" ], "Mathematical Operations": null, "Spatial Transformations": null, "Topological Relations": [ "Int...
Validation
q14-2
def solution(start_1: tuple[int, int], start_2: tuple[int, int], direction_1: tuple[int, int], direction_2: tuple[int, int]) -> bool: """ Determines whether the two balls will collide. Parameters: - start_1: Tuple[int, int], represents the initial position of ball 1 (x, y). - start_2: Tuple[int, in...
# Problem Description This problem involves determining whether two balls, starting from different positions and moving in specified directions, will collide on a 10x10 grid. The balls bounce off the boundaries of the grid according to the law of reflection (angle of incidence equals angle of reflection). The task is t...
def test(): test_cases = [ [(8, 7), (6, 9), (1, -1), (1, 1), False], [(8, 7), (6, 9), (1, -1), (-1, 1), True], [(8, 7), (6, 9), (-1, 1), (1, -1), True], [(8, 7), (9, 6), (1, -1), (1, -1), False], [(0, 0), (1, 1), (1, 0), (1, 1), False], [(0, 0), (0, 3), (1, 0...
def solution(start_1: tuple[int, int], start_2: tuple[int, int], direction_1: tuple[int, int], direction_2: tuple[int, int]) -> bool: """ Determines whether the two balls will collide. Parameters: - start_1: Tuple[int, int], represents the initial position of ball 1 (x, y). - start_2: Tuple[int, in...
{ "Common Sense": null, "Data Structures": [ "Path" ], "Dynamic Patterns": [ "Bouncing" ], "Geometric Objects": [ "Grid", "Arrow", "Point", "Line", "Coordinate System" ], "Mathematical Operations": null, "Spatial Transformations": null, "Topological Relations": [ "Int...
Validation
q14-3
def solution(start: tuple[int, int], direction: tuple[int, int]) -> bool: """ Determines whether the ball can go into the hole Parameters: - start: Tuple[int, int], represents the initial position of the ball (x, y). - direction: Tuple[int, int], represents the initial direction of the ball (dx, dy...
# Problem Description This problem involves determining if a ball starting from a given position with an initial direction can reach any of the holes on a 10x10 grid. The ball follows the law of reflection when it hits the boundaries of the grid. The task is to simulate the ball's movement and check if it eventually fa...
def test(): test_cases = [ [(8, 7), (1, -1), False], [(8, 7), (-1, -1), False], [(8, 8), (1, -1), True], [(0, 0), (1, 0), False], [(0, 0), (1, 1), True], [(0, 0), (0, 1), False], [(2, 1), (-1, -1), False], [(2, 1), (0, 1), True], ...
def solution(start: tuple[int, int], direction: tuple[int, int]) -> bool: """ Determines whether the ball can go into the hole Parameters: - start: Tuple[int, int], represents the initial position of the ball (x, y). - direction: Tuple[int, int], represents the initial direction of the ball (dx, dy...
{ "Common Sense": null, "Data Structures": [ "Path" ], "Dynamic Patterns": [ "Bouncing" ], "Geometric Objects": [ "Grid", "Arrow", "Point", "Line", "Coordinate System" ], "Mathematical Operations": null, "Spatial Transformations": null, "Topological Relations": [ "Int...
Validation
q15
def solution(end_time: int) -> int: """ Calculate how many layers of cups have been full-filled by the given end time. Input: - end_time: the given end time. Output: - the total numbers of full-filled layers. """ layers_filled = 0 total_time = 0 while True: time_for_nex...
# Problem Description This is a water flow simulation problem in a pyramid-like cup structure. Water is poured continuously from the top, and when a cup is full, it overflows equally to the two cups below it. The task is to calculate how many layers of cups are completely filled at a given time point. # Visual Facts 1...
def test(): test_cases = [ (1*8, 1), (2*8, 1), (3*8, 2), (4*8, 2), (5*8, 2), (7*8, 3), (9*8, 3), (25*8, 4), (30*8, 4), (50*8, 5), (70*8, 6), (100*8, 6), ] for i, (end_time, expected_output) in enumerate(test_case...
def solution(end_time: int) -> int: """ Calculate how many layers of cups have been full-filled by the given end time. Input: - end_time: the given end time. Output: - the total numbers of full-filled layers. """
{ "Common Sense": [ "Flow of Water", "Capacity" ], "Data Structures": null, "Dynamic Patterns": [ "Layered Structure", "Propagation" ], "Geometric Objects": null, "Mathematical Operations": null, "Spatial Transformations": null, "Topological Relations": [ "Connectivity", "Conne...
Iterative Calculation
q16
def solution(grid: list[int]) -> int: """ Calculate the number of communities according to the image. Input: - grid: A list representing the initial grid, each str element is a row of the grid. The 'x' indicates a gray square and '.' indicates a white square. Output: - An integer representing ...
# Problem Description This is a grid-based problem where we need to count the number of "communities" in a given grid. A community appears to be a group of connected white squares (represented by '.') in a grid where some squares are gray (represented by 'x'). The goal is to return the total count of distinct communiti...
def test(): test_cases = [ ([".x.x", "xxxx"], 2), (["....", "..xx"], 1), ([".xxxx....", "..xxx.xxx"], 2), (["xxx..", "...x."], 1), (["xxx..xx", "...xx.."], 1), (["x.x..x", ".x...x", "..x.xx", ...
def solution(grid: list[int]) -> int: """ Calculate the number of communities according to the image. Input: - grid: A list representing the initial grid, each str element is a row of the grid. The 'x' indicates a gray square and '.' indicates a white square. Output: - An integer representing ...
{ "Common Sense": null, "Data Structures": [ "Matrix" ], "Dynamic Patterns": null, "Geometric Objects": [ "Grid", "Square" ], "Mathematical Operations": null, "Spatial Transformations": [ "Clustering", "Grouping" ], "Topological Relations": [ "Connectivity", "Adjacency" ...
Aggregation
q17
def solution(matrix: list[list[int]]) -> list[list[int]]: """ Refer to the example cases illustrated in the figure, identify and implement the pooling operation on the matrix. Input: - matrix: A 2d list representing the initial matrix. For example, [[1,3,4,2], [2,1,1,3], [1,2,2,4], [3,2,1,0]] Outp...
# Problem Description This is a matrix pooling operation problem where a larger input matrix needs to be transformed into a smaller output matrix using specific rules. The pooling operation appears to reduce the size of the input matrix by processing 2×2 regions into single values in the output matrix. The goal is to i...
def test(): test_cases = [ { "input":[ [1,2], [3,4] ], "expected":[ [1] ] }, { "input": [ [1, 3, 4, 2], [2, 1, 1, 3], [1, 2, 2, 4], ...
def solution(matrix: list[list[int]]) -> list[list[int]]: """ Refer to the example cases illustrated in the figure, identify and implement the pooling operation on the matrix. Input: - matrix: A 2d list representing the initial matrix. For example, [[1,3,4,2], [2,1,1,3], [1,2,2,4], [3,2,1,0]] Outp...
{ "Common Sense": null, "Data Structures": [ "Matrix" ], "Dynamic Patterns": null, "Geometric Objects": null, "Mathematical Operations": [ "Value Comparison", "Aggregation" ], "Spatial Transformations": [ "Grouping", "Scaling", "Filtering" ], "Topological Relations": [ "A...
Aggregation
q17-2
def solution(matrix: list[list[int]]) -> list[list[int]]: """ Refer to the example cases illustrated in the figure, identify and implement the pooling operation on the matrix. Input: - matrix: A 2d list representing the initial matrix. For example, [[1,3,4,2], [2,1,1,3], [1,2,2,4], [3,2,1,0]] Outp...
# Problem Description This problem involves performing a pooling operation on a given 2D matrix. The pooling operation reduces the size of the matrix by processing 2x2 regions into single values in the output matrix. The goal is to implement this transformation according to the pattern shown in the examples. # Visual ...
def test(): test_cases = [ { "input": [ [1, -2], [3, 4] ], "expected": [ [4] ] }, { "input": [ [1, 3, 4, 2], [2, 1, 1, 3], [1, 2, 2, 4]...
def solution(matrix: list[list[int]]) -> list[list[int]]: """ Refer to the example cases illustrated in the figure, identify and implement the pooling operation on the matrix. Input: - matrix: A 2d list representing the initial matrix. For example, [[1,3,4,2], [2,1,1,3], [1,2,2,4], [3,2,1,0]] Outp...
{ "Common Sense": null, "Data Structures": [ "Matrix" ], "Dynamic Patterns": null, "Geometric Objects": null, "Mathematical Operations": [ "Value Comparison", "Aggregation", "Absolute Value" ], "Spatial Transformations": [ "Grouping", "Scaling", "Filtering" ], "Topologica...
Aggregation
q17-3
def solution(matrix: list[list[int]]) -> list[list[int]]: """ Refer to the example cases illustrated in the figure, identify and implement the pooling operation on the matrix. Input: - matrix: A 2d list representing the initial matrix. For example, [[1,3,4], [2,1,1], [1,2,2]] Output: - A 2d li...
# Problem Description This problem involves performing a pooling operation on a given matrix. The pooling operation reduces the size of the matrix by selecting specific elements from sub-regions of the original matrix. The goal is to implement this transformation according to the patterns shown in the examples. # Visu...
def test(): test_cases = [ { "input": [ [1, 2, 6], [3, 4, 3], [8, 7, 9], ], "expected": [ [1] ] }, { "input": [ [1, 3, 4, 2, 0, 3], [2, ...
def solution(matrix: list[list[int]]) -> list[list[int]]: """ Refer to the example cases illustrated in the figure, identify and implement the pooling operation on the matrix. Input: - matrix: A 2d list representing the initial matrix. For example, [[1,3,4], [2,1,1], [1,2,2]] Output: - A 2d li...
{ "Common Sense": null, "Data Structures": [ "Matrix" ], "Dynamic Patterns": null, "Geometric Objects": null, "Mathematical Operations": [ "Value Comparison", "Aggregation" ], "Spatial Transformations": [ "Grouping", "Scaling", "Filtering" ], "Topological Relations": [ "A...
Aggregation
q18
from typing import List def solution(matrix: List[List[int]]) -> List[int]: """ Given an M x N 2D matrix, traverse the matrix according to the spiral pattern shown in the figure Parameters: matrix (List[List[int]]): A 2D list of integers representing the matrix. Returns: List[int]: A list of...
# Problem Description This is a matrix traversal problem where we need to: - Start from the top-right corner of a given matrix - Follow a specific spiral pattern in counter-clockwise direction - Collect all elements in the order of traversal - The traversal pattern should work for matrices of different sizes (MxN) # V...
def test(): test_cases = [ ([[1, 2]], [2, 1]), ([[1, 2], [3, 4]], [2, 1, 3, 4]), ([[1, 2, 3], [4, 5, 6], [7, 8 , 9]], [3, 2, 1, 4, 7, 8, 9, 6, 5]), ([[1,2,3,4], [5,6,7,8], [9,10,11,12]], [4, 3, 2, 1, 5, 9, 10, 11, 12, 8, 7, 6]), ([[1,...
from typing import List def solution(matrix: List[List[int]]) -> List[int]: """ Given an M x N 2D matrix, traverse the matrix according to the spiral pattern shown in the figure Parameters: matrix (List[List[int]]): A 2D list of integers representing the matrix. Returns: List[int]: A list of...
{ "Common Sense": null, "Data Structures": [ "Path", "Matrix", "Directed Graph" ], "Dynamic Patterns": [ "Cyclic Motion", "Spiral" ], "Geometric Objects": [ "Grid", "Arrow" ], "Mathematical Operations": null, "Spatial Transformations": null, "Topological Relations": [ ...
Transformation
q18-2
from typing import List def solution(matrix: List[List[int]]) -> List[int]: """ Given an M x N 2D matrix, traverse the matrix according to the spiral pattern shown in the figure Parameters: matrix (List[List[int]]): A 2D list of integers representing the matrix. Returns: List[int]: A list of...
# Problem Description The problem requires implementing a matrix traversal function that follows a specific spiral pattern. Given a matrix of M x N dimensions, we need to return the elements in a specific order that follows a spiral path starting from the bottom-right corner, moving initially leftward, and then followi...
def test(): test_cases = [ ([[1, 2]], [2, 1]), ([[1, 2], [3, 4]], [4, 3, 1, 2]), ([[1, 2, 3], [4, 5, 6], [7, 8 , 9]], [9, 8, 7, 4, 1, 2, 3, 6, 5]), ([[1,2,3,4], [5,6,7,8], [9,10,11,12]], [12, 11, 10, 9, 5, 1, 2, 3, 4, 8, 7, 6]), ([[1,...
from typing import List def solution(matrix: List[List[int]]) -> List[int]: """ Given an M x N 2D matrix, traverse the matrix according to the spiral pattern shown in the figure Parameters: matrix (List[List[int]]): A 2D list of integers representing the matrix. Returns: List[int]: A list of...
{ "Common Sense": null, "Data Structures": [ "Path", "Matrix", "Directed Graph" ], "Dynamic Patterns": [ "Cyclic Motion", "Spiral" ], "Geometric Objects": [ "Grid", "Arrow" ], "Mathematical Operations": null, "Spatial Transformations": null, "Topological Relations": [ ...
Transformation
q18-3
from typing import List def solution(matrix: List[List[int]]) -> List[int]: """ Given an M x N 2D matrix, traverse the matrix according to the spiral pattern shown in the figure Parameters: matrix (List[List[int]]): A 2D list of integers representing the matrix. Returns: List[int]: A list of...
# Problem Description The problem requires implementing a matrix traversal function that follows a specific spiral pattern. Given a matrix of M x N dimensions, we need to return the elements in a specific order that follows a spiral path starting from the bottom-left corner, moving initially rightward, and then followi...
def test(): test_cases = [ ([[1, 2]], [1, 2]), ([[1, 2], [3, 4]], [3, 4, 2, 1]), ([[1, 2, 3], [4, 5, 6], [7, 8 , 9]], [7, 8, 9, 6, 3, 2, 1, 4, 5]), ([[1,2,3,4], [5,6,7,8], [9,10,11,12]], [9, 10, 11, 12, 8, 4, 3, 2, 1, 5, 6, 7]), ([[1,...
from typing import List def solution(matrix: List[List[int]]) -> List[int]: """ Given an M x N 2D matrix, traverse the matrix according to the spiral pattern shown in the figure Parameters: matrix (List[List[int]]): A 2D list of integers representing the matrix. Returns: List[int]: A list of...
{ "Common Sense": null, "Data Structures": [ "Path", "Matrix", "Directed Graph" ], "Dynamic Patterns": [ "Cyclic Motion", "Spiral" ], "Geometric Objects": [ "Grid", "Arrow" ], "Mathematical Operations": null, "Spatial Transformations": null, "Topological Relations": [ ...
Transformation
q19
def solution(dragon_life: float, player_life: float, dragon_attack_point: float, player_attack_point: float) -> int: """ Build the dragon slaying game as shown in the diagram, and calculate how many life points the winner has left. Parameters: dragon_life (float): The life points of the dragon. ...
# Problem Description This is a turn-based battle game simulation between a player and a dragon. The game has two distinct status phases with different attack patterns. The goal is to calculate the remaining life points of whoever wins the battle (either dragon or player). The battle follows specific rules for attack p...
def test(): test_cases = [ (100, 90, 10, 5, 49), (59.9, 78, 60, 26.6, 1), (1000.1, 100.79, 8.54, 50.3, 396), (63, 100, 100, 1, 62), (1000.34, 10, 11, 1001, 10), (150.33, 176.24, 23.5, 26.8, 68), (92.3, 11.1, 1, 32.3, 9), (12384.4, 13323.9, 10.1, 11.1, ...
def solution(dragon_life: float, player_life: float, dragon_attack_point: float, player_attack_point: float) -> int: """ Build the dragon slaying game as shown in the diagram, and calculate how many life points the winner has left. Parameters: dragon_life (float): The life points of the dragon. ...
{ "Common Sense": null, "Data Structures": null, "Dynamic Patterns": null, "Geometric Objects": [ "Arrow" ], "Mathematical Operations": [ "Flowcharting", "Conditional Branching", "Value Comparison" ], "Spatial Transformations": null, "Topological Relations": [ "Connectivity", "...
Direct Calculation
q19-2
def solution(dragon_life: float, player_life: float, dragon_attack_point: float, player_attack_point: float) -> int: """ Build the dragon slaying game as shown in the diagram, and calculate how many life points the winner has left. Parameters: dragon_life (float): The life points of the dragon. ...
# Problem Description This is a turn-based battle game simulation between a player and a dragon. The game has two distinct status phases with different attack patterns. The goal is to calculate the remaining life points of whoever wins the battle (either dragon or player). The battle follows specific rules for attack p...
def test(): test_cases = [ (100, 90, 10, 5, 55), (59.9, 78, 60, 26.6, 39), (1000.1, 100.79, 8.54, 50.3, 396), (63, 100, 100, 1, 62), (1000.34, 10, 11, 1001, 10), (150.33, 176.24, 23.5, 26.8, 66), (92.3, 11.1, 1, 32.3, 9), (12384.4, 13323.9, 10.1, 11.1,...
def solution(dragon_life: float, player_life: float, dragon_attack_point: float, player_attack_point: float) -> int: """ Build the dragon slaying game as shown in the diagram, and calculate how many life points the winner has left. Parameters: dragon_life (float): The life points of the dragon. ...
{ "Common Sense": null, "Data Structures": null, "Dynamic Patterns": null, "Geometric Objects": [ "Arrow" ], "Mathematical Operations": [ "Flowcharting", "Conditional Branching", "Value Comparison" ], "Spatial Transformations": null, "Topological Relations": [ "Connectivity", "...
Direct Calculation
q19-3
def solution(dragon_life: float, player_life: float, dragon_attack_point: float, player_attack_point: float) -> int: """ Build the dragon slaying game as shown in the diagram, and calculate how many life points the winner has left. Parameters: dragon_life (float): The life points of the dragon. ...
# Problem Description This is a turn-based battle game simulation between a player and a dragon. The game has two distinct status phases with different attack patterns. The goal is to calculate the remaining life points of whoever wins the battle (either dragon or player). The battle follows specific rules for attack p...
def test(): test_cases = [ (90, 100, 5, 10, 49), (78, 59.9, 26.6, 60, 1), (100.79, 1000.1, 50.3, 8.54, 396), (100, 63, 1, 100, 62), (10, 1000.34, 1001, 11, 10), (176.24, 150.33, 26.8, 23.5, 68), (11.1, 92.3, 32.3, 1, 9), (13323.9, 12384.4, 11.1, 10.1, ...
def solution(dragon_life: float, player_life: float, dragon_attack_point: float, player_attack_point: float) -> int: """ Build the dragon slaying game as shown in the diagram, and calculate how many life points the winner has left. Parameters: dragon_life (float): The life points of the dragon. ...
{ "Common Sense": null, "Data Structures": null, "Dynamic Patterns": null, "Geometric Objects": [ "Arrow" ], "Mathematical Operations": [ "Flowcharting", "Conditional Branching", "Value Comparison" ], "Spatial Transformations": null, "Topological Relations": [ "Connectivity", "...
Direct Calculation
q2
from typing import List import numpy as np def solution() -> List[List[float]]: """ generate a set of 1000 data points that match the distribution shown in the figure Returns: List[List[float]]: A 2D array of shape (1000, 2), where each row contains the x and y coordinates of a point. """ ...
# Problem Description The task is to generate a dataset of 1000 2D points that follows a specific distribution pattern shown in the figure. The points should be distributed within a 1x1 square area with special constraints around a circular region. The output should be a 2D array of shape (1000, 2) where each row repre...
import numpy as np def quartile_test(points): x_quartiles = np.percentile(points[:, 0], [25, 50, 75]) y_quartiles = np.percentile(points[:, 1], [25, 50, 75]) theoretical_quartiles = [0.2, 0.5, 0.8] x_check = np.allclose(x_quartiles, theoretical_quartiles, atol=0.1) y_check = np.allclose(y_quartil...
from typing import List def solution() -> List[List[float]]: """ generate a set of 1000 data points that match the distribution shown in the figure Returns: List[List[float]]: A 2D array of shape (1000, 2), where each row contains the x and y coordinates of a point. """
{ "Common Sense": null, "Data Structures": null, "Dynamic Patterns": [ "Concentric Arrangement" ], "Geometric Objects": [ "Point", "Coordinate System", "Circle" ], "Mathematical Operations": [ "Random Distribution" ], "Spatial Transformations": [ "Clustering" ], "Topologica...
Direct Calculation
q2-2
from typing import List import numpy as np def solution() -> List[List[float]]: """ generate a set of 1000 data points that match the distribution shown in the figure Returns: List[List[float]]: A 2D array of shape (1000, 2), where each row contains the x and y coordinates of a point. """ ...
# Problem Description The task is to generate a dataset of 1000 2D points that follows a specific distribution pattern shown in the figure. The points should be distributed within a circular area with a radius of 0.25. The output should be a 2D array of shape (1000, 2) where each row represents the (x,y) coordinates of...
import numpy as np def quartile_test(points): x_quartiles = np.percentile(points[:, 0], [25, 50, 75]) y_quartiles = np.percentile(points[:, 1], [25, 50, 75]) theoretical_quartiles = [0.4, 0.5, 0.6] x_check = np.allclose(x_quartiles, theoretical_quartiles, atol=0.1) y_check = np.allclose(y_quar...
from typing import List def solution() -> List[List[float]]: """ generate a set of 1000 data points that match the distribution shown in the figure Returns: List[List[float]]: A 2D array of shape (1000, 2), where each row contains the x and y coordinates of a point. """
{ "Common Sense": null, "Data Structures": null, "Dynamic Patterns": [ "Concentric Arrangement" ], "Geometric Objects": [ "Point", "Coordinate System", "Circle" ], "Mathematical Operations": [ "Random Distribution" ], "Spatial Transformations": [ "Clustering" ], "Topologica...
Direct Calculation
q2-3
from typing import List import numpy as np def solution() -> List[List[float]]: """ generate a set of 1000 data points that match the distribution shown in the figure Returns: List[List[float]]: A 2D array of shape (1000, 2), where each row contains the x and y coordinates of a point. """ ...
# Problem Description The task is to generate a dataset of 1000 2D points that follows a specific distribution pattern shown in the figure. The points should be distributed within a 1x1 square area with special constraints around an elliptical region. The output should be a 2D array of shape (1000, 2) where each row re...
import numpy as np def quartile_test(points): x_quartiles = np.percentile(points[:, 0], [25, 50, 75]) y_quartiles = np.percentile(points[:, 1], [25, 50, 75]) theoretical_x_quartiles = [0.2, 0.5, 0.8] theoretical_y_quartiles = [0.2, 0.5, 0.8] x_check = np.allclose(x_quartiles, theoretical_x_quartile...
from typing import List def solution() -> List[List[float]]: """ generate a set of 1000 data points that match the distribution shown in the figure Returns: List[List[float]]: A 2D array of shape (1000, 2), where each row contains the x and y coordinates of a point. """
{ "Common Sense": null, "Data Structures": null, "Dynamic Patterns": [ "Concentric Arrangement" ], "Geometric Objects": [ "Point", "Coordinate System", "Ellipse" ], "Mathematical Operations": [ "Random Distribution" ], "Spatial Transformations": [ "Clustering" ], "Topologic...
Direct Calculation
q20
from typing import List def solution(swaps: List[str], initial_position: int) -> int: """ Determine the final position of the ball after a series of swaps. Parameters: swaps (List[str]): A list of operation ids ('A', 'B', 'C', 'D', 'E', or 'F') representing the sequence of cup swap operations. ...
# Problem Description This is a cup-swapping puzzle where: - There are 4 cups indexed from 1 to 4 - A red ball is placed under one of the cups initially - A sequence of swap operations (A through F) is performed - We need to track the final position of the ball after all swaps are completed - Each swap operation has a ...
def test(): test_cases = [ (['A'], 1, 2), (['A'], 3, 3), (['B'], 3, 1), (['A', 'B', 'C'], 2, 2), (['D', 'E', 'A', 'C', 'B'], 4, 3), (['E', 'C', 'A', 'B', 'C', 'E', 'D'], 3, 3), (['A', 'C', 'E', 'D'], 1, 2), (['A', 'E', 'D', 'A', 'C', 'A', 'D', 'E', 'B'...
from typing import List def solution(swaps: List[str], initial_position: int) -> int: """ Determine the final position of the ball after a series of swaps. Parameters: swaps (List[str]): A list of operation ids ('A', 'B', 'C', 'D', 'E', or 'F') representing the sequence of cup swap operations. ...
{ "Common Sense": null, "Data Structures": [ "Sequence" ], "Dynamic Patterns": null, "Geometric Objects": [ "Arrow" ], "Mathematical Operations": null, "Spatial Transformations": [ "Swapping" ], "Topological Relations": [ "Adjacency", "Connection" ] }
Iterative Calculation
q20-2
from typing import List def solution(swaps: List[str], initial_position: int) -> int: """ Determine the final position of the ball after a series of swaps. Parameters: swaps (List[str]): A list of operation ids ('A', 'B', 'C') representing the sequence of cup swap operations. initial_posit...
# Problem Description This is a cup-swapping puzzle where: - There are 4 cups numbered from 1 to 4 - A red ball is placed under one of the cups initially - Three possible swap operations (A, B, C) can be performed in sequence - We need to track and return the final position of the ball after all swaps - Each operation ...
def test(): test_cases = [ (['A'], 1, 2), (['A'], 3, 3), (['B'], 3, 4), (['A', 'B', 'C'], 2, 1), (['C', 'A', 'A', 'C', 'B'], 4, 3), (['B', 'C', 'A', 'B', 'C', 'B', 'A'], 3, 1), (['A', 'C', 'B', 'C'], 1, 4), (['A', 'B', 'B', 'C', 'C', 'B', 'A', 'C', 'B'...
from typing import List def solution(swaps: List[str], initial_position: int) -> int: """ Determine the final position of the ball after a series of swaps. Parameters: swaps (List[str]): A list of operation ids ('A', 'B', 'C') representing the sequence of cup swap operations. initial_posit...
{ "Common Sense": null, "Data Structures": [ "Sequence" ], "Dynamic Patterns": null, "Geometric Objects": [ "Arrow" ], "Mathematical Operations": null, "Spatial Transformations": [ "Swapping" ], "Topological Relations": [ "Adjacency", "Connection" ] }
Iterative Calculation
q20-3
from typing import List def solution(swaps: List[str], initial_position: int) -> int: """ Determine the final position of the ball after a series of swaps. Parameters: swaps (List[str]): A list of operation ids ('A', 'B', 'C', 'D') representing the sequence of cup swap operations. initial_...
# Problem Description This is a cup-swapping puzzle where: - There are 4 cups numbered 1 to 4 arranged in a row - A red ball is placed under one of the cups initially - A sequence of swap operations (A through D) is performed - We need to track and return the final position of the ball - Each operation represents a spe...
def test(): test_cases = [ (['A'], 1, 2), (['A'], 3, 3), (['B'], 3, 1), (['A', 'B', 'D', 'C'], 2, 4), (['C', 'A', 'A', 'C', 'B'], 1, 3), (['B', 'C', 'A', 'B', 'D', 'C', 'B', 'A'], 3, 2), (['A', 'C', 'B', 'C'], 1, 1), (['A', 'B', 'B', 'C', 'C', 'B', 'A'...
from typing import List def solution(swaps: List[str], initial_position: int) -> int: """ Determine the final position of the ball after a series of swaps. Parameters: swaps (List[str]): A list of operation ids ('A', 'B', 'C', 'D') representing the sequence of cup swap operations. initial_...
{ "Common Sense": null, "Data Structures": [ "Sequence" ], "Dynamic Patterns": null, "Geometric Objects": [ "Arrow" ], "Mathematical Operations": null, "Spatial Transformations": [ "Swapping" ], "Topological Relations": [ "Adjacency", "Connection" ] }
Iterative Calculation
q21
from math import gcd def solution(x: int, y: int) -> str: """ Determine the first laser receiver encountered by the laser in the square area Parameters: x (int): The length of x. y (int): The length of y. Returns: str: The identifier of the first laser receiver encountered by ...
# Problem Description This is a laser path prediction problem in a square grid where: - A laser emitter shoots a beam from the bottom-left corner - The beam reflects off the walls following the law of reflection - There are three receivers (A, B, C) at different corners - We need to determine which receiver the laser w...
def test(): test_cases = [ (2, 1, 'C'), (3, 1, 'B'), (3, 2, 'A'), (3, 3, 'B'), (4, 1, 'C'), (4, 2, 'C'), (4, 3, 'C'), (4, 4, 'B'), (5, 1, 'B'), (5, 2, 'A'), ] for i, (x, y, expected_output) in enumerate(test_cases): try...
def solution(x: int, y: int) -> str: """ Determine the first laser receiver encountered by the laser in the square area Parameters: x (int): The length of x. y (int): The length of y. Returns: str: The identifier of the first laser receiver encountered by the laser. ('A', 'B', ...
{ "Common Sense": null, "Data Structures": [ "Path" ], "Dynamic Patterns": [ "Zigzag", "Mirror Reflection" ], "Geometric Objects": [ "Point", "Arrow", "Square", "Line Segment", "Line" ], "Mathematical Operations": null, "Spatial Transformations": null, "Topological Re...
Validation
q21-2
from math import gcd def solution(x: int, y: int) -> str: """ Determine the first laser receiver encountered by the laser in the square area Parameters: x (int): The length of x. y (int): The length of y. Returns: str: The identifier of the first laser receiver encountered by ...
# Problem Description This is a laser path prediction problem in a square grid where: - A laser emitter shoots a beam from the top-left corner - The beam reflects off the walls following the law of reflection - There are three receivers (A, B, C) at different corners - We need to determine which receiver the laser will...
def test(): test_cases = [ (2, 1, 'C'), (3, 1, 'A'), (3, 2, 'B'), (3, 3, 'A'), (4, 1, 'C'), (4, 2, 'C'), (4, 3, 'C'), (4, 4, 'A'), (5, 1, 'A'), (5, 2, 'B'), ] for i, (x, y, expected_output) in enumerate(test_cases): try...
def solution(x: int, y: int) -> str: """ Determine the first laser receiver encountered by the laser in the square area Parameters: x (int): The length of x. y (int): The length of y. Returns: str: The identifier of the first laser receiver encountered by the laser. ('A', 'B', ...
{ "Common Sense": null, "Data Structures": [ "Path" ], "Dynamic Patterns": [ "Zigzag", "Mirror Reflection" ], "Geometric Objects": [ "Point", "Arrow", "Square", "Line Segment", "Line" ], "Mathematical Operations": null, "Spatial Transformations": null, "Topological Re...
Validation
q22
def solution(numbers: list[int]) -> int: """ Based on the visual examples provided, calculate the total distance required to perform the operations Input: - numbers: A list of integers representing a sequence of numbers. (len(numbers) >= 1) Output: - An integer representing the total distance ...
# Problem Description This is a card stacking problem where we need to: 1. Take a sequence of numbered cards arranged horizontally 2. Stack them vertically in descending order (largest number on top) 3. Calculate the total "distance" cost of all moves required to achieve this arrangement 4. Each move involves taking a ...
def test(): test_cases = [ ([2, 3, 1, 4], 5), ([1, 2, 3, 4], 3), ([4, 3, 2, 1], 3), ([3, 1, 4, 2], 7), ([1], 0), ([2, 1], 1), ([15, 2, 9, 5, 13, 6, 7, 12, 1, 4, 3, 10, 11, 14, 8], 86), ([5, 3, 2, 1, 4, 6], 14), ([15, 2, 9, 5, 4, 6, 7, 12, 1, 13...
def solution(numbers: list[int]) -> int: """ Based on the visual examples provided, calculate the total distance required to perform the operations Input: - numbers: A list of integers representing a sequence of numbers. (len(numbers) >= 1) Output: - An integer representing the total distance ...
{ "Common Sense": null, "Data Structures": [ "Sequence" ], "Dynamic Patterns": null, "Geometric Objects": null, "Mathematical Operations": [ "Sorting", "Value Comparison" ], "Spatial Transformations": [ "Translation", "Stacking" ], "Topological Relations": [ "Adjacency" ] }
Iterative Calculation
q22-2
def solution(cards: list[int]) -> int: """ Based on the visual examples provided, calculate the total effort required to sequentially stack the given cards. Input: - cards: A list of integers representing a sequence of cards. (len(cards) >= 1) Output: - An integer representing the total effort...
# Problem Description This problem involves stacking a sequence of numbered cards in descending order (largest number on top) from a given horizontal arrangement. The goal is to calculate the total effort required to achieve this vertical stack. The effort is calculated based on the distance moved and the weight of the...
def test(): test_cases = [ ([2, 3, 1, 4], 10), ([1, 2, 3, 4], 6), ([4, 3, 2, 1], 6), ([3, 1, 4, 2], 14), ([1], 0), ([2, 1], 1), ([15, 2, 9, 5, 13, 6, 7, 12, 1, 4, 3, 10, 11, 14, 8], 701), ([5, 3, 2, 1, 4, 6], 53), ([15, 2, 9, 5, 4, 6, 7, 12, 1,...
def solution(cards: list[int]) -> int: """ Based on the visual examples provided, calculate the total effort required to sequentially stack the given cards. Input: - cards: A list of integers representing a sequence of cards. (len(cards) >= 1) Output: - An integer representing the total effort...
{ "Common Sense": null, "Data Structures": [ "Sequence" ], "Dynamic Patterns": null, "Geometric Objects": null, "Mathematical Operations": [ "Sorting", "Value Comparison" ], "Spatial Transformations": [ "Translation", "Stacking" ], "Topological Relations": [ "Adjacency" ] }
Iterative Calculation
q22-3
def solution(cards: list[int]) -> int: """ Based on the visual examples provided, calculate the total distance required to sequentially stack the given cards. Input: - cards: A list of integers representing a sequence of cards. (len(cards) >= 1) Output: - An integer representing the total dist...
# Problem Description This is a card stacking problem where we need to: 1. Take a sequence of numbered cards arranged horizontally 2. Stack them vertically in ascending order (smallest number on top) 3. Calculate the total "distance" cost of all moves required to achieve this arrangement 4. Each move involves taking a ...
def test(): test_cases = [ ([2, 3, 1, 4], 4), ([1, 2, 3, 4], 6), ([4, 3, 2, 1], 6), ([3, 1, 4, 2], 4), ([1], 0), ([2, 1], 1), ([15, 2, 9, 5, 13, 6, 7, 12, 1, 4, 3, 10, 11, 14, 8], 57), ([5, 3, 2, 1, 4, 6], 9), ([15, 2, 9, 5, 4, 6, 7, 12, 1, 13,...
def solution(cards: list[int]) -> int: """ Based on the visual examples provided, calculate the total distance required to sequentially stack the given cards. Input: - cards: A list of integers representing a sequence of cards. (len(cards) >= 1) Output: - An integer representing the total dist...
{ "Common Sense": null, "Data Structures": [ "Sequence" ], "Dynamic Patterns": null, "Geometric Objects": null, "Mathematical Operations": [ "Sorting", "Value Comparison" ], "Spatial Transformations": [ "Translation", "Stacking" ], "Topological Relations": [ "Adjacency" ] }
Iterative Calculation
q23
from typing import List def solution(commands: List[str]) -> List[List[int]]: """ Given a series of commands, transform the color of a matrix according to the rules shown in the image. Input: - command: A list of strings, where each string is a command that modifies the matrix. For exam...
# Problem Description This is a matrix transformation problem where: - We have a 3x3 matrix initially filled with white cells (represented as 1) - Commands are given as letters corresponding to rows (D,E,F) or columns (A,B,C) - Each command transforms the matrix according to specific rules - The output should represent...
def test(): test_cases = [ { 'input': ['B'], 'expected': [[1, 0, 1], [1, 0, 1], [1, 0, 1]] }, { 'input': ['E'], 'expected': [[1, 1, 1], [0, 0, 0], [1, 1, 1]] }, { 'input': ['A'], 'expected': [[0, 1, 1], [...
from typing import List def solution(commands: List[str]) -> List[List[int]]: """ Given a series of commands, transform the color of a matrix according to the rules shown in the image. Input: - command: A list of strings, where each string is a command that modifies the matrix. For exam...
{ "Common Sense": null, "Data Structures": [ "Matrix" ], "Dynamic Patterns": null, "Geometric Objects": [ "Grid" ], "Mathematical Operations": [ "Logical Operations" ], "Spatial Transformations": [ "Mapping" ], "Topological Relations": [ "Adjacency" ] }
Iterative Calculation
q23-2
from typing import List def solution(commands: List[str], matrix: List[List[int]]) -> List[List[int]]: """ Given a series of commands, transform the numbers of a matrix according to the rules shown in the image. Input: - command: A list of strings, where each string is a command that modifies the matr...
# Problem Description This is a matrix transformation problem where: - We have a 3x3 matrix with initial numbers - Commands are given as letters corresponding to rows (D,E,F) or columns (A,B,C) - Each command rearranges numbers within the specified row or column - The goal is to transform the matrix according to the ru...
def test(): test_cases = [ { 'commands': ['B'], 'matrix': [[7, 1, 8],[1, 1, 3],[7, 5, 9]], 'expected': [[7, 1, 8], [1, 1, 3], [7, 5, 9]] }, { 'commands': ['E'], 'matrix': [[3, 7, 2],[6, 9, 7],[4, 7, 8]], 'expected': [[3,...
from typing import List def solution(commands: List[str], matrix: List[List[int]]) -> List[List[int]]: """ Given a series of commands, transform the numbers of a matrix according to the rules shown in the image. Input: - command: A list of strings, where each string is a command that modifies the matr...
{ "Common Sense": null, "Data Structures": [ "Matrix" ], "Dynamic Patterns": null, "Geometric Objects": [ "Grid" ], "Mathematical Operations": [ "Value Comparison", "Sorting" ], "Spatial Transformations": [ "Shifting" ], "Topological Relations": [ "Adjacency" ] }
Iterative Calculation
q23-3
from typing import List def solution(commands: List[str], matrix: List[List[int]]) -> List[List[int]]: """ Given a series of commands, transform the numbers of a matrix according to the rules shown in the image. Input: - command: A list of strings, where each string is a command that modifies the matr...
# Problem Description This is a matrix transformation problem where: - We have a 3x3 matrix with initial numbers - Commands are given as letters corresponding to rows (D,E,F) or columns (A,B,C) - Each command negates (multiplies by -1) the numbers in the specified row or column - The goal is to calculate the final stat...
def test(): test_cases = [ { 'commands': ['B'], 'matrix': [[7, 1, 8],[1, 1, 3],[7, 5, 9]], 'expected': [[7, -1, 8], [1, -1, 3], [7, -5, 9]] }, { 'commands': ['E'], 'matrix': [[3, 7, 2],[6, 9, 7],[4, 7, 8]], 'expected': [...
from typing import List def solution(commands: List[str], matrix: List[List[int]]) -> List[List[int]]: """ Given a series of commands, transform the numbers of a matrix according to the rules shown in the image. Input: - command: A list of strings, where each string is a command that modifies the matr...
{ "Common Sense": null, "Data Structures": [ "Matrix" ], "Dynamic Patterns": null, "Geometric Objects": [ "Grid" ], "Mathematical Operations": [ "Basic Arithmetic" ], "Spatial Transformations": null, "Topological Relations": [ "Adjacency" ] }
Iterative Calculation
q24
from typing import List def solution(arrangement: List[List[int]]) -> bool: """ Determine whether the arrangement of the given puzzle pieces is valid. Input: - arrangement: A 2D list of integers, where each element represents the rotation angle for the corresponding puzzle piece. Possible angle...
# Problem Description This is a puzzle validation problem where we need to determine if a given arrangement of puzzle pieces is valid. Each piece: - Has a rotation angle (0°, 90°, 180°, or -90°) - Has sides with either protrusions or indents - Must properly connect with adjacent pieces (protrusion must match with inden...
def test(): test_cases = [ ([[-90, 0], [180, 90]], True), ([[0, 90, 90]], True), ([[90,90,90]], True), ([[180, 90, 90]], True), ([[0, 90, 90, 90, 90]], True), ([[90, 90, 90, 90, 90]], True), ([[180, 90, 90, 90, 90]], True), ([[0], [90], [180]], True), ...
from typing import List def solution(arrangement: List[List[int]]) -> bool: """ Determine whether the arrangement of the given puzzle pieces is valid. Input: - arrangement: A 2D list of integers, where each element represents the rotation angle for the corresponding puzzle piece. Possible angle...
{ "Common Sense": [ "Puzzle" ], "Data Structures": null, "Dynamic Patterns": [ "Circular Motion" ], "Geometric Objects": [ "Angle" ], "Mathematical Operations": null, "Spatial Transformations": [ "Rotation" ], "Topological Relations": [ "Adjacency", "Connection" ] }
Validation
q24-2
from typing import List def solution(arrangement: List[List[int]]) -> bool: """ Determine whether the arrangement of the given puzzle pieces is valid. Input: - arrangement: A 2D list of integers, where each element represents the rotation angle for the corresponding puzzle piece. Possible angle...
# Problem Description This is a puzzle piece validation problem where we need to check if a given arrangement of rotated puzzle pieces forms a valid configuration. Each puzzle piece: - Has a rotation angle (0°, 90°, 180°, or -90°) - Contains protrusions and indents on its edges - Must properly connect with adjacent pie...
def test(): test_cases = [ ([[-90, 0], [180, 90]], False), ([[0, 90], [-90, 180]], True), ([[90, 180, 180]], True), ([[180, 180, 180]], True), ([[-90, 180, 180]], True), ([[90, 180, 180, 180, 180]], True), ([[180, 180, 180, 180]], True), ([[-90, 180, 1...
from typing import List def solution(arrangement: List[List[int]]) -> bool: """ Determine whether the arrangement of the given puzzle pieces is valid. Input: - arrangement: A 2D list of integers, where each element represents the rotation angle for the corresponding puzzle piece. Possible angle...
{ "Common Sense": [ "Puzzle" ], "Data Structures": null, "Dynamic Patterns": [ "Circular Motion" ], "Geometric Objects": [ "Angle" ], "Mathematical Operations": null, "Spatial Transformations": [ "Rotation" ], "Topological Relations": [ "Adjacency", "Connection" ] }
Validation
q24-3
from typing import List def solution(arrangement: List[List[int]]) -> bool: """ Determine whether the arrangement of the given puzzle pieces is valid. Input: - arrangement: A 2D list of integers, where each element represents the rotation angle for the corresponding puzzle piece. Possible angle...
# Problem Description This is a puzzle validation problem where we need to check if a given arrangement of puzzle pieces forms a valid configuration. Each piece: - Has a numerical label representing its rotation (0°, 90°, 180°, or -90°) - Contains interlocking edges (protrusions and indents) - Must properly connect wit...
def test(): test_cases = [ ([[0, 0], [90, 90]], True), ([[0, 0], [0, 0]], True), ([[0, 0, 0]], True), ([[0, -90, -90]], True), ([[0, -90, 0, -90, 0]], True), ([[-90, -90, -90, -90, -90]], True), ([[180, 90, 90, 90, 90]], True), ([[0], [90], [0]], True)...
from typing import List def solution(arrangement: List[List[int]]) -> bool: """ Determine whether the arrangement of the given puzzle pieces is valid. Input: - arrangement: A 2D list of integers, where each element represents the rotation angle for the corresponding puzzle piece. Possible angle...
{ "Common Sense": [ "Puzzle" ], "Data Structures": null, "Dynamic Patterns": [ "Circular Motion" ], "Geometric Objects": [ "Angle" ], "Mathematical Operations": null, "Spatial Transformations": [ "Rotation" ], "Topological Relations": [ "Adjacency", "Connection" ] }
Validation
q25
from typing import Dict, List, Tuple def solution(rectangles: Dict[int, List[Tuple[int, int]]], rectangle_id: int) -> int: """ Calculate the trimmed area of a specified rectangle within a grid. Args: rectangles: A dictionary mapping rectangle IDs (int) to their corner coordinates. ...
# Problem Description: - The problem involves a 3x7 grid containing rectangles that may overlap. Each rectangle has an associated priority. Higher-priority rectangles take precedence over lower-priority rectangles, and the overlapping regions are "trimmed" such that only the highest-priority rectangle occupies the over...
def test(): test_cases = [ ({1: [(0, 1), (3, 3)], 2: [(0, 0), (4, 2)], 3: [(3, 1), (5, 3)], 4: [(4, 0), (7, 2)]}, 1, 6), ({1: [(0, 1), (3, 3)], 2: [(0, 0), (4, 2)], 3: [(3, 1), (5, 3)], 4: [(4, 0), (7, 2)]}, 2, 5), ({1: [(0, 1), (3, 3)], 2: [(0, 0), (4, 2)], 3: [(3, 1), (5, 3)], 4: [(4, 0), ...
from typing import Dict, List, Tuple def solution(rectangles: Dict[int, List[Tuple[int, int]]], rectangle_id: int) -> int: """ Calculate the trimmed area of a specified rectangle within a grid. Args: rectangles: A dictionary mapping rectangle IDs (int) to their corner coordinates. ...
{ "Common Sense": null, "Data Structures": [ "Matrix" ], "Dynamic Patterns": null, "Geometric Objects": [ "Rectangle", "Grid" ], "Mathematical Operations": [ "Value Comparison" ], "Spatial Transformations": [ "Truncation", "Filtering" ], "Topological Relations": [ "Over...
Aggregation
q25-2
from typing import Dict, List, Tuple def solution(rectangles: Dict[int, List[Tuple[int, int]]], rectangle_id: int) -> int: """ Calculate the trimmed area of a specified rectangle within a grid. Args: rectangles: A dictionary mapping rectangle IDs (int) to their corner coordinates. ...
# Problem Description: - The problem involves a grid containing rectangles that may overlap. Each rectangle has an associated priority. Higher-priority rectangles take precedence over lower-priority rectangles, and the overlapping regions are "trimmed" such that only the highest-priority rectangle occupies the overlapp...
def test(): test_cases = [ ({1: [(0, 1), (3, 3)], 2: [(0, 0), (4, 2)], 3: [(3, 1), (5, 3)], 4: [(4, 0), (7, 2)]}, 1, 3), ({1: [(0, 1), (3, 3)], 2: [(0, 0), (4, 2)], 3: [(3, 1), (5, 3)], 4: [(4, 0), (7, 2)]}, 2, 7), ({1: [(0, 1), (3, 3)], 2: [(0, 0), (4, 2)], 3: [(3, 1), (5, 3)], 4: [(4, 0), ...
from typing import Dict, List, Tuple def solution(rectangles: Dict[int, List[Tuple[int, int]]], rectangle_id: int) -> int: """ Calculate the trimmed area of a specified rectangle within a grid. Args: rectangles: A dictionary mapping rectangle IDs (int) to their corner coordinates. ...
{ "Common Sense": null, "Data Structures": [ "Matrix" ], "Dynamic Patterns": null, "Geometric Objects": [ "Rectangle", "Grid" ], "Mathematical Operations": [ "Value Comparison" ], "Spatial Transformations": [ "Truncation", "Filtering" ], "Topological Relations": [ "Over...
Aggregation
q26
from typing import List def solution(rules: List[List[str]], matrix: List[List[int]]) -> bool: """ Validates whether a given matrix satisfies the specified rules. Args: rules: A 2D list of strings containing 'E' or 'N', representing equality/inequality constraints matrix: A 2D list of inte...
# Problem Description - The task involves validating a 2D matrix (matrix) with specific rules (rules). The rules matrix contains two types of constraints: E: Denotes that the elements must be equal in the matrix. N: Denotes that the elements must be not equal in the matrix. - The goal is to check whether the ma...
def test(): # Test case 1 relations = [ ['E'], ['N', 'N'], ['E'] ] filled_matrix = [ [1, 1], [2, 2] ] try: result = solution(relations, filled_matrix) except Exception as e: error_message = ( f"An exception occurred while ru...
from typing import List def solution(rules: List[List[str]], matrix: List[List[int]]) -> bool: """ Validates whether a given matrix satisfies the specified rules. Args: rules: A 2D list of strings containing 'E' or 'N', representing equality/inequality constraints matrix: A 2D list of inte...
{ "Common Sense": null, "Data Structures": [ "Matrix" ], "Dynamic Patterns": null, "Geometric Objects": null, "Mathematical Operations": [ "Value Comparison", "Logical Operations" ], "Spatial Transformations": null, "Topological Relations": [ "Adjacency" ] }
Validation
q26-2
from typing import List def solution(rules: List[List[str]], matrix: List[List[int]]) -> bool: """ Validates whether a given matrix satisfies the specified rules. Args: rules: A 2D list of strings containing 'G' or 'L', representing greater/less constraints matrix: A 2D list of integers to...
# Problem Description The task involves validating a 2D matrix (`matrix`) against a set of rules (`rules`). The rules matrix contains two types of constraints: - 'G': Denotes that the element in the matrix must be greater than its adjacent element. - 'L': Denotes that the element in the matrix must be less than its adj...
def test(): # Test case 1 relations = [ ['G'], ['L', 'L'], ['G'] ] filled_matrix = [ [2, 1], [3, 2] ] try: output = solution(relations, filled_matrix) except Exception as e: error_message = ( f"An exception occurred while ru...
from typing import List def solution(rules: List[List[str]], matrix: List[List[int]]) -> bool: """ Validates whether a given matrix satisfies the specified rules. Args: rules: A 2D list of strings containing 'G' or 'L', representing greater/less constraints matrix: A 2D list of integers to...
{ "Common Sense": null, "Data Structures": [ "Matrix" ], "Dynamic Patterns": null, "Geometric Objects": null, "Mathematical Operations": [ "Value Comparison", "Logical Operations" ], "Spatial Transformations": null, "Topological Relations": [ "Adjacency" ] }
Validation
q27
from typing import Tuple def solution(n: int, initial_point: Tuple[int, int], day: int) -> int: """ Calculate the area of the blue region. Args: n: The size of the n x n grid. initial_point: A tuple (x, y) representing the starting coordinates of the blue region (1-indexed). day: T...
# Problem Description This is a grid infection spread simulation problem. Given an n×n grid with an initial infection point, we need to calculate how many cells will be infected at the given `day`. The infection spreads to adjacent cells (up, down, left, right) each day, but cannot spread beyond the grid boundaries. #...
def test(): test_cases = [ (6, (3, 5), 1, 1), (6, (3, 5), 3, 12), (6, (3, 5), 4, 20), (9, (3, 8), 3, 12), (3, (2, 2), 3, 9), (6, (1, 6), 6, 21), (6, (1, 6), 7, 26), (6, (6, 3), 4, 15), (6, (6, 3), 5, 21), ] for grid_size, initial_point,...
from typing import Tuple def solution(n: int, initial_point: Tuple[int, int], day: int) -> int: """ Calculate the area of the blue region. Args: n: The size of the n x n grid. initial_point: A tuple (x, y) representing the starting coordinates of the blue region (1-indexed). day: T...
{ "Common Sense": null, "Data Structures": [ "Matrix" ], "Dynamic Patterns": [ "Exponential Increment", "Cross Pattern", "Propagation" ], "Geometric Objects": [ "Coordinate System", "Grid", "Square" ], "Mathematical Operations": [ "Counting" ], "Spatial Transformation...
Expansion
q27-2
from typing import Tuple def solution(n: int, initial_point: Tuple[int, int], t: int) -> int: """ Calculate the number of infected cells after t days. Input: - n: An integer representing the size of the grid (n x n). - initial_point: A tuple (x, y) representing the coordinates of the initial infec...
# Problem Description This is a grid infection spread simulation problem. Given an n×n grid with an initial infection point, we need to calculate how many cells will be infected after t days. The infection spreads following a specific diagonal pattern, unlike traditional adjacent cell spreading. # Visual Facts 1. The ...
def test(): test_cases = [ (6, (3, 5), 0, 1), (6, (3, 5), 2, 10), (6, (3, 5), 3, 15), (9, (3, 8), 2, 10), (3, (2, 2), 2, 5), (6, (1, 6), 5, 18), (6, (1, 6), 6, 18), (6, (6, 3), 3, 12), (6, (6, 3), 4, 15), ] for n, initial_point, t, exp...
from typing import Tuple def solution(n: int, initial_point: Tuple[int, int], t: int) -> int: """ Calculate the number of infected cells after t days. Input: - n: An integer representing the size of the grid (n x n). - initial_point: A tuple (x, y) representing the coordinates of the initial infec...
{ "Common Sense": null, "Data Structures": [ "Matrix" ], "Dynamic Patterns": [ "Exponential Increment", "Cross Pattern", "Propagation" ], "Geometric Objects": [ "Coordinate System", "Grid", "Square" ], "Mathematical Operations": [ "Counting" ], "Spatial Transformation...
Expansion
q27-3
from typing import Tuple def solution(n: int, initial_point: Tuple[int, int], t: int) -> int: """ Calculate the number of infected cells after t days. Input: - n: An integer representing the size of the grid (n x n). - initial_point: A tuple (x, y) representing the coordinates of the initial infec...
# Problem Description This is a cellular infection spread simulation on an n×n grid. Given an initial infection point, we need to calculate the total number of infected cells after t days. The infection spreads following a specific pattern with three states: healthy, latent, and infected. This is more complex than a si...
def test(): test_cases = [ (6, (3, 5), 0, 1), (6, (3, 5), 2, 5), (6, (3, 5), 3, 5), (9, (3, 8), 2, 5), (3, (2, 2), 2, 5), (6, (1, 6), 5, 6), (6, (1, 6), 6, 10), (6, (6, 3), 3, 4), (6, (6, 3), 4, 9), ] for n, initial_point, t, expected_o...
from typing import Tuple def solution(n: int, initial_point: Tuple[int, int], t: int) -> int: """ Calculate the number of infected cells after t days. Input: - n: An integer representing the size of the grid (n x n). - initial_point: A tuple (x, y) representing the coordinates of the initial infec...
{ "Common Sense": null, "Data Structures": [ "Matrix" ], "Dynamic Patterns": [ "Exponential Increment", "Cross Pattern", "Propagation" ], "Geometric Objects": [ "Coordinate System", "Grid", "Square" ], "Mathematical Operations": [ "Counting" ], "Spatial Transformation...
Expansion
q28
from typing import List def solution(terrain: List[int]) -> int: """ Determine the index of the terrain block where pouring water would result in the most area being covered with water. The water will quickly seep into the terrain block and will not accumulate between the blocks. Input: - terrain...
# Problem Description This is a terrain water flow optimization problem where: - We have a series of terrain blocks of different heights - Water can be poured at any block - Water flows to adjacent blocks if they are at the same height or lower - Water seeps into blocks (doesn't accumulate) - Goal: Find the optimal pou...
def test(): test_cases = [ ([3, 1, 2, 3, 3, 2, 4], [3, 4]), ([1, 2, 3, 4], 3), ([3, 2, 1, 1, 1], 0), ([1, 3, 3, 5, 3, 5, 9, 5, 1, 3, 6, 8, 6, 4, 2, 7, 9, 6, 4, 2, 8, 2, 3, 4, 5, 1, 7, 1], 11), ([1, 3, 3, 5, 9, 5, 1, 3, 6, 8, 6, 4, 2, 3, 4, 5, 1, 7, 1], 4), ([2, 5, 3, ...
from typing import List def solution(terrain: List[int]) -> int: """ Determine the index of the terrain block where pouring water would result in the most area being covered with water. The water will quickly seep into the terrain block and will not accumulate between the blocks. Input: - terrain...
{ "Common Sense": [ "Flow of Water" ], "Data Structures": null, "Dynamic Patterns": [ "Propagation" ], "Geometric Objects": [ "Rectangle" ], "Mathematical Operations": [ "Value Comparison" ], "Spatial Transformations": null, "Topological Relations": [ "Adjacency", "Boundary...
Direct Calculation
q29
from typing import List, Tuple def solution(n: int, chain: List[Tuple[int, int]], top_left: Tuple[int, int], bottom_right: Tuple[int, int]) -> int: """ Given a chain and a yellow region in an n x n 2D matrix, find the number of red regions that are formed. Parameters: n (int): The size of the matr...
# Problem Description This is a geometric problem involving a grid, a polyline (chain), and a rectangular region. The task is to count the number of intersections (red regions) where the polyline crosses the boundary of a specified rectangular yellow region. The polyline consists of connected line segments that move ho...
def test(): test_cases = [ (2, [(0, 0), (0, 1), (1, 1), (1, 0)], (1, 0), (1, 1), 1), (2, [(0, 0), (0, 1), (1, 1), (1, 0)], (1, 1), (1, 1), 2), (2, [(0, 0), (0, 1), (1, 1), (1, 0)], (1, 1), (1, 1), 2), (2, [(0, 0), (0, 1), (1, 0)], (1, 1), (1, 1), 0), (3, [(0, 0), (0, 1), (1, ...
from typing import List, Tuple def solution(n: int, chain: List[Tuple[int, int]], top_left: Tuple[int, int], bottom_right: Tuple[int, int]) -> int: """ Given a chain and a yellow region in an n x n 2D matrix, find the number of red regions that are formed. Parameters: n (int): The size of the matr...
{ "Common Sense": null, "Data Structures": [ "Path" ], "Dynamic Patterns": null, "Geometric Objects": [ "Line Segment", "Grid", "Point", "Coordinate System", "Rectangle" ], "Mathematical Operations": [ "Counting" ], "Spatial Transformations": null, "Topological Relations"...
Aggregation
q29-2
from typing import List, Tuple def solution(n: int, chain: List[Tuple[int, int]], top_left: Tuple[int, int], bottom_right: Tuple[int, int]) -> Tuple[int, int]: """ Given a chain and a yellow region in an n x n 2D matrix, find the number of red regions and green regions that are formed. Parameters: ...
# Problem Description This is a geometric problem that involves analyzing intersections between a polyline (chain) and a rectangular region on a grid. The goal is to count two types of intersections: 1. Red regions: where the polyline crosses the yellow rectangle's boundary vertically 2. Green regions: where the polyli...
def test(): test_cases = [ (2, [(0, 0), (0, 1), (1, 1), (1, 0)], (1, 0), (1, 1), (0, 1)), (2, [(0, 0), (0, 1), (1, 1), (1, 0)], (1, 1), (1, 1), (1, 1)), (2, [(0, 0), (0, 1), (1, 0)], (1, 1), (1, 1), (0, 0)), (3, [(0, 0), (0, 1), (1, 1), (1, 0), (2, 0), (2, 2), (1, 2), (1, 1)], (1, 0)...
from typing import List, Tuple def solution(n: int, chain: List[Tuple[int, int]], top_left: Tuple[int, int], bottom_right: Tuple[int, int]) -> Tuple[int, int]: """ Given a chain and a yellow region in an n x n 2D matrix, find the number of red regions and green regions that are formed. Parameters: ...
{ "Common Sense": null, "Data Structures": [ "Path" ], "Dynamic Patterns": null, "Geometric Objects": [ "Line Segment", "Grid", "Point", "Coordinate System", "Rectangle" ], "Mathematical Operations": [ "Counting" ], "Spatial Transformations": null, "Topological Relations"...
Aggregation
q3
def solution(start: str, end: str) -> list[str]: """ Find the shortest path from one point to another Parameters: start (str): The starting node of the path. end (str): The ending node of the path. Returns: Optional[List[str]]: A list of nodes representing the path from start t...
# Problem Description This is a shortest path finding problem in a directed graph where: - We need to find the shortest path between two given nodes in the graph - The path must follow the direction of the arrows - The input nodes are represented as single letters - We need to return the complete path as a list of node...
def test(): test_cases = [ ('A', 'B', ['A', 'B']), ('C', 'E', ['C', 'A', 'B', 'E']), ('A', 'E', ['A', 'B', 'E']), ('B', 'D', ['B', 'D']), ('C', 'B', ['C', 'A', 'B']), ('C', 'D', ['C', 'D']), ('B', 'E', ['B', 'E']) ] for start, end, expected_output in ...
def solution(start: str, end: str) -> list[str]: """ Find the shortest path from one point to another Parameters: start (str): The starting node of the path. end (str): The ending node of the path. Returns: Optional[List[str]]: A list of nodes representing the path from start t...
{ "Common Sense": null, "Data Structures": [ "Directed Graph", "Path" ], "Dynamic Patterns": null, "Geometric Objects": [ "Circle", "Arrow" ], "Mathematical Operations": null, "Spatial Transformations": null, "Topological Relations": [ "Connectivity", "Adjacency", "Connecti...
Direct Calculation
q3-2
def solution(start: str, end: str) -> list[str]: """ Find the shortest path from one point to another Parameters: start (str): The starting node of the path. end (str): The ending node of the path. Returns: Optional[List[str]]: A list of nodes representing the path from start t...
# Problem Description This is a shortest path finding problem in an undirected graph. The task is to implement a function that finds the shortest path between two nodes in the graph, given start and end nodes. The function should return the sequence of nodes that represents the shortest path from start to end. # Visua...
def test(): test_cases = [ ('A', 'B', ['A', 'B']), ('A', 'E', ['A', 'B', 'E']), ('B', 'D', ['B', 'D']), ('C', 'D', ['C', 'D']), ('B', 'E', ['B', 'E']) ] for start, end, expected_output in test_cases: try: output = solution(start, end) ...
def solution(start: str, end: str) -> list[str]: """ Find the shortest path from one point to another Parameters: start (str): The starting node of the path. end (str): The ending node of the path. Returns: Optional[List[str]]: A list of nodes representing the path from start t...
{ "Common Sense": null, "Data Structures": [ "Undirected Graph", "Path" ], "Dynamic Patterns": null, "Geometric Objects": [ "Circle", "Arrow" ], "Mathematical Operations": null, "Spatial Transformations": null, "Topological Relations": [ "Connectivity", "Adjacency", "Connec...
Direct Calculation
q3-3
def solution(start: str, end: str) -> list[str]: """ Find the shortest path from one point to another Parameters: start (str): The starting node of the path. end (str): The ending node of the path. Returns: Optional[List[str]]: A list of nodes representing the path from start t...
# Problem Description This is a shortest path finding problem in a directed graph. The task is to implement a function that finds the shortest path between two given nodes in a directed graph. The function should return the sequence of nodes that represents the shortest path from the start node to the end node. # Visu...
def test(): test_cases = [ ('A', 'B', ['A', 'B']), ('E', 'C', ['E', 'D', 'C']), ('E', 'A', ['E', 'D', 'C', 'A']), ('B', 'D', ['B', 'D']), ('C', 'B', ['C', 'A', 'B']), ('C', 'D', ['C', 'A', 'B', 'D']), ('E', 'B', ['E', 'B']) ] for start, end, expec...
def solution(start: str, end: str) -> list[str]: """ Find the shortest path from one point to another Parameters: start (str): The starting node of the path. end (str): The ending node of the path. Returns: Optional[List[str]]: A list of nodes representing the path from start t...
{ "Common Sense": null, "Data Structures": [ "Directed Graph", "Path" ], "Dynamic Patterns": null, "Geometric Objects": [ "Circle", "Arrow" ], "Mathematical Operations": null, "Spatial Transformations": null, "Topological Relations": [ "Connectivity", "Adjacency", "Connecti...
Direct Calculation
q30
from typing import Optional class TreeNode: """ This class represents a node in a tree. Each node contains a value and a list of children. """ def __init__(self, value: int, children=[None, None]): self.value = value self.children = children def is_mirror(left: Optional[TreeNode], rig...
# Problem Description This is a binary tree classification problem where we need to determine if a given binary tree belongs to Type 1 or Type 2. The main task is to determine if a binary tree has mirror symmetry - where the left subtree is a mirror reflection of the right subtree. Type 1 represents symmetrical trees, ...
def tree_to_string(node: TreeNode, level: int = 0) -> str: """Helper function to convert a tree to a readable string format""" if node is None: return "None" indent = " " * level result = f"TreeNode({node.value}" if node.children: result += ", [\n" child_strings = ...
from typing import List class TreeNode: """ This class represents a node in a tree. Each node contains a value and a list of children. """ def __init__(self, value: int, children=[None, None]): self.value = value self.children = children # contains the left and right children, or empty ...
{ "Common Sense": null, "Data Structures": [ "Binary Tree" ], "Dynamic Patterns": [ "Mirror Symmetry" ], "Geometric Objects": null, "Mathematical Operations": [ "Value Comparison" ], "Spatial Transformations": null, "Topological Relations": [ "Connectivity" ] }
Validation
q30-2
from typing import List class TreeNode: """ This class represents a node in a tree. Each node contains a value and a list of children. """ def __init__(self, value: int, children=[None, None]): self.value = value self.children = children def are_identical(left: TreeNode, right: TreeNod...
# Problem Description This is a binary tree classification problem where we need to determine if a given binary tree belongs to Type 1 or Type 2. The main task is to determine if a binary tree follows a special pattern where the left subtree is exactly identical (same structure and values) to the right subtree. Type 1 ...
def print_tree(node: TreeNode, level=0, prefix="Root: "): """Helper function to create a string representation of the tree""" if node is None: return prefix + "None\n" result = prefix + str(node.value) + "\n" for i, child in enumerate(node.children): if child: result += ...
from typing import List class TreeNode: """ This class represents a node in a tree. Each node contains a value and a list of children. """ def __init__(self, value: int, children=[None, None]): self.value = value self.children = children # contains the left and right children, or empty ...
{ "Common Sense": null, "Data Structures": [ "Binary Tree" ], "Dynamic Patterns": [ "Mirror Symmetry" ], "Geometric Objects": null, "Mathematical Operations": [ "Value Comparison" ], "Spatial Transformations": null, "Topological Relations": [ "Connectivity" ] }
Validation
q31
from typing import List def solution(cubes: List[List[int]]) -> int: """ Count the red squares from a specified view of the stacked cubes. Parameters: cubes (List[List[int]]): A 2D list where cubes[i][j] represents the number of cubes stacked at coordinate (i, j). (0-indexed) Returns: ...
# Problem Description - The task involves calculating the number of red squares visible from a given view of a 3D stack of cubes represented by a 2D grid. The red squares appear as the top-most cube among all the cubes. The function accepts a 2D grid cubes where each entry cubes[i][j] specifies the number of stacked cu...
def test(): cubes1 = [[2, 1, 3], [1, 2, 1]] cubes2 = [[2, 1, 3], [1, 0, 1]] cubes3 = [[2, 1, 3], [1, 1, 1]] cubes4 = [[1, 2], [3, 4]] cubes5 = [[1, 2], [3, 0], [5, 6]] cubes6 = [[1, 2], [3, 0], [5, 6], [0, 8]] cubes7 = [[1, 2], [3, 4], [5, 6], [7, 9], [9, 9]] cubes8 = [[0, 0], [0, 0], [...
from typing import List def solution(cubes: List[List[int]]) -> int: """ Count the red squares from a specified view of the stacked cubes. Parameters: cubes (List[List[int]]): A 2D list where cubes[i][j] represents the number of cubes stacked at coordinate (i, j). (0-indexed) Returns: ...
{ "Common Sense": null, "Data Structures": null, "Dynamic Patterns": [ "Layered Structure" ], "Geometric Objects": [ "Coordinate System", "Grid", "Square" ], "Mathematical Operations": null, "Spatial Transformations": [ "Stacking" ], "Topological Relations": [ "Adjacency" ]...
Aggregation
q31-2
from typing import List def solution(cubes: List[List[int]]) -> int: """ Count the red squares from a specified view of the stacked cubes. Parameters: cubes (List[List[int]]): A 2D list where cubes[i][j] represents the number of cubes stacked at coordinate (i, j). (0-indexed) Returns: ...
# Problem Description The task involves analyzing a 3D stack of cubes and determining how many "rightmost cubes" are visible when viewing the stack from the right side. The function `solution` accepts a 2D list `cubes` where `cubes[i][j]` represents the number of cubes stacked vertically at coordinate `(i, j)` on a 2D ...
def test(): cubes1 = [[2, 1, 3], [1, 2, 1]] cubes2 = [[2, 1, 3], [1, 0, 1]] cubes3 = [[2, 1, 3], [1, 1, 1]] cubes4 = [[1, 2], [3, 4]] cubes5 = [[1, 2], [3, 0], [5, 6]] cubes6 = [[1, 2], [3, 0], [5, 6], [0, 8]] cubes7 = [[1, 2], [3, 4], [5, 6], [7, 9], [9, 9]] cubes8 = [[0, 0], [0, 0], [0...
from typing import List def solution(cubes: List[List[int]]) -> int: """ Count the red squares from a specified view of the stacked cubes. Parameters: cubes (List[List[int]]): A 2D list where cubes[i][j] represents the number of cubes stacked at coordinate (i, j). (0-indexed) Returns: ...
{ "Common Sense": null, "Data Structures": null, "Dynamic Patterns": [ "Layered Structure" ], "Geometric Objects": [ "Coordinate System", "Grid", "Square" ], "Mathematical Operations": null, "Spatial Transformations": [ "Stacking" ], "Topological Relations": [ "Adjacency" ]...
Aggregation
q31-3
from typing import List def solution(cubes: List[List[int]]) -> int: """ Count the red squares from a specified view of the stacked cubes. Parameters: cubes (List[List[int]]): A 2D list where cubes[i][j] represents the number of cubes stacked at coordinate (i, j). (0-indexed) Returns: ...
# Problem Description The task involves analyzing a 3D stack of cubes and determining how many "front-most cubes" are visible when viewing the stack from the front side. The function `solution` accepts a 2D list `cubes` where `cubes[i][j]` represents the number of cubes stacked at coordinate `(i, j)` on a 2D grid. The ...
def test(): cubes1 = [[2, 1, 3], [1, 2, 1]] cubes2 = [[2, 1, 3], [1, 0, 1]] cubes3 = [[2, 1, 3], [1, 1, 1]] cubes4 = [[0, 2], [0, 4]] cubes5 = [[1, 2], [3, 0], [5, 6]] cubes6 = [[1, 2], [3, 0], [5, 6], [0, 8]] cubes7 = [[1, 2], [3, 4], [5, 6], [7, 9], [9, 9]] cubes8 = [[3, 1], [3], [2,...
from typing import List def solution(cubes: List[List[int]]) -> int: """ Count the red squares from a specified view of the stacked cubes. Parameters: cubes (List[List[int]]): A 2D list where cubes[i][j] represents the number of cubes stacked at coordinate (i, j). (0-indexed) Returns: ...
{ "Common Sense": null, "Data Structures": null, "Dynamic Patterns": [ "Layered Structure" ], "Geometric Objects": [ "Coordinate System", "Grid", "Square" ], "Mathematical Operations": null, "Spatial Transformations": [ "Stacking" ], "Topological Relations": [ "Adjacency" ]...
Aggregation
q32
def solution(n: int) -> int: """ Refer to the pattern in the figure, calculate the number of cells with the specified n. Args: n: integer in [1, 1000] Returns: int: The number of cells """ return n*(n+3)+1
# Problem Description - The problem involves calculating the total number of hexagonal cells in a specific pattern for a given value of n - Input n is an integer between 1 and 1000 - The pattern grows symmetrically from the center, forming an hourglass-like shape - Need to find a formula that gives the total count of h...
def test(): x = lambda x: x*(x+3)+1 test_cases = [ (1, x(1)), (2, x(2)), (3, x(3)), (8, x(8)), (10, x(10)), (20, x(20)), (21, x(21)), (50, x(50)), (100, x(100)), (1000, x(1000)) ] for input_n, expected_output in test_c...
def solution(n: int) -> int: """ Refer to the pattern in the figure, calculate the number of cells with the specified n. Args: n: integer in [1, 1000] Returns: int: The number of cells """
{ "Common Sense": null, "Data Structures": null, "Dynamic Patterns": [ "Layered Structure", "Mirror Symmetry", "Linear Increment" ], "Geometric Objects": [ "Hexagon", "Grid" ], "Mathematical Operations": null, "Spatial Transformations": [ "Scaling", "Stacking" ], "Topolog...
Expansion
q32-2
def solution(n: int) -> int: """ Refer to the pattern in the figure, calculate the number of cells with the specified n. Args: n: integer in [1, 1000] Returns: int: The number of cells """ return n*(n+3)+1
# Problem Description - The problem involves calculating the total number of hexagonal cells in a triangular-like pattern for a given value of n - Input n is an integer between 1 and 1000 - The pattern grows vertically, forming a triangular structure that expands both upward and downward - Need to find the total count ...
def test(): x = lambda x: x*(x+3)+1 test_cases = [ (1, x(1)), (2, x(2)), (3, x(3)), (8, x(8)), (10, x(10)), (20, x(20)), (21, x(21)), (50, x(50)), (100, x(100)), (1000, x(1000)) ] for n, expected_output in test_cases: ...
def solution(n: int) -> int: """ Refer to the pattern in the figure, calculate the number of cells with the specified n. Args: n: integer in [1, 1000] Returns: int: The number of cells """
{ "Common Sense": null, "Data Structures": null, "Dynamic Patterns": [ "Layered Structure", "Mirror Symmetry", "Linear Increment" ], "Geometric Objects": [ "Hexagon", "Grid" ], "Mathematical Operations": null, "Spatial Transformations": [ "Scaling", "Stacking" ], "Topolog...
Expansion
q32-3
def solution(n: int) -> int: """ Refer to the pattern in the figure, calculate the number of cells with the specified n. Args: n: integer in [1, 1000] Returns: int: The number of cells """ return n*(n+3)+1
# Problem Description - Calculate the total number of hexagonal cells in a specific pattern for a given value of n - Input n is an integer between 1 and 1000 - The pattern forms a symmetrical hourglass-like shape with hexagonal cells - Need to find a formula for counting total hexagons for any valid n # Visual Facts 1...
def test(): x = lambda x: x*(x+3)+1 test_cases = [ (1, x(1)), (2, x(2)), (3, x(3)), (8, x(8)), (10, x(10)), (20, x(20)), (21, x(21)), (50, x(50)), (100, x(100)), (1000, x(1000)) ] for n, expected_output in test_cases: ...
def solution(n: int) -> int: """ Refer to the pattern in the figure, calculate the number of cells with the specified n. Args: n: integer in [1, 1000] Returns: int: The number of cells """
{ "Common Sense": null, "Data Structures": null, "Dynamic Patterns": [ "Layered Structure", "Mirror Symmetry", "Linear Increment" ], "Geometric Objects": [ "Hexagon", "Grid" ], "Mathematical Operations": null, "Spatial Transformations": [ "Scaling", "Stacking" ], "Topolog...
Expansion
q33
from collections import deque class TreeNode: """ Represents a node in a tree. Each node contains an integer value and a list of child TreeNodes. Attributes: value (int): The integer value of the node. children (list): A list of child nodes (TreeNode objects). """ def __init__(...
# Problem Description The problem requires implementing a function that processes a binary tree and returns a sequence of node values based on specific rules. The function takes a root node of a tree as input and should return a list of integers representing the "rightmost" nodes in the tree, following certain patterns...
def print_tree(node, level=0, prefix="Root: "): """Helper function to create a string representation of the tree""" if not node: return "" ret = " " * level + prefix + str(node.value) + "\n" for i, child in enumerate(node.children): ret += print_tree(child, level + 1, f"Child {i}: ...
class TreeNode: """ Represents a node in a tree. Each node contains an integer value and a list of child TreeNodes. Attributes: value (int): The integer value of the node. children (list): A list of child nodes (TreeNode objects). """ def __init__(self, value: int, children: lis...
{ "Common Sense": null, "Data Structures": [ "Sequence", "Binary Tree" ], "Dynamic Patterns": [ "Layered Structure" ], "Geometric Objects": [ "Arrow" ], "Mathematical Operations": null, "Spatial Transformations": [ "Filtering" ], "Topological Relations": [ "Adjacency", ...
Transformation
q33-2
from collections import deque class TreeNode: """ Represents a node in a tree. Each node contains an integer value and a list of child TreeNodes. Attributes: value (int): The integer value of the node. children (list): A list of child nodes (TreeNode objects). """ def __init__(...
# Problem Description The problem requires implementing a function that processes a binary tree and returns a sequence of node values based on specific rules. The function takes a root node of a tree as input and should return a list of integers representing the "leftmost" nodes in the tree, following certain patterns ...
def tree_to_string(node, level=0): """Helper function to convert a tree to a readable string format.""" if not node: return "None" result = f"TreeNode({node.value})" if node.children: result += " → [" child_strings = [] for child in node.children: child_s...
class TreeNode: """ Represents a node in a tree. Each node contains an integer value and a list of child TreeNodes. Attributes: value (int): The integer value of the node. children (list): A list of child nodes (TreeNode objects). """ def __init__(self, value: int, children: lis...
{ "Common Sense": null, "Data Structures": [ "Sequence", "Binary Tree" ], "Dynamic Patterns": [ "Layered Structure" ], "Geometric Objects": [ "Arrow" ], "Mathematical Operations": null, "Spatial Transformations": [ "Filtering" ], "Topological Relations": [ "Adjacency", ...
Transformation
q33-3
class TreeNode: """ Represents a node in a tree. Each node contains an integer value and a list of child TreeNodes. Attributes: value (int): The integer value of the node. children (list): A list of child nodes (TreeNode objects). """ def __init__(self, value: int, children: lis...
# Problem Description The problem requires implementing a function that processes a binary tree and returns a sequence of node values based on specific rules. The function takes a root node of a tree as input and should return a list of integers representing the "leaf" nodes in the tree. The leaf nodes are those that d...
def tree_to_string(node, level=0): """Helper function to convert a tree to a readable string format""" if not node: return "None" result = f"TreeNode({node.value})" if node.children: result += " → [" children_str = ", ".join(tree_to_string(child, level + 1) for child in node...
class TreeNode: """ Represents a node in a tree. Each node contains an integer value and a list of child TreeNodes. Attributes: value (int): The integer value of the node. children (list): A list of child nodes (TreeNode objects). """ def __init__(self, value: int, children: lis...
{ "Common Sense": null, "Data Structures": [ "Sequence", "Binary Tree" ], "Dynamic Patterns": [ "Layered Structure" ], "Geometric Objects": [ "Arrow" ], "Mathematical Operations": null, "Spatial Transformations": [ "Filtering" ], "Topological Relations": [ "Adjacency", ...
Transformation
q34
def solution(input_matrix: list[list[str]]) -> int: """ Count the number of edges dirived from the given matrix. Args: input_matrix (list[list[str]]): A 2D list where input_matrix[i][j] represents a character at row i, column j. Returns: int: The number of edges in the given matrix. ...
# Problem Description This is a grid-based edge counting problem where: - We need to count the number of edges between adjacent cells containing identical letters - An edge exists when two adjacent cells (horizontally or vertically) contain the same letter - The goal is to return the total count of such edges in the gi...
def test(): test_cases = [ { 'matrix': [ ['A', 'B', 'C'], ['D', 'E', 'F'], ['G', 'H', 'I'] ], "expected": 0 }, { 'matrix': [ ['A', 'A', 'A'], ['A', 'A', 'A'], ...
def solution(input_matrix: list[list[str]]) -> int: """ Count the number of edges. Args: input_matrix (list[list[str]]). Returns: int: The number of edges in the given matrix. """
{ "Common Sense": null, "Data Structures": [ "Matrix" ], "Dynamic Patterns": null, "Geometric Objects": [ "Line Segment", "Grid" ], "Mathematical Operations": [ "Counting" ], "Spatial Transformations": null, "Topological Relations": [ "Connection", "Adjacency", "Connectiv...
Aggregation
q34-2
def solution(input_matrix: list[list[str]]) -> int: """ Count the number of edges dirived from the given matrix. Args: input_matrix (list[list[str]]): A 2D list where input_matrix[i][j] represents a character at row i, column j. Returns: int: The number of edges in the given matrix. ...
# Problem Description This problem involves counting the number of vertical edges in a given matrix. An edge is defined as a connection between two vertically adjacent cells that contain the same letter. The goal is to return the total count of such vertical edges in the given matrix. # Visual Facts 1. **Matrix Struct...
def test(): test_cases = [ { 'matrix': [ ['A', 'B', 'C'], ['D', 'E', 'F'], ['G', 'H', 'I'] ], "expected": 0 }, { 'matrix': [ ['A', 'A', 'A'], ['A', 'A', 'A'], ...
def solution(input_matrix: list[list[str]]) -> int: """ Count the number of edges dirived from the given matrix. Args: input_matrix (list[list[str]]): A 2D list where input_matrix[i][j] represents a character at row i, column j. Returns: int: The number of edges in the given matrix. ...
{ "Common Sense": null, "Data Structures": [ "Matrix" ], "Dynamic Patterns": null, "Geometric Objects": [ "Line Segment", "Grid" ], "Mathematical Operations": [ "Counting" ], "Spatial Transformations": null, "Topological Relations": [ "Connection", "Adjacency", "Connectiv...
Aggregation
q34-3
def solution(input_matrix: list[list[str]]) -> int: """ Count the number of edges dirived from the given matrix. Args: input_matrix (list[list[str]]): A 2D list where input_matrix[i][j] represents a character at row i, column j. Returns: int: The number of edges in the given matrix. ...
# Problem Description This problem involves counting the number of edges in a grid where each cell contains a letter (A, B, C, or D). An edge is defined as a connection between two horizontally adjacent cells that contain the same letter. The goal is to return the total number of such edges in the given matrix. # Visu...
def test(): test_cases = [ { 'matrix': [ ['A', 'B', 'C'], ['D', 'E', 'F'], ['G', 'H', 'I'] ], "expected": 0 }, { 'matrix': [ ['A', 'A', 'A'], ['A', 'A', 'A'], ...
def solution(input_matrix: list[list[str]]) -> int: """ Count the number of edges dirived from the given matrix. Args: input_matrix (list[list[str]]): A 2D list where input_matrix[i][j] represents a character at row i, column j. Returns: int: The number of edges in the given matrix. ...
{ "Common Sense": null, "Data Structures": [ "Matrix" ], "Dynamic Patterns": null, "Geometric Objects": [ "Line Segment", "Grid" ], "Mathematical Operations": [ "Counting" ], "Spatial Transformations": null, "Topological Relations": [ "Connection", "Adjacency", "Connectiv...
Aggregation
q35
from typing import List import numpy as np def solution(input_matrix: List[List[int]]) -> List[List[int]]: """ Transform the given N*3 matrix as illustrated in the figure. Args: input_matrix: A 2D list where input_matrix[i][j] contains an integer. (i is in range [0, N-1]...
# Problem Description This is a matrix transformation problem where we need to rearrange rows of an N×3 matrix according to specific rules. The input matrix has an even number of rows (N is even), and we need to reorder these rows based on their position (odd/even-numbered rows) while maintaining certain patterns. # V...
import numpy as np def test(): test_cases = [ ([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]], [[1, 2, 3], [7, 8, 9], [4, 5, 6], [10, 11, 12]] ), ([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 1...
from typing import List def solution(input_matrix: List[List[int]]) -> List[List[int]]: """ Transform the given N*3 matrix as illustrated in the figure. Args: input_matrix: A 2D list where input_matrix[i][j] contains an integer. (i is in range [0, N-1], N % 2 == 0; j is ...
{ "Common Sense": null, "Data Structures": [ "Matrix" ], "Dynamic Patterns": [ "Alternation", "Layered Structure" ], "Geometric Objects": null, "Mathematical Operations": null, "Spatial Transformations": [ "Swapping", "Grouping" ], "Topological Relations": null }
Transformation
q35-2
from typing import List import numpy as np def solution(input_matrix: List[List[int]]) -> List[List[int]]: """ Transform the given N*3 matrix as illustrated in the figure. Args: input_matrix: A 2D list where input_matrix[i][j] contains an integer. (i is in range [0, N-1]...
# Problem Description This is a matrix transformation problem where we need to rearrange rows of an N×3 matrix according to specific rules. The input matrix has an even number of rows (N is even), and we need to reorder these rows based on their position (odd/even-numbered rows) while maintaining certain patterns. # V...
import numpy as np def test(): test_cases = [ ([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]], [[4, 5, 6], [10, 11, 12], [1, 2, 3], [7, 8, 9]] ), ([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11,...
from typing import List def solution(input_matrix: List[List[int]]) -> List[List[int]]: """ Transform the given N*3 matrix as illustrated in the figure. Args: input_matrix: A 2D list where input_matrix[i][j] contains an integer. (i is in range [0, N-1], N % 2 == 0; j is ...
{ "Common Sense": null, "Data Structures": [ "Matrix" ], "Dynamic Patterns": [ "Alternation", "Layered Structure" ], "Geometric Objects": null, "Mathematical Operations": null, "Spatial Transformations": [ "Swapping", "Grouping" ], "Topological Relations": null }
Transformation
q35-3
from typing import List import numpy as np def solution(input_matrix: List[List[int]]) -> List[List[int]]: """ Transform the given N*3 matrix as illustrated in the figure. Args: input_matrix: A 2D list where input_matrix[i][j] contains an integer. (i is in range [0, N-1]...
# Problem Description This is a matrix transformation problem where we need to rearrange rows of an N×4 matrix according to specific rules. The input matrix has an even number of rows (N is even), and we need to reorder these rows based on their position (odd/even-numbered rows) while maintaining certain patterns. # V...
import numpy as np def test(): test_cases = [ ([[1, 2, 3, 4], [6, 7, 8, 9]], [[1, 2, 3, 4], [6, 7, 8, 9]]), ([[1, 2, 3, 4], [6, 7, 8, 9], [11, 12, 13, 14], [16, 17, 18, 19]], [[1, 2, 3, 4], [11, 12, 13, 14], ...
from typing import List def solution(input_matrix: List[List[int]]) -> List[List[int]]: """ Transform the given N*3 matrix as illustrated in the figure. Args: input_matrix: A 2D list where input_matrix[i][j] contains an integer. (i is in range [0, N-1], N % 2 == 0; j is ...
{ "Common Sense": null, "Data Structures": [ "Matrix" ], "Dynamic Patterns": [ "Alternation", "Layered Structure" ], "Geometric Objects": null, "Mathematical Operations": null, "Spatial Transformations": [ "Swapping", "Grouping" ], "Topological Relations": null }
Transformation
q36
from typing import List def solution(numbers: List[int]) -> int: """ Given a sequence of numbers, determine the number of red segments that would be illuminated. Parameters: numbers (List[int]): A list of integers Returns: int: The total number of segments that will turn red based on ...
# Problem Description The problem involves working with seven-segment displays and logical AND operations. Given a sequence of numbers, we need to determine how many segments would be illuminated (shown in red) after performing a logical AND operation on the segment patterns of all input numbers. The result should coun...
def test(): test_cases = [ ([0, 1], 2), ([3, 5], 4), ([5, 3], 4), ([2, 3], 4), ([4, 5], 3), ([6, 7], 2), ([8, 9], 6), ([2, 6, 4], 1), ([7, 8, 9], 3), ([1, 2, 3, 4], 1), ([5, 6, 7, 8], 2), ([1, 2, 3, 4, 5, 6, 7, 8, 9, 0],...
from typing import List def solution(numbers: List[int]) -> int: """ Given a sequence of numbers, determine the number of red segments that would be illuminated. Parameters: numbers (List[int]): A list of integers Returns: int: The total number of segments that will turn red based on ...
{ "Common Sense": [ "Seven-Segment Display" ], "Data Structures": null, "Dynamic Patterns": null, "Geometric Objects": null, "Mathematical Operations": [ "Logical Operations" ], "Spatial Transformations": null, "Topological Relations": [ "Overlap", "Connectivity" ] }
Direct Calculation
q36-2
from typing import List def solution(numbers: List[int]) -> int: """ Given a sequence of numbers, determine the number of red segments that would be illuminated. Parameters: numbers (List[int]): A list of integers Returns: int: The total number of segments that will turn red based on ...
# Problem Description The problem involves working with seven-segment displays and logical OR operations. Given a sequence of numbers, we need to determine how many segments would be illuminated (shown in red) after performing a logical OR operation on the segment patterns of all input numbers. The result should count ...
def test(): test_cases = [ ([0, 1], 6), ([3, 5], 6), ([5, 3], 6), ([2, 3], 6), ([4, 5], 6), ([6, 7], 7), ([8, 9], 7), ([2, 6, 4], 7), ([7, 8, 9], 7), ([1, 2, 3, 4], 7), ([5, 6, 7, 8], 7), ([1, 2, 3, 4, 5, 6, 7, 8, 9, 0],...
from typing import List def solution(numbers: List[int]) -> int: """ Given a sequence of numbers, determine the number of red segments that would be illuminated. Parameters: numbers (List[int]): A list of integers Returns: int: The total number of segments that will turn red based on ...
{ "Common Sense": [ "Seven-Segment Display" ], "Data Structures": null, "Dynamic Patterns": null, "Geometric Objects": null, "Mathematical Operations": [ "Logical Operations" ], "Spatial Transformations": null, "Topological Relations": [ "Overlap", "Connectivity" ] }
Direct Calculation
q36-3
from typing import List def solution(numbers: List[int]) -> int: """ Given a sequence of numbers, determine the number of red segments that would be illuminated. Parameters: numbers (List[int]): A list of integers Returns: int: The total number of segments that will turn red based on ...
# Problem Description The problem involves working with seven-segment displays and logical XOR operations. Given a sequence of numbers, we need to determine how many segments would be illuminated (shown in red) after performing a logical XOR operation on the segment patterns of all input numbers. The result should coun...
def test(): test_cases = [ ([0, 1], 4), ([3, 5], 2), ([5, 3], 2), ([2, 3], 2), ([4, 5], 3), ([6, 7], 5), ([8, 9], 1), ([2, 6, 4], 1), ([1, 4, 9], 4), ([7, 8, 9], 4), ([1, 2, 3, 4], 4), ([5, 6, 7, 8], 3), ([1, 2, ...
from typing import List def solution(numbers: List[int]) -> int: """ Given a sequence of numbers, determine the number of red segments that would be illuminated. Parameters: numbers (List[int]): A list of integers Returns: int: The total number of segments that will turn red based on ...
{ "Common Sense": [ "Seven-Segment Display" ], "Data Structures": null, "Dynamic Patterns": null, "Geometric Objects": null, "Mathematical Operations": [ "Logical Operations" ], "Spatial Transformations": null, "Topological Relations": [ "Overlap", "Connectivity" ] }
Direct Calculation
q37
from math import atan2 def solution(points: list[tuple[int, int]], point_a_index: int, point_b_index: int) -> bool: """ Given a list of points and the index of two points, determine whether the two points should be connected to form the shape in the figure. Args: points (list[tuple[int, int]]): An...
# Problem Description This is a geometric problem to determine whether two given points should be connected to form a valid five-pointed star (pentagram). The function needs to: 1. Take a list of 5 coordinate points and indices of 2 points 2. Determine if these two points should be connected based on the rules of penta...
def test(): test_cases = [ ([(2, 5), (4, 7), (3, 2), (5, 2), (6, 5)], 2, 4, True), ([(2, 5), (4, 7), (3, 2), (5, 2), (6, 5)], 2, 3, False), ([(2, 5), (4, 7), (3, 2), (5, 2), (6, 5)], 0, 4, True), ([(2, 5), (4, 7), (3, 2), (5, 2), (6, 5)], 0, 2, False), ([(2, 5), (4, 7), (3, 2...
def solution(points: list[tuple[int, int]], point_a_index: int, point_b_index: int) -> bool: """ Given a list of points and the index of two points, determine whether the two points should be connected to form the shape in the figure. Args: points (list[tuple[int, int]]): An list of tuples, where e...
{ "Common Sense": null, "Data Structures": null, "Dynamic Patterns": [ "Cyclic Motion", "Circular Arrangement" ], "Geometric Objects": [ "Pentagram", "Coordinate System", "Grid", "Line Segment", "Point" ], "Mathematical Operations": null, "Spatial Transformations": null, "T...
Validation
q37-2
from math import atan2 def solution(points: list[tuple[int, int]], point_a_index: int, point_b_index: int) -> bool: """ Given a list of points and the index of two points, determine whether the two points should be connected to form the shape in the figure. Args: points (list[tuple[int, int]]): An...
# Problem Description This problem involves determining whether two given points should be connected to form a six-pointed star pattern. The function needs to: 1. Take a list of coordinate points and indices of 2 points. 2. Determine if these two points should be connected based on the rules of six-pointed star constru...
def test(): test_cases = [ ([(2, 5), (4, 7), (6, 5), (5, 2), (3, 1), (1, 2)], 2, 4, True), ([(2, 5), (4, 7), (6, 5), (5, 2), (3, 1), (1, 2)], 2, 3, False), ([(2, 5), (4, 7), (6, 5), (5, 2), (3, 1), (1, 2)], 0, 4, True), ([(2, 5), (4, 7), (6, 5), (5, 2), (3, 1), (1, 2)], 0, 2, True), ...
def solution(points: list[tuple[int, int]], point_a_index: int, point_b_index: int) -> bool: """ Given a list of points and the index of two points, determine whether the two points should be connected to form the shape in the figure. Args: points (list[tuple[int, int]]): An list of tuples, where e...
{ "Common Sense": null, "Data Structures": null, "Dynamic Patterns": [ "Cyclic Motion", "Circular Arrangement" ], "Geometric Objects": [ "Coordinate System", "Hexagon", "Grid", "Line Segment", "Point" ], "Mathematical Operations": null, "Spatial Transformations": null, "Top...
Validation
q37-3
from math import atan2 def solution(points: list[tuple[int, int]], point_a_index: int, point_b_index: int) -> bool: """ Given a list of points and the index of two points, determine whether the two points should be connected to form the shape in the figure. Args: points (list[tuple[int, int]]): An...
# Problem Description This problem requires determining whether two given points should be connected to form a pentagon. The function takes a list of points and the indices of two points, and it returns whether these two points should be connected to form a valid pentagon. The points are not guaranteed to be in any par...
def test(): test_cases = [ ([(2, 5), (4, 7), (3, 2), (5, 2), (6, 5)], 2, 4, False), ([(2, 5), (4, 7), (3, 2), (5, 2), (6, 5)], 2, 3, True), ([(2, 5), (4, 7), (3, 2), (5, 2), (6, 5)], 0, 4, False), ([(2, 5), (4, 7), (3, 2), (5, 2), (6, 5)], 0, 2, True), ([(2, 5), (4, 7), (3, 2...
def solution(points: list[tuple[int, int]], point_a_index: int, point_b_index: int) -> bool: """ Given a list of points and the index of two points, determine whether the two points should be connected to form the shape in the figure. Args: points (list[tuple[int, int]]): An list of tuples, where e...
{ "Common Sense": null, "Data Structures": null, "Dynamic Patterns": [ "Cyclic Motion", "Circular Arrangement" ], "Geometric Objects": [ "Coordinate System", "Grid", "Line Segment", "Pentagon", "Point" ], "Mathematical Operations": null, "Spatial Transformations": null, "To...
Validation
q38
from typing import List def solution(colors: List[int], line_position: int) -> List[int]: """ Transforms a 1D color array based on a given dashed line position. Args: colors (List[int]): A 1D array representing colors where: - 0 = white - 1 = light blue - 2 = ...
# Problem Description - The task involves transforming a 1d array of colors based on a given "vertical axis" (specified by the line_position). The input list contains integer values representing colors: 0 for white 1 for light blue 2 for dark blue - The transformation involves folding the 1d array around th...
def test(): test_cases = [ ([0, 1, 0, 1], 2, [1, 1]), ([0, 1, 0, 1], 1, [1, 0, 1]), ([1, 1, 0, 1], 2, [1, 2]), ([1, 1, 1, 1], 2, [2, 2]), ([0, 1, 0, 0], 3, [0, 1, 0]), ([0, 1, 1, 1, 0, 1], 2, [2, 1, 0, 1]), ([0, 1, 1, 1, 0, 1], 1, [1, 1, 1, 0, 1]), ([...
from typing import List def solution(colors: List[int], line_position: int) -> List[int]: """ Transforms a 1D color array based on a given dashed line position. Args: colors (List[int]): A 1D array representing colors where: - 0 = white - 1 = light blue - 2 = ...
{ "Common Sense": null, "Data Structures": [ "Sequence" ], "Dynamic Patterns": [ "Mirror Reflection" ], "Geometric Objects": [ "Rectangle", "Grid", "Line" ], "Mathematical Operations": [ "Value Comparison", "Basic Arithmetic" ], "Spatial Transformations": [ "Flipping"...
Direct Calculation
q38-2
from typing import List def solution(numbers: List[int], line_position: int) -> List[int]: """ You are given a list of numbers. Your task is to generate a new list based on the given dashed line position. Input: - numbers: A 1D list of integers representing the initial state of the numbers. - line...
# Problem Description The task involves transforming a 1D array of integers based on a given "vertical axis" (specified by the line_position). The transformation involves folding the array around the vertical axis and merging values on either side of the axis using a specific rule. The output is a new 1D array with tra...
def test(): test_cases = [ ([1, 2, 3], 1, [3, 3]), ([1, 2, 3], 2, [5, 1]), ([1, 2, 3, 2, 1], 3, [5, 3, 1]), ([1, 2, 3, 2, 1], 2, [5, 3, 1]), ([1, 2, 3, 2, 1], 1, [3, 3, 2, 1]), ([1, 2, 3, 4], 3, [7, 2, 1]), ([1, 2, 3, 4], 2, [5, 5]), ([5, 6, 7, 8], 1,...
from typing import List def solution(numbers: List[int], line_position: int) -> List[int]: """ You are given a list of numbers. Your task is to generate a new list based on the given dashed line position. Input: - numbers: A 1D list of integers representing the initial state of the numbers. - line...
{ "Common Sense": null, "Data Structures": [ "Sequence" ], "Dynamic Patterns": [ "Mirror Reflection" ], "Geometric Objects": [ "Rectangle", "Grid", "Line" ], "Mathematical Operations": [ "Value Comparison", "Basic Arithmetic" ], "Spatial Transformations": [ "Flipping"...
Direct Calculation
q38-3
from typing import List def solution(numbers: List[int], line_position: int) -> List[int]: """ You are given a list of numbers. Your task is to generate a new list based on the given dashed line position. Input: - numbers: A 1D list of integers representing the initial state of the numbers. - line...
# Problem Description The task involves transforming a 1D array of integers based on a given "vertical axis" (specified by the line_position). The transformation involves folding the array around the vertical axis and merging values on either side of the axis using a specific rule. The output is a new 1D array with tra...
def test(): test_cases = [ ([1, 2, 3], 1, [1, 3]), ([1, 2, 3], 2, [1, -1]), ([1, 2, 3, 4, 5], 3, [1, 3, -1]), ([1, 2, 3, 4, 5], 2, [1, 3, 5]), ([1, 2, 3, 4, 5], 1, [1, 3, 4, 5]), ([1, 2, 3, 2], 3, [-1, -2, -1]), ([5, 6, 7, 5], 2, [1, 0]), ([1, 2, 3, 2]...
from typing import List def solution(numbers: List[int], line_position: int) -> List[int]: """ You are given a list of numbers. Your task is to generate a new list based on the given dashed line position. Input: - numbers: A 1D list of integers representing the initial state of the numbers. - line...
{ "Common Sense": null, "Data Structures": [ "Sequence" ], "Dynamic Patterns": [ "Mirror Reflection" ], "Geometric Objects": [ "Rectangle", "Grid", "Line" ], "Mathematical Operations": [ "Value Comparison", "Basic Arithmetic" ], "Spatial Transformations": [ "Flipping"...
Direct Calculation
q39
from typing import List, Tuple def move_direction(x: int, y: int, direction: str) -> Tuple[int, int]: """Move to the next cell based on the given direction.""" if direction == 'L': return x, y - 1 elif direction == 'R': return x, y + 1 elif direction == 'U': return x - 1, y ...
# Problem Description This is a matrix traversal problem where: - We navigate through a matrix containing directional characters (R, L, U, D) - Movement starts from a given coordinate and follows the directional instructions - The goal is to find the final coordinates where the path exits the matrix - The coordinates a...
def test(): test_cases = [ ( [['R', 'D', 'L'], ['L', 'U', 'R'], ['U', 'L', 'U']], (2, 2), (2, 1) ), ( [['D', 'R', 'L', 'D'], ['U', 'L', 'U', 'L'], ['D', 'U', 'U', 'R'], ['R', 'D',...
from typing import List, Tuple def solution(matrix: List[List[str]], start: Tuple[int, int]) -> Tuple[int, int]: """ Given the starting coordinates, find the ending coordinates in a 2D matrix. Args: matrix (List[List[str]]): A 2D matrix where each element is one of four upper case characters ...
{ "Common Sense": null, "Data Structures": [ "Path", "Matrix" ], "Dynamic Patterns": null, "Geometric Objects": [ "Grid", "Point", "Arrow", "Coordinate System" ], "Mathematical Operations": null, "Spatial Transformations": null, "Topological Relations": [ "Boundary", "C...
Iterative Calculation
q39-2
from typing import List, Tuple def solution(matrix: List[List[str]], start: Tuple[int, int], home: Tuple[int, int]) -> bool: """ Determine if it's possible to reach home given the starting point and the house coordinates. Args: matrix (List[List[str]]): A 2D matrix where each element is one of fou...
# Problem Description This problem involves navigating through a matrix where each cell contains a directional character ('R', 'L', 'U', 'D'). Starting from a given coordinate, the goal is to determine if it's possible to reach a specified home position by following the directional instructions. Each cell can change di...
def test(): # Test case 1 matrix = [ ['R', 'D', 'L'], ['L', 'U', 'R'], ['U', 'L', 'U'] ] home = (0, 2) start = (1, 2) try: result = solution(matrix, start, home) except Exception as e: error_message = ( f"An exception occurred while running...
from typing import List, Tuple def solution(matrix: List[List[str]], start: Tuple[int, int], home: Tuple[int, int]) -> bool: """ Determine if it's possible to reach home given the starting point and the house coordinates. Args: matrix (List[List[str]]): A 2D matrix where each element is one of fou...
{ "Common Sense": null, "Data Structures": [ "Path", "Matrix" ], "Dynamic Patterns": null, "Geometric Objects": [ "Grid", "Point", "Arrow", "Coordinate System" ], "Mathematical Operations": null, "Spatial Transformations": null, "Topological Relations": [ "Boundary", "C...
Iterative Calculation
q4
import matplotlib.pyplot as plt from typing import List, Tuple def solution(dots: List[Tuple[int, int]], top_left: Tuple[int, int], bottom_right: Tuple[int, int]) -> bool: """ Determines whether a rectangle is valid given its corner coordinates and a set of dots. Parameters: dots: A list of coordi...
# Problem Description: - The function solution is tasked with determining if a rectangle defined by its top_left and bottom_right corners is "valid" given a grid of points (dots). A rectangle is considered valid or invalid based on certain properties inferred from the image and the accompanying description. The goal is...
def test(): test_cases = [ ([(1, 1), (3, 3), (5, 5)], (2, 6), (6, 2), False), ([(1, 1), (2, 3), (4, 6)], (2, 6), (6, 2), True), ([(2, 0), (3, 0), (5, 6)], (1, 6), (6, 1), True), ([(1, 1), (3, 3), (5, 5)], (2, 4), (4, 2), False), ([], (2, 6), (6, 2), True), ([(1, 1), (...
from typing import List, Tuple def solution(dots: List[Tuple[int, int]], top_left: Tuple[int, int], bottom_right: Tuple[int, int]) -> bool: """ Determines whether a rectangle is valid given its corner coordinates and a set of dots. Parameters: dots: A list of coordinate pairs representing points i...
{ "Common Sense": null, "Data Structures": null, "Dynamic Patterns": null, "Geometric Objects": [ "Rectangle", "Coordinate System", "Point", "Grid" ], "Mathematical Operations": [ "Counting", "Conditional Branching" ], "Spatial Transformations": null, "Topological Relations": [...
Validation
q4-2
import matplotlib.pyplot as plt from typing import List, Tuple import matplotlib.pyplot as plt def solution(dots: List[Tuple[int, int]], top_left: Tuple[int, int], bottom_right: Tuple[int, int]) -> bool: """ Determines whether a rectangle is valid given its corner coordinates and a set of dots. Parameters...
# Problem Description: The task is to determine whether a given rectangle, defined by its top-left and bottom-right corners, is valid based on the presence of red dots within a grid. A rectangle is considered valid if it contains exactly one red dot either inside or on its boundary. The function `solution` takes a list...
def test(): test_cases = [ ([(1, 1), (3, 3), (5, 5)], (2, 6), (6, 2), False), ([(1, 1), (2, 3), (4, 6)], (2, 6), (6, 2), False), ([(2, 0), (3, 0), (5, 6)], (1, 6), (6, 1), True), ([(1, 1), (3, 3), (5, 5)], (2, 4), (4, 2), True), ([], (2, 6), (6, 2), False), ([(1, 1), ...
from typing import List, Tuple def solution(dots: List[Tuple[int, int]], top_left: Tuple[int, int], bottom_right: Tuple[int, int]) -> bool: """ Determines whether a rectangle is valid given its corner coordinates and a set of dots. Parameters: dots: A list of coordinate pairs representing points i...
{ "Common Sense": null, "Data Structures": null, "Dynamic Patterns": null, "Geometric Objects": [ "Rectangle", "Coordinate System", "Point", "Grid" ], "Mathematical Operations": [ "Counting", "Conditional Branching" ], "Spatial Transformations": null, "Topological Relations": [...
Validation
q4-3
import matplotlib.pyplot as plt from typing import List, Tuple import matplotlib.pyplot as plt def solution(dots: List[Tuple[int, int]], top_left: Tuple[int, int], bottom_right: Tuple[int, int]) -> bool: """ Determines whether a rectangle is valid given its corner coordinates and a set of dots. Parameters...
# Problem Description: The task is to implement a function `solution` that determines whether a given rectangle is valid based on its corner coordinates and a set of points (dots) on a grid. A rectangle is considered valid if it does not contain any of the given points either inside or on its boundary. # Visual Facts:...
def test(): test_cases = [ ([(1, 1), (3, 3), (5, 5)], (2, 6), (6, 2), False), ([(1, 1), (2, 3), (4, 6)], (2, 6), (6, 2), False), ([(2, 0), (3, 0), (5, 6)], (1, 6), (6, 1), False), ([(1, 1), (3, 3), (5, 5)], (2, 4), (4, 2), False), ([], (2, 6), (6, 2), True), ([(1, 1),...
from typing import List, Tuple def solution(dots: List[Tuple[int, int]], top_left: Tuple[int, int], bottom_right: Tuple[int, int]) -> bool: """ Determines whether a rectangle is valid given its corner coordinates and a set of dots. Parameters: dots: A list of coordinate pairs representing points i...
{ "Common Sense": null, "Data Structures": null, "Dynamic Patterns": null, "Geometric Objects": [ "Rectangle", "Coordinate System", "Point", "Grid" ], "Mathematical Operations": [ "Counting", "Conditional Branching" ], "Spatial Transformations": null, "Topological Relations": [...
Validation
q40
import math def solution(h: int, m: int, a: int, b: int, k: int) -> float: """ Given an initial time (in 12-hour format) and the lengths of the orange and green arrows, calculate the length of the red dashed line after k minutes Parameters: h (int): Hour. m (int): Minute. a (int): ...
# Problem Description This is a geometric problem involving clock hand movements and distance calculations. We need to: 1. Start with an initial time (h:m) and two arrows of lengths a and b 2. After k minutes, calculate the length of a line that connects: - The initial position of the hour hand - The final positi...
def test(): test_cases = [ (3, 0, 3, 4, 40, 6.77), (3, 0, 4, 3, 180, 5.0), (3, 0, 2, 7, 40, 8.79), (4, 20, 6, 8, 70, 6.19), (6, 0, 6, 8, 150, 2), (8, 22, 5, 9, 137, 4.46), (7, 12, 4, 6, 29, 3.23), (1, 56, 2, 7, 173, 8.29), (1, 56, 3, 4, 104, 7....
def solution(h: int, m: int, a: int, b: int, k: int) -> float: """ Given an initial time (in 12-hour format) and the lengths of the orange and green arrows, calculate the length of the red dashed line after k minutes Parameters: h (int): Hour. m (int): Minute. a (int): Length of the...
{ "Common Sense": [ "Clock" ], "Data Structures": null, "Dynamic Patterns": [ "Cyclic Motion", "Circular Motion" ], "Geometric Objects": [ "Line Segment", "Angle", "Triangle", "Circle", "Point", "Arrow" ], "Mathematical Operations": null, "Spatial Transformations": ...
Direct Calculation
q40-2
import math def solution(h: int, m: int, a: int, b: int, k: int) -> float: """ Given an initial time (in 12-hour format) and the lengths of the orange and green arrows, calculate the area of the blue region after k minutes Parameters: h (int): Hour. m (int): Minute. a (int): Length...
# Problem Description The problem involves calculating the area of a triangle formed by the positions of the hour and minute hands on a clock after a given time has elapsed. The initial positions of the hour and minute hands are given, along with the lengths of the arrows representing these hands. We need to determine ...
def test(): test_cases = [ (3, 0, 3, 4, 30, 6.0), (3, 0, 4, 3, 180, 6.0), (3, 0, 2, 7, 40, 3.5), (4, 20, 6, 8, 70, 18.39), (6, 0, 6, 8, 150, 0), (8, 22, 5, 9, 137, 6.58), (7, 12, 4, 6, 29, 6.0), (1, 56, 2, 7, 173, 5.8), (1, 56, 3, 4, 104, 0.21)...
def solution(h: int, m: int, a: int, b: int, k: int) -> float: """ Given an initial time (in 12-hour format) and the lengths of the orange and green arrows, calculate the area of the blue region after k minutes Parameters: h (int): Hour. m (int): Minute. a (int): Length of the orang...
{ "Common Sense": [ "Clock" ], "Data Structures": null, "Dynamic Patterns": [ "Cyclic Motion", "Circular Motion" ], "Geometric Objects": [ "Line Segment", "Angle", "Triangle", "Circle", "Point", "Arrow" ], "Mathematical Operations": null, "Spatial Transformations": ...
Direct Calculation
q40-3
import math def solution(h: int, m: int, a: int, b: int, k: int) -> float: """ Given an initial time (in 12-hour format) and the lengths of the orange and green arrows, calculate the distance between the initial minute hand and the hour hand after k minutes. Parameters: h (int): Hour. ...
# Problem Description The problem involves calculating the length of a line segment (red dashed line) on an analog clock after a certain duration has passed. The initial time is given along with the lengths of the hour and minute hands. The goal is to determine the length of the red dashed line, which connects the init...
def test(): test_cases = [ (2, 0, 3, 4, 60, 5.0), (3, 0, 4, 3, 180, 7.0), (3, 0, 2, 7, 40, 7.91), (4, 20, 6, 8, 70, 5.67), (6, 0, 6, 8, 150, 11.17), (8, 22, 5, 9, 137, 13.97), (7, 12, 4, 6, 29, 9.83), (1, 56, 2, 7, 173, 8.97), (1, 56, 3, 4, 104...
def solution(h: int, m: int, a: int, b: int, k: int) -> float: """ Given an initial time (in 12-hour format) and the lengths of the orange and green arrows, calculate the length of the red dashed line after k minutes Parameters: h (int): Hour. m (int): Minute. a (int): Length of the...
{ "Common Sense": [ "Clock" ], "Data Structures": null, "Dynamic Patterns": [ "Cyclic Motion", "Circular Motion" ], "Geometric Objects": [ "Line Segment", "Angle", "Triangle", "Circle", "Point", "Arrow" ], "Mathematical Operations": null, "Spatial Transformations": ...
Direct Calculation
q41
from typing import List def solution(n: int) -> List[int]: """ Returns the numbers in the specified row. Parameters: n (int): The row number to retrieve. (n > 1) Returns: List[int]: A list containing all numbers in the nth row. """ ret = list() for i in range(n): ...
# Problem Description This is a hexagonal pyramid number pattern problem where we need to generate the nth row of numbers following specific rules. Each row contains numbers arranged in hexagonal cells, with the first row having one cell, and each subsequent row adding one more cell than the previous row. The function ...
def test(): test_cases = [ (1, [2]), (2, [2, 2]), (3, [2, 4, 2]), (4, [2, 8, 8, 2]), (5, [2, 16, 64, 16, 2]), (6, [2, 32, 1024, 1024, 32, 2]), (7, [2, 64, 32768, 1048576, 32768, 64, 2]), (8, [2, 128, 2097152, 34359738368, 34359738368, 2097152, 128, 2])...
from typing import List def solution(n: int) -> List[int]: """ Returns the numbers in the specified row. Parameters: n (int): The row number to retrieve. (n > 1) Returns: List[int]: A list containing all numbers in the nth row. """
{ "Common Sense": null, "Data Structures": [ "Sequence" ], "Dynamic Patterns": [ "Linear Increment", "Layered Structure", "Exponential Increment", "Mirror Symmetry", "Propagation" ], "Geometric Objects": [ "Triangle", "Hexagon" ], "Mathematical Operations": [ "Basic A...
Expansion
q41-2
from typing import List def solution(n: int) -> List[int]: """ Returns the numbers in the specified row. Parameters: n (int): The row number to retrieve. (n > 1) Returns: List[int]: A list containing all numbers in the nth row. """ ret = list() for i in range(n): ...
# Problem Description This is a hexagonal pyramid number pattern problem where we need to generate the nth row of numbers following specific rules. Each row contains numbers arranged in hexagonal cells, with the first row having one cell, and each subsequent row adding one more cell than the previous row. The function ...
def test(): test_cases = [ (1, [1]), (2, [2, 2]), (3, [3, 4, 3]), (4, [4, 12, 12, 4]), (5, [5, 48, 144, 48, 5]), (6, [6, 240, 6912, 6912, 240, 6]), (7, [7, 1440, 1658880, 47775744, 1658880, 1440, 7]), (8, [8, 10080, 2388787200, 79254226206720, 79254226...
from typing import List def solution(n: int) -> List[int]: """ Returns the numbers in the specified row. Parameters: n (int): The row number to retrieve. (n > 1) Returns: List[int]: A list containing all numbers in the nth row. """
{ "Common Sense": null, "Data Structures": [ "Sequence" ], "Dynamic Patterns": [ "Linear Increment", "Layered Structure", "Exponential Increment", "Mirror Symmetry", "Propagation" ], "Geometric Objects": [ "Triangle", "Hexagon" ], "Mathematical Operations": [ "Basic A...
Expansion
q41-3
from typing import List def solution(n: int) -> List[int]: """ Returns the numbers in the specified row. Parameters: n (int): The row number to retrieve. (n > 1) Returns: List[int]: A list containing all numbers in the nth row. """ ret = list() for i in range(n): ...
# Problem Description This is a hexagonal pyramid number pattern problem where we need to generate the nth row of numbers following specific rules. Each row contains numbers arranged in hexagonal cells, with the first row having one cell, and each subsequent row adding one more cell than the previous row. The function ...
def test(): test_cases = [ (1, [2]), (2, [2, 2]), (3, [2, 4, 2]), (4, [2, 6, 6, 2]), (5, [2, 8, 12, 8, 2]), (6, [2, 10, 20, 20, 10, 2]), (7, [2, 12, 30, 40, 30, 12, 2]), (8, [2, 14, 42, 70, 70, 42, 14, 2]), (9, [2, 16, 56, 112, 140, 112, 56, 16...
from typing import List def solution(n: int) -> List[int]: """ Returns the numbers in the specified row. Parameters: n (int): The row number to retrieve. (n > 1) Returns: List[int]: A list containing all numbers in the nth row. """
{ "Common Sense": null, "Data Structures": [ "Sequence" ], "Dynamic Patterns": [ "Linear Increment", "Layered Structure", "Exponential Increment", "Mirror Symmetry", "Propagation" ], "Geometric Objects": [ "Triangle", "Hexagon" ], "Mathematical Operations": [ "Basic A...
Expansion
q42
from typing import List def solution(matrix: List[List[int]]) -> int: """ Calculate the sum of the elements in the matrix. Parameters: matrix (List[List[int]]): A 3x3 integer matrix. Returns: int: The sum of the elements in the matrix. """ return matrix[0][2] + m...
# Problem Description This appears to be a problem about calculating a specific sum in a 3x3 matrix, but the complete requirements aren't clear from the function signature alone. The image suggests we need to calculate the sum of elements along a diagonal path marked by arrows in each matrix case. # Visual Facts 1. Ea...
def test(): test_cases = [ ([[1, 2, 3], [4, 5, 6], [7, 8, 9]], 15), ([[4, 4, 2], [1, 8, 6], [5, 3, 5]], 15), ([[4, 4, 1], [1, 3, 3], [2, 3, 5]], 6), ([[1, 0, 0], [2, 8, 6], [5, 4, 2]], 13), ([[3, 4, 5], [6, 1, 3], [2, 2, 1]], 8), ([[7, 1, 1], [2, 4, 6], [1, 3, 5]], 6)...
from typing import List def solution(matrix: List[List[int]]) -> int: """ Calculate the sum of the elements in the matrix. Parameters: matrix (List[List[int]]): A 3x3 integer matrix. Returns: int: The sum of the elements in the matrix. """
{ "Common Sense": null, "Data Structures": [ "Matrix" ], "Dynamic Patterns": [ "Cross Pattern" ], "Geometric Objects": [ "Line", "Diagonal", "Arrow", "Grid" ], "Mathematical Operations": [ "Aggregation", "Basic Arithmetic" ], "Spatial Transformations": null, "Topolo...
Aggregation