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 |
|---|---|---|---|---|---|---|---|
q80 | from typing import List
def solution(bin_array: List[int], chosen: int) -> List[int]:
"""
Manipulates a binary array based on the selected index position.
Parameters:
bin_array (List[int]): A binary array containing only 0s and 1s
chosen (int): Zero-based index of the chosen cell
Retu... | # Problem Description
This is a binary array manipulation problem where we need to:
1. Take a binary array (containing only 0s and 1s) and a chosen index position
2. Perform some operation on all elements except the chosen position
3. Return the transformed array maintaining the same length as input
# Visual Facts
1. ... | def test():
test_cases = [
([1, 1, 0, 1, 0, 1, 0, 1], 3, [0, 0, 1, 1, 1, 0, 1, 0]),
([1, 1, 0, 1, 0, 1, 0, 1], 4, [1, 1, 0, 1, 0, 1, 0, 1]),
([1, 0, 1, 0, 1, 1], 5, [0, 1, 0, 1, 0, 1]),
([0, 0, 0, 0, 0, 0, 1, 0, 0, 0], 0, [0, 0, 0, 0, 0, 0, 1, 0, 0, 0]),
([1, 0, 1, 1, 0, 0, 1... | from typing import List
def solution(bin_array: List[int], chosen: int) -> List[int]:
"""
Manipulates a binary array based on the selected index position.
Parameters:
bin_array (List[int]): A binary array containing only 0s and 1s
chosen (int): Zero-based index of the chosen cell
Retu... | {
"Common Sense": null,
"Data Structures": [
"Sequence"
],
"Dynamic Patterns": [
"Propagation"
],
"Geometric Objects": [
"Arrow"
],
"Mathematical Operations": [
"Logical Operations"
],
"Spatial Transformations": [
"Mapping"
],
"Topological Relations": [
"Connection"
]
} | Direct Calculation | |
q80-2 | from typing import List
def solution(bin_array: List[int], chosen: int) -> List[int]:
"""
Manipulates a binary array based on the selected index position.
Parameters:
bin_array (List[int]): A binary array containing only 0s and 1s
chosen (int): Zero-based index of the chosen cell
Retu... | # Problem Description
The task involves manipulating a binary array based on a chosen index. Specifically, given a binary array (containing only 0s and 1s) and a chosen index, the goal is to transform the array such that each element (except the one at the chosen index) is replaced by the result of the XNOR operation b... | def test():
test_cases = [
([1, 1, 0, 1, 0, 1, 0, 1],3 ,[1, 1, 0, 1, 0, 1, 0, 1]),
([1, 1, 0, 1, 0, 1, 0, 1],4 ,[0, 0, 1, 0, 0, 0, 1, 0]),
([1, 0, 1, 0, 1, 1],1 ,[0, 0, 0, 1, 0, 0]),
([0, 0, 0, 0, 0, 0, 1, 0, 0, 0],0 ,[0, 1, 1, 1, 1, 1, 0, 1, 1, 1]),
([1, 0, 1, 1, 0, 0, 1, 1]... | from typing import List
def solution(bin_array: List[int], chosen: int) -> List[int]:
"""
Manipulates a binary array based on the selected index position.
Parameters:
bin_array (List[int]): A binary array containing only 0s and 1s
chosen (int): Zero-based index of the chosen cell
Retu... | {
"Common Sense": null,
"Data Structures": [
"Sequence"
],
"Dynamic Patterns": [
"Propagation"
],
"Geometric Objects": [
"Arrow"
],
"Mathematical Operations": [
"Logical Operations"
],
"Spatial Transformations": [
"Mapping"
],
"Topological Relations": [
"Connection"
]
} | Direct Calculation | |
q80-3 | from typing import List
def solution(bin_array: List[int], chosen: int) -> List[int]:
"""
Manipulates a binary array based on the selected index position.
Parameters:
bin_array (List[int]): A binary array containing only 0s and 1s
chosen (int): Zero-based index of the chosen cell
Retu... | # Problem Description
The task involves manipulating a binary array based on a chosen index. The manipulation is performed by applying a Multiply operation between the chosen element and every other element in the array. The result of this operation is stored in a new output array, where each element is the result of t... | def test():
test_cases = [
([1, 1, 0, 1, 0, 1, 0, 1],3,[1, 1, 0, 1, 0, 1, 0, 1]),
([1, 1, 0, 1, 0, 1, 0, 1],4,[0, 0, 0, 0, 0, 0, 0, 0]),
([1, 0, 1, 0, 1, 1],1,[0, 0, 0, 0, 0, 0]),
([0, 0, 0, 0, 0, 0, 1, 0, 0, 0],0,[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]),
([1, 0, 1, 1, 0, 0, 1, 1],5,[... | from typing import List
def solution(bin_array: List[int], chosen: int) -> List[int]:
"""
Manipulates a binary array based on the selected index position.
Parameters:
bin_array (List[int]): A binary array containing only 0s and 1s
chosen (int): Zero-based index of the chosen cell
Retu... | {
"Common Sense": null,
"Data Structures": [
"Sequence"
],
"Dynamic Patterns": [
"Propagation"
],
"Geometric Objects": [
"Arrow"
],
"Mathematical Operations": [
"Basic Arithmetic"
],
"Spatial Transformations": [
"Mapping"
],
"Topological Relations": [
"Connection"
]
} | Direct Calculation | |
q81 | from typing import List
class GraphNode:
"""
Represents a node in a graph. Each node contains an integer value, a list of connected nodes, and a type attribute.
Attributes:
value (int): The integer value of the node.
type (str): The type of the node ('start', 'end', or '').
connect... | # Problem Description
This is a graph path validation problem where we need to determine if a given sequence of node values represents a valid path through the undirected graph. The graph contains specially marked "start" and "end" nodes, and the path must follow specific rules to be considered valid.
# Visual Facts
1... | from typing import List
class GraphNode:
"""
Represents a node in a graph. Each node contains an integer value, a list of connected nodes, and a type attribute.
Attributes:
value (int): The integer value of the node.
type (str): The type of the node, can be 'start', 'end', or ''.
... | from typing import List
class GraphNode:
"""
Represents a node in a graph. Each node contains an integer value, a list of connected nodes, and a type attribute.
Attributes:
value (int): The integer value of the node.
type (str): The type of the node ('start', 'end', or '').
connect... | {
"Common Sense": null,
"Data Structures": [
"Sequence",
"Undirected Graph",
"Path"
],
"Dynamic Patterns": null,
"Geometric Objects": null,
"Mathematical Operations": [
"Conditional Branching"
],
"Spatial Transformations": null,
"Topological Relations": [
"Connection",
"Adjacen... | Validation | |
q81-2 | from typing import List
class GraphNode:
"""
Represents a node in a graph. Each node contains an integer value, a list of connected nodes, and a type attribute.
Attributes:
value (int): The integer value of the node.
type (str): The type of the node ('start', 'end', 'x', or '').
co... | # Problem Description
This is a graph path validation problem where we need to determine if a given sequence of node values represents a valid path through the undirected graph. The graph contains specially marked "start" "end" and "x" nodes, and the path must follow specific rules to be considered valid.
# Visual Fac... | from typing import List
class GraphNode:
"""
Represents a node in a graph. Each node contains an integer value, a list of connected nodes, and a type attribute.
Attributes:
value (int): The integer value of the node.
type (str): The type of the node, can be 'start', 'end', or ''.
... | from typing import List
class GraphNode:
"""
Represents a node in a graph. Each node contains an integer value, a list of connected nodes, and a type attribute.
Attributes:
value (int): The integer value of the node.
type (str): The type of the node ('start', 'end', "x" or '').
con... | {
"Common Sense": null,
"Data Structures": [
"Sequence",
"Undirected Graph",
"Path"
],
"Dynamic Patterns": null,
"Geometric Objects": null,
"Mathematical Operations": [
"Conditional Branching"
],
"Spatial Transformations": null,
"Topological Relations": [
"Connection",
"Adjacen... | Validation | |
q82 | from typing import List
def solution(colors: List[str]) -> str:
"""
Determines the final color by applying transformation rules to a sequence of colors.
Args:
colors: A list of strings, where each string is a single uppercase character representing a color.
Returns:
A single uppercase... | # Problem Description
This is a color transformation problem where we need to apply a set of combination rules to transform a sequence of colors into a final single color. The program takes a list of color codes (R, G, B) as input and should return the final color (W, R, G, or B) after applying all possible transformat... | def test():
test_cases = [
(['R','R'], 'W'),
(['R','G'], 'B'),
(['B','B'], 'W'),
(['G','G'], 'W'),
(['R','R','R'], 'R'),
(['R','G','B'], 'W'),
(['R','B','R'], 'B'),
(['R','G','G','G'], 'B'),
(['R','G','B','B... | from typing import List
def solution(colors: List[str]) -> str:
"""
Determines the final color by applying transformation rules to a sequence of colors.
Args:
colors: A list of strings, where each string is a single uppercase character representing a color.
Returns:
A single uppercase... | {
"Common Sense": [
"Color Mixing"
],
"Data Structures": [
"Sequence"
],
"Dynamic Patterns": [
"Linear Increment",
"Propagation"
],
"Geometric Objects": null,
"Mathematical Operations": [
"Logical Operations",
"Conditional Branching"
],
"Spatial Transformations": [
"Conca... | Iterative Calculation | |
q82-2 | from typing import List
def solution(colors: List[str]) -> str:
"""
Determines the resulting color when combining multiple colors.
Args:
colors: A list of single uppercase characters, each representing a color.
Returns:
A single uppercase character representing the final combined colo... | # Problem Description:
The problem involves transforming a sequence of colored blocks (represented by 'R', 'G', and 'B') into a single final color by repeatedly applying a set of combination rules. The transformation rules dictate how pairs of blocks combine, either turning into a single block of the same color if they... | def test():
test_cases = [
(['R','R'], 'R'),
(['R','G'], 'B'),
(['B','B'], 'B'),
(['G','G'], 'G'),
(['R','R','R'], 'R'),
(['R','G','B'], 'B'),
(['R','B','R'], 'B'),
(['R','G','G','G'], 'B'),
(['R','G','B','B... | from typing import List
def solution(colors: List[str]) -> str:
"""
Determines the resulting color when combining multiple colors.
Args:
colors: A list of single uppercase characters, each representing a color.
Returns:
A single uppercase character representing the final combined colo... | {
"Common Sense": [
"Color Mixing"
],
"Data Structures": [
"Sequence"
],
"Dynamic Patterns": [
"Linear Increment",
"Propagation"
],
"Geometric Objects": null,
"Mathematical Operations": [
"Logical Operations",
"Conditional Branching"
],
"Spatial Transformations": [
"Conca... | Iterative Calculation | |
q83 | from typing import List
def solution(matrix: List[List[str]]) -> int:
"""
Calculates the maximum area in a matrix according to specified rules.
Args:
matrix: A 2D list containing characters ('A', 'B', 'C' ...).
Returns:
The maximum area possible based on the given rules.
"""
i... | # Problem Description
This appears to be a matrix-based problem where we need to calculate the maximum possible area of contiguous characters in a matrix following certain rules. The input is a 2D matrix containing single uppercase letters, and we need to return an integer representing the maximum valid area that can b... | def test():
test_cases = [
(
[['A']],
1
),
(
[['A','A'],
['A','A']],
4
),
(
[['A','B'],
['C','D']],
1
),
(
[['A','A','B'],
['A','A','A']]... | from typing import List
def solution(matrix: List[List[str]]) -> int:
"""
Calculates the maximum area in a matrix according to specified rules.
Args:
matrix: A 2D list containing characters ('A', 'B', 'C' ...).
Returns:
The maximum area possible based on the given rules.
"""
| {
"Common Sense": null,
"Data Structures": [
"Matrix"
],
"Dynamic Patterns": null,
"Geometric Objects": [
"Rectangle",
"Grid",
"Square"
],
"Mathematical Operations": [
"Counting"
],
"Spatial Transformations": [
"Grouping",
"Clustering"
],
"Topological Relations": [
... | Aggregation | |
q83-2 | from typing import List
def solution(matrix: List[List[str]]) -> int:
"""
Calculates the max area of the matrix according to illustrated rules.
Args:
matrix: A 2D list containing characters.
Returns:
The max area of the matrix
"""
if not matrix or not matrix[0]:
return... | # Problem Description:
The task is to find the largest rectangle submatrix within a given 2D list (matrix) of characters that consists entirely of the same character. The function should return the area of this largest rectangle. Each cell in the matrix contributes an area of 1.
# Visual Facts:
1. **Invalid Patterns**... | def test():
test_cases = [
(
[['A']],
1
),
(
[['A','A'],
['A','A']],
4
),
(
[['A','B'],
['C','D']],
1
),
(
[['A','A','B'],
['A','A','A']]... | from typing import List
def solution(matrix: List[List[str]]) -> int:
"""
Calculates the max area of the matrix according to illustrated rules.
Args:
matrix: A 2D list containing characters.
Returns:
The max area of the matrix
"""
| {
"Common Sense": null,
"Data Structures": [
"Matrix"
],
"Dynamic Patterns": null,
"Geometric Objects": [
"Rectangle",
"Grid",
"Square"
],
"Mathematical Operations": [
"Counting"
],
"Spatial Transformations": [
"Grouping",
"Clustering"
],
"Topological Relations": [
... | Aggregation | |
q84 | from typing import List
def solution(initial_blocks: List[str], operations: List[int]) -> List[str]:
"""
Calculates the final arrangement of blocks after applying a series of transformation operations.
Args:
initial_blocks: List of strings representing the initial order of blocks from top to bo... | # Problem Description
This appears to be a block transformation problem where:
- We start with an initial vertical stack of blocks labeled with letters
- We need to perform a series of transformations based on given operations
- Each operation appears to involve some form of block movement or swapping
- The goal is to ... | def test():
test_cases = [
(
["A", "B", "C"],
[],
["A", "B", "C"]
),
(
["B1", "C"],
[0],
["C", "B1"]
),
(
["B1", "B2", "C", "D"],
[1],
["C", "B1", "B2... | from typing import List
def solution(initial_blocks: List[str], operations: List[int]) -> List[str]:
"""
Calculates the final arrangement of blocks after applying a series of transformation operations.
Args:
initial_blocks: List of strings representing the initial order of blocks from top to bo... | {
"Common Sense": null,
"Data Structures": [
"Sequence"
],
"Dynamic Patterns": [
"Layered Structure"
],
"Geometric Objects": null,
"Mathematical Operations": null,
"Spatial Transformations": [
"Swapping",
"Shifting",
"Stacking"
],
"Topological Relations": [
"Adjacency"
]
} | Transformation | |
q84-2 | from typing import List
def solution(initial_blocks: List[str], operations: List[int]) -> List[str]:
"""
Calculates the final arrangement of blocks after applying a series of transformation operations.
Args:
initial_blocks: List of strings representing the initial order of blocks from top to bo... | # Problem Description
This problem involves rearranging a vertical stack of blocks labeled with letters based on a series of operations. Each operation specifies an index in the stack, and the transformation involves lifting the block at that index and all blocks above it, then moving all blocks below the lifted block ... | def test():
test_cases = [
(
["A", "B", "C"],
[],
["A", "B", "C"]
),
(
["B1", "C"],
[0],
["C", "B1"]
),
(
["B1", "B2", "C", "D"],
[1],
["C", "D","B1",... | from typing import List
def solution(initial_blocks: List[str], operations: List[int]) -> List[str]:
"""
Calculates the final arrangement of blocks after applying a series of transformation operations.
Args:
initial_blocks: List of strings representing the initial order of blocks from top to bo... | {
"Common Sense": null,
"Data Structures": [
"Sequence"
],
"Dynamic Patterns": [
"Layered Structure"
],
"Geometric Objects": null,
"Mathematical Operations": null,
"Spatial Transformations": [
"Swapping",
"Shifting",
"Stacking"
],
"Topological Relations": [
"Adjacency"
]
} | Transformation | |
q84-3 | from typing import List
def solution(initial_blocks: List[str], operations: List[int]) -> List[str]:
"""
return the transformed blocks after applying the operations.
Args:
initial_blocks: List of strings representing the initial blocks
operations: List of integers representing the opera... | # Problem Description
This is a block rearrangement problem where we need to:
- Transform a vertical stack of blocks through a series of operations
- Each operation moves a block from a specified index to the top
- The remaining blocks maintain their relative positions
- Process multiple operations sequentially based o... | def test():
test_cases = [
(
["A", "B", "C"],
[],
["A", "B", "C"]
),
(
["B1", "C"],
[1],
["C", "B1"]
),
(
["B1", "B2", "C", "D"],
[2],
["C", "B1", "B2... | from typing import List
def solution(initial_blocks: List[str], operations: List[int]) -> List[str]:
"""
return the transformed blocks after applying the operations.
Args:
initial_blocks: List of strings representing the initial blocks
operations: List of integers representing the opera... | {
"Common Sense": null,
"Data Structures": [
"Sequence"
],
"Dynamic Patterns": [
"Layered Structure"
],
"Geometric Objects": null,
"Mathematical Operations": null,
"Spatial Transformations": [
"Swapping",
"Shifting",
"Stacking"
],
"Topological Relations": [
"Adjacency"
]
} | Transformation | |
q85 | from typing import Tuple, Set
def solution(towers: Set[Tuple[int, int]]) -> Set[Tuple[int, int]]:
"""
Identifies watchtowers that are not connected to any others based on given connection rules.
Args:
towers: A set of tuples, each containing (x, y) coordinates of a watchtower.
Returns:
... | # Problem Description
This is a watchtower connectivity problem where we need to identify isolated watchtowers in a 2D grid system. The main goal is to determine which watchtowers are not connected to any network of other watchtowers, based on specific connection rules. The function should return the coordinates of the... | def test():
test_cases = [
{
"input": set(()),
"expected": set()
},
{
"input": set([(1,1), (3,4)]),
"expected": set([(1,1), (3,4)])
},
{
"input": set([(1,1), (1,2)]),
"expected": set()
},
... | from typing import Tuple, Set
def solution(towers: Set[Tuple[int, int]]) -> Set[Tuple[int, int]]:
"""
Identifies watchtowers that are not connected to any others based on given connection rules.
Args:
towers: A set of tuples, each containing (x, y) coordinates of a watchtower.
Returns:
... | {
"Common Sense": null,
"Data Structures": null,
"Dynamic Patterns": [
"Propagation"
],
"Geometric Objects": [
"Coordinate System",
"Grid",
"Line",
"Distance",
"Point"
],
"Mathematical Operations": null,
"Spatial Transformations": null,
"Topological Relations": [
"Connectio... | Validation | |
q85-2 | from typing import Tuple, Set
def solution(towers: Set[Tuple[int, int]]) -> Set[Tuple[int, int]]:
"""
Identifies watchtowers that are not connected to any others based on given connection rules.
Args:
towers: A set of tuples, each containing (x, y) coordinates of a watchtower.
Returns:
... | # Problem Description
The problem involves identifying watchtowers that are not connected to any other watchtowers based on specific connection rules. Each watchtower is represented by its coordinates in a 2D plane. A watchtower is considered connected if there is at least one other watchtower within a radius of 3 unit... | def test():
test_cases = [
{
"input": set(()),
"expected": set()
},
{
"input": set([(1,1), (3,4), (10,10), (10,13)]),
"expected": set([(1,1), (3,4)])
},
{
"input": set([(1,1), (1,2), (0,11), (0,8), (0,14.1)]),
... | from typing import Tuple, Set
def solution(towers: Set[Tuple[int, int]]) -> Set[Tuple[int, int]]:
"""
Identifies watchtowers that are not connected to any others based on given connection rules.
Args:
towers: A set of tuples, each containing (x, y) coordinates of a watchtower.
Returns:
... | {
"Common Sense": null,
"Data Structures": null,
"Dynamic Patterns": [
"Propagation"
],
"Geometric Objects": [
"Coordinate System",
"Grid",
"Line",
"Distance",
"Point",
"Circle"
],
"Mathematical Operations": null,
"Spatial Transformations": null,
"Topological Relations": [
... | Validation | |
q86 | from typing import List, Tuple
def solution(rectangles: List[int], target_idx: int) -> int:
"""
Calculate the U value between two adjacent rectangles.
Args:
rectangles: A list of integers representing rectangle heights from left to right.
target_idx: The 0-based index position at which to ... | # Problem Description
This is a problem about calculating a "U value" between adjacent rectangles in a circular arrangement of rectangles. The U value appears to be a measurement derived from the heights of two adjacent rectangles. The problem requires implementing a function that takes a list of rectangle heights and ... |
def test():
test_cases = [
{
"rectangles": [8, 6, 2, 3, 5],
"target_idx": 0,
"expected": 12
},
{
"rectangles": [8, 6, 2, 3, 5],
"target_idx": 1,
"expected": 4
},
{
"rectangles": [8, 6, 2, 3,... | from typing import List, Tuple
def solution(rectangles: List[int], target_idx: int) -> int:
"""
Calculate the U value between two adjacent rectangles.
Args:
rectangles: A list of integers representing rectangle heights from left to right.
target_idx: The 0-based index position at which to ... | {
"Common Sense": null,
"Data Structures": [
"Sequence"
],
"Dynamic Patterns": null,
"Geometric Objects": [
"Rectangle"
],
"Mathematical Operations": [
"Value Comparison",
"Basic Arithmetic"
],
"Spatial Transformations": [
"Grouping"
],
"Topological Relations": [
"Adjacency... | Direct Calculation | |
q86-2 | from typing import List, Tuple
def solution(rectangles: List[int], target_idx: int) -> int:
"""
Calculate the U value between two adjacent rectangles.
Args:
rectangles: A list of integers representing rectangle heights from left to right.
target_idx: The 0-based index position at which to ... | # Problem Description:
The problem involves calculating a specific value, referred to as the "X value," between two adjacent rectangles in a list of rectangle heights. The function takes in a list of integers representing the heights of these rectangles and an index position. The goal is to compute the X value for the ... | def test():
test_cases = [
{
"rectangles": [8, 6, 2, 3, 5],
"target_idx": 0,
"expected": 2
},
{
"rectangles": [8, 6, 2, 3, 5],
"target_idx": 1,
"expected": 4
},
{
"rectangles": [8, 6, 2, 3, 5... | from typing import List, Tuple
def solution(rectangles: List[int], target_idx: int) -> int:
"""
Calculate the U value between two adjacent rectangles.
Args:
rectangles: A list of integers representing rectangle heights from left to right.
target_idx: The 0-based index position at which to ... | {
"Common Sense": null,
"Data Structures": [
"Sequence"
],
"Dynamic Patterns": null,
"Geometric Objects": [
"Rectangle"
],
"Mathematical Operations": [
"Value Comparison",
"Basic Arithmetic"
],
"Spatial Transformations": [
"Grouping"
],
"Topological Relations": [
"Adjacency... | Direct Calculation | |
q86-3 | from typing import List, Tuple
def solution(rectangles: List[int], target_idx: int) -> int:
"""
Calculate the U value between two adjacent rectangles.
Args:
rectangles: A list of integers representing rectangle heights from left to right.
target_idx: The 0-based index position at which to ... | # Problem Description
The task is to calculate the "U value" for a given rectangle in a list of rectangles. The U value is determined by the heights of the rectangles and their positions. Specifically, the U value for a rectangle at a given index is calculated based on the heights of the rectangles adjacent to it. The ... | def test():
test_cases = [
{
"rectangles": [8, 6, 2, 3, 5],
"target_idx": 1,
"expected": 12
},
{
"rectangles": [8, 6, 2, 3, 5],
"target_idx": 2,
"expected": 4
},
{
"rectangles": [8, 6, 2, 3, ... | from typing import List, Tuple
def solution(rectangles: List[int], target_idx: int) -> int:
"""
Calculate the U value between two adjacent rectangles.
Args:
rectangles: A list of integers representing rectangle heights from left to right.
target_idx: The 0-based index position at which to ... | {
"Common Sense": null,
"Data Structures": [
"Sequence"
],
"Dynamic Patterns": null,
"Geometric Objects": [
"Rectangle"
],
"Mathematical Operations": [
"Value Comparison",
"Basic Arithmetic"
],
"Spatial Transformations": [
"Grouping"
],
"Topological Relations": [
"Adjacency... | Direct Calculation | |
q87 | from typing import List, Tuple
def solution(grid: List[List[str]], path: List[Tuple[int, int]]) -> bool:
"""
Determines if the given path forms a valid connected route from the leftmost column to the rightmost column.
Args:
grid: A 2D list representing the grid, where each cell contains a string r... | # Problem Description
This is a pipe connection validation problem where we need to verify if a given sequence of coordinates forms a valid path for water to flow by accessing connected pipe segments from left to right. The path must follow proper pipe connections and reach the rightmost column without any breaks or in... | def test():
test_cases = [
([["-", "t", "f"], ["f", "l", "j"]],[(0,0),(0,1),(1,1),(1,2),(0,2)],True),
([["f", "t", "-"], ["j", "l", "j"]],[(0,0),(0,1),(1,1),(1,2),(0,2)],False),
([["-", "t", "f"], ["f", "l", "j"]],[(0,0),(0,1),(1,1)],False),
([["-", "-", "-"]], [(0,0),(0,1),(0,2)],Tr... | from typing import List, Tuple
def solution(grid: List[List[str]], path: List[Tuple[int, int]]) -> bool:
"""
Determines if the given path forms a valid connected route from the leftmost column to the rightmost column.
Args:
grid: A 2D list representing the grid, where each cell contains a string r... | {
"Common Sense": null,
"Data Structures": [
"Matrix",
"Path"
],
"Dynamic Patterns": [
"Propagation"
],
"Geometric Objects": [
"Grid",
"Arrow",
"Line"
],
"Mathematical Operations": null,
"Spatial Transformations": null,
"Topological Relations": [
"Adjacency",
"Connect... | Validation | |
q88 | from typing import List
def solution(init_seq: List[str], ptr_pos: int) -> List[str]:
"""
Transforms an initial sequence based on a pointer position according to specific rules.
Args:
init_seq: List of single characters representing the initial sequence
ptr_pos: pointer position (1-based i... | # Problem Description
This is a sequence transformation problem where:
- Given an initial sequence and a pointer position
- The goal is to transform the sequence following specific rules about moving elements
- The transformation involves moving certain elements based on the pointer position
- Uses 1-based indexing for... | def test():
test_cases = [
{
"input": (["A", "B", "C"], 1),
"expected": ['C', 'A', 'B']
},
{
"input": (["A", "B", "C"], 2),
"expected": ['A', 'C', 'B']
},
{
"input": (["A", "B", "C"], 3),
"expected": ['A'... | from typing import List
def solution(init_seq: List[str], ptr_pos: int) -> List[str]:
"""
Transforms an initial sequence based on a pointer position according to specific rules.
Args:
init_seq: List of single characters representing the initial sequence
ptr_pos: pointer position (1-based i... | {
"Common Sense": null,
"Data Structures": [
"Sequence"
],
"Dynamic Patterns": null,
"Geometric Objects": [
"Circle",
"Arrow"
],
"Mathematical Operations": [
"Sorting"
],
"Spatial Transformations": [
"Swapping",
"Shifting"
],
"Topological Relations": null
} | Transformation | |
q88-2 | from typing import List
def solution(init_seq: List[str], ptr_pos: int) -> List[str]:
"""
Transforms an initial sequence based on a pointer position according to specific rules.
Args:
init_seq: List of single characters representing the initial sequence
ptr_pos: pointer position (1-based i... | # Problem Description
This problem involves transforming an initial sequence of characters based on a given pointer position. The transformation follows specific rules where the elements before the pointer position (inclusive) are cyclically shifted. The goal is to determine the final sequence after applying these tran... | def test():
test_cases = [
{
"input": (["A", "B", "C"], 1),
"expected": ['A', 'B', 'C']
},
{
"input": (["A", "B", "C"], 2),
"expected": ['B', 'A', 'C']
},
{
"input": (["A", "B", "C"], 3),
"expected": ['B'... | from typing import List
def solution(init_seq: List[str], ptr_pos: int) -> List[str]:
"""
Transforms an initial sequence based on a pointer position according to specific rules.
Args:
init_seq: List of single characters representing the initial sequence
ptr_pos: pointer position (1-based i... | {
"Common Sense": null,
"Data Structures": [
"Sequence"
],
"Dynamic Patterns": null,
"Geometric Objects": [
"Circle",
"Arrow"
],
"Mathematical Operations": [
"Sorting"
],
"Spatial Transformations": [
"Swapping",
"Shifting"
],
"Topological Relations": null
} | Transformation | |
q88-3 | from typing import List
def solution(init_seq: List[str]) -> List[str]:
"""
Transforms an initial sequence based on a pointer position according to specific rules.
Args:
init_seq: List of single characters representing the initial sequence
Returns:
List of single characters representi... | # Problem Description
The problem involves transforming an initial sequence of characters or numbers by shifting all elements one position to the right, with the last element moving to the first position. This transformation is akin to a circular rotation of the sequence.
# Visual Facts
1. **Example 1:**
- Initial ... | def test():
test_cases = [
{
"input": (["A", "B", "C"]),
"expected": ['C', 'A', 'B']
},
{
"input": (["A", "B", "C", "D"]),
"expected": ['D', 'A', 'B', 'C']
},
{
"input": (["A", "D" ,"B", "C"]),
"expected... | from typing import List
def solution(init_seq: List[str]) -> List[str]:
"""
Transforms an initial sequence based on a pointer position according to specific rules.
Args:
init_seq: List of single characters representing the initial sequence
Returns:
List of single characters representi... | {
"Common Sense": null,
"Data Structures": [
"Sequence"
],
"Dynamic Patterns": null,
"Geometric Objects": [
"Circle",
"Arrow"
],
"Mathematical Operations": [
"Sorting"
],
"Spatial Transformations": [
"Swapping",
"Shifting"
],
"Topological Relations": null
} | Transformation | |
q89 | from typing import List, Tuple
def solution(initial_matrix: List[List[int]], operations: List[Tuple[str, str]]) -> bool:
"""
Determines whether a cube is ordered after performing a sequence of operations.
Args:
initial_matrix: A 3x3 matrix represented as a list of lists, where each inner list cont... | # Problem Description
This is a cube restoration verification problem where:
- We have a 3×3 matrix (cube face) with initial values
- We can perform operations on rows and columns
- Each operation involves shifting elements cyclically in a specified direction
- We need to determine if the cube is ordered
- The goal is ... | def test():
test_cases = [
# Test Case 1: Simple row shift to restore
{
"input_matrix": [
[2, 3, 1],
[4, 5, 6],
[7, 8, 9]
],
"operations": [("D", "R"), ("D", "R"), ("D", "L")],
"expected": True
},... | from typing import List, Tuple
def solution(initial_matrix: List[List[int]], operations: List[Tuple[str, str]]) -> bool:
"""
Determines whether a cube is ordered after performing a sequence of operations.
Args:
initial_matrix: A 3x3 matrix represented as a list of lists, where each inner list cont... | {
"Common Sense": null,
"Data Structures": [
"Matrix",
"Sequence"
],
"Dynamic Patterns": [
"Cyclic Motion"
],
"Geometric Objects": null,
"Mathematical Operations": [
"Sorting"
],
"Spatial Transformations": [
"Swapping",
"Shifting"
],
"Topological Relations": [
"Adjacenc... | Transformation | |
q89-2 | from typing import List, Tuple
def solution(initial_matrix: List[List[int]], operations: List[Tuple[str, str]]) -> bool:
"""
Determines whether a cube is ordered after performing a sequence of operations.
Args:
initial_matrix: A 3x3 matrix represented as a list of lists, where each inner list cont... | # Problem Description
This is a cube restoration verification problem where:
- We have a 3×3 matrix (cube face) with initial values
- We can perform operations on rows and columns
- Each operation involves shifting elements cyclically in a specified direction
- The operation symbol and the actual operation direction ar... | def test():
test_cases = [
# Test Case 1: Simple row shift to restore
{
"input_matrix": [
[2, 3, 1],
[4, 5, 6],
[7, 8, 9]
],
"operations": [("D", "L"), ("D", "L"), ("D", "R")],
"expected": True
},... | from typing import List, Tuple
def solution(initial_matrix: List[List[int]], operations: List[Tuple[str, str]]) -> bool:
"""
Determines whether a cube is ordered after performing a sequence of operations.
Args:
initial_matrix: A 3x3 matrix represented as a list of lists, where each inner list cont... | {
"Common Sense": null,
"Data Structures": [
"Matrix",
"Sequence"
],
"Dynamic Patterns": [
"Cyclic Motion"
],
"Geometric Objects": null,
"Mathematical Operations": [
"Sorting"
],
"Spatial Transformations": [
"Swapping",
"Shifting"
],
"Topological Relations": [
"Adjacenc... | Transformation | |
q89-3 | from typing import List, Tuple
def solution(initial_matrix: List[List[int]], operations: List[Tuple[str, str]]) -> bool:
"""
Determines whether a cube is ordered after performing a sequence of operations.
Args:
initial_matrix: A 3x3 matrix represented as a list of lists, where each inner list cont... | # Problem Description
This is a cube restoration verification problem where:
- We have a 3×3 matrix (cube face) with initial values
- We can perform operations on rows and columns
- Each operation involves shifting elements cyclically in a specified direction
- We need to determine if the cube is ordered
- The goal is ... | def test():
test_cases = [
# Test Case 1: Simple row shift to restore
{
"input_matrix": [
[9, 8, 7],
[6, 5, 4],
[1, 3, 2]
],
"operations": [("F", "L"), ("F", "L"), ("F", "R")],
"expected": True
},... | from typing import List, Tuple
def solution(initial_matrix: List[List[int]], operations: List[Tuple[str, str]]) -> bool:
"""
Determines whether a cube is ordered after performing a sequence of operations.
Args:
initial_matrix: A 3x3 matrix represented as a list of lists, where each inner list cont... | {
"Common Sense": null,
"Data Structures": [
"Matrix",
"Sequence"
],
"Dynamic Patterns": [
"Cyclic Motion"
],
"Geometric Objects": null,
"Mathematical Operations": [
"Sorting"
],
"Spatial Transformations": [
"Swapping",
"Shifting"
],
"Topological Relations": [
"Adjacenc... | Transformation | |
q9 | def solution(matrix: list[list[int]]) -> list[int]:
"""
Traverses a given matrix according to the snake pattern shown in the figure.
Parameters:
matrix (list[list[int]]): A 2D list (N x N matrix) containing integers that need to be traversed.
Returns:
list[int]: A list of integ... | # Problem Description
This is a matrix traversal problem where we need to implement a specific "snake-like" pattern traversal of a square matrix (N x N). The traversal follows a vertical zigzag pattern, moving down and up through columns while progressing from left to right. The function should return the elements in t... | def test():
test_cases = [
([[1, 2], [3, 4]], [1, 3, 4, 2]),
([[9, 9, 9], [9, 9, 9], [9, 9, 9]], [9, 9, 9, 9, 9, 9, 9, 9, 9]),
([[99, 102], [672, 5]], [99, 672, 5, 102]),
([[1, 2, 3], [4, 5, 6], [7, 8, 9]], [1, 4, 7, 8, 5, 2, 3, 6, 9]),
([[63, 22, 17], [98, 21, 3], [76, 33, 9... | def solution(matrix: list[list[int]]) -> list[int]:
"""
Traverses a given matrix according to the snake pattern shown in the figure.
Parameters:
matrix (list[list[int]]): A 2D list (N x N matrix) containing integers that need to be traversed.
Returns:
list[int]: A list of integ... | {
"Common Sense": null,
"Data Structures": [
"Path",
"Matrix",
"Directed Graph"
],
"Dynamic Patterns": [
"Zigzag"
],
"Geometric Objects": null,
"Mathematical Operations": null,
"Spatial Transformations": null,
"Topological Relations": [
"Connectivity",
"Adjacency"
]
} | Transformation | |
q9-2 | def solution(matrix: list[list[int]]) -> list[int]:
"""
Traverses a given matrix according to the snake pattern shown in the figure.
Parameters:
matrix (list[list[int]]): A 2D list (N x N matrix) containing integers that need to be traversed.
Returns:
list[int]: A list of integ... | # Problem Description
This is a matrix traversal problem requiring implementation of a specific snake-like pattern in a square matrix (N x N). The traversal follows a vertical zigzag pattern, starting from the bottom-right corner and moving in alternating upward and downward directions while progressing from right to l... | def test():
test_cases = [
([[1, 2], [3, 4]], [4, 2, 1, 3]),
([[9, 9, 9], [9, 9, 9], [9, 9, 9]], [9, 9, 9, 9, 9, 9, 9, 9, 9]),
([[99, 102], [672, 5]], [5, 102, 99, 672]),
([[1, 2, 3], [4, 5, 6], [7, 8, 9]], [9, 6, 3, 2, 5, 8, 7, 4, 1]),
([[63, 22, 17], [98, 21, 3], [76, 33, 9... | def solution(matrix: list[list[int]]) -> list[int]:
"""
Traverses a given matrix according to the snake pattern shown in the figure.
Parameters:
matrix (list[list[int]]): A 2D list (N x N matrix) containing integers that need to be traversed.
Returns:
list[int]: A list of integ... | {
"Common Sense": null,
"Data Structures": [
"Path",
"Matrix",
"Directed Graph"
],
"Dynamic Patterns": [
"Zigzag"
],
"Geometric Objects": null,
"Mathematical Operations": null,
"Spatial Transformations": null,
"Topological Relations": [
"Connectivity",
"Adjacency"
]
} | Transformation | |
q9-3 | def solution(matrix: list[list[int]]) -> list[int]:
"""
Traverses a given matrix according to the snake pattern shown in the figure.
Parameters:
matrix (list[list[int]]): A 2D list (N x N matrix) containing integers that need to be traversed.
Returns:
list[int]: A list of integ... | # Problem Description
This is a matrix traversal problem requiring implementation of a specific horizontal "snake-like" pattern traversal of a square matrix (N x N). Starting from the bottom-right corner, the traversal follows a horizontal zigzag pattern, alternating between leftward and rightward movements while progr... | def test():
test_cases = [
([[1, 2], [3, 4]], [4, 3, 1, 2]),
([[9, 9, 9], [9, 9, 9], [9, 9, 9]], [9, 9, 9, 9, 9, 9, 9, 9, 9]),
([[99, 102], [672, 5]], [5, 672, 99, 102]),
([[1, 2, 3], [4, 5, 6], [7, 8, 9]], [9, 8, 7, 4, 5, 6, 3, 2, 1]),
([[63, 22, 17], [98, 21, 3], [76, 33, 9... | def solution(matrix: list[list[int]]) -> list[int]:
"""
Traverses a given matrix according to the snake pattern shown in the figure.
Parameters:
matrix (list[list[int]]): A 2D list (N x N matrix) containing integers that need to be traversed.
Returns:
list[int]: A list of integ... | {
"Common Sense": null,
"Data Structures": [
"Path",
"Matrix",
"Directed Graph"
],
"Dynamic Patterns": [
"Zigzag"
],
"Geometric Objects": null,
"Mathematical Operations": null,
"Spatial Transformations": null,
"Topological Relations": [
"Connectivity",
"Adjacency"
]
} | Transformation | |
q90 | from typing import List, Tuple
from collections import defaultdict
def solution(seed_positions: List[Tuple[int, int]], field_size: int, T: int) -> int:
"""
Determines which watermelon seeds remain alive at Day T, based on field size and growth rules.
Args:
seed_positions: List of (x,... | # Problem Description
This is a grid-based watermelon growth simulation problem where:
- Watermelons start from seeds placed on a square grid
- The seed span in the certain directions each day
- The simulation runs for T days
- Seeds can die under certain conditions
- We need to track which seeds survive until day T
#... | def test():
test_cases = [
{
"input": ([(2, 2)], 5, 3),
"expected": [(2, 2)]
},
{
"input": ([(2, 2)], 5, 4),
"expected": []
},
{
"input": ([(2, 1)], 4, 2),
"expected": [(2, 1)]
},
{
... | from typing import List, Tuple
from collections import defaultdict
def solution(seed_positions: List[Tuple[int, int]], field_size: int, T: int) -> int:
"""
Determines which watermelon seeds remain alive at Day T, based on field size and growth rules.
Args:
seed_positions: List of (x,... | {
"Common Sense": null,
"Data Structures": [
"Matrix"
],
"Dynamic Patterns": [
"Propagation",
"Cross Pattern"
],
"Geometric Objects": [
"Square",
"Grid"
],
"Mathematical Operations": null,
"Spatial Transformations": [
"Grouping",
"Propagation"
],
"Topological Relations"... | Iterative Calculation | |
q90-2 | from typing import List, Tuple
from collections import defaultdict
def solution(seed_positions: List[Tuple[int, int]], field_size: int, T: int) -> int:
"""
Determines which watermelon seeds remain alive at Day T, based on field size and growth rules.
Args:
seed_positions: List of (x, y) coordinate... | # Problem Description
This is a grid-based watermelon growth simulation problem where:
- Watermelons start from seeds placed on a square grid
- Each seed grows in 4 directions (up, down, left, right) each day
- The simulation runs for T days
- Seeds can die under certain conditions
- We need to track which seeds surviv... | def test():
test_cases = [
{
"input": ([(2, 2)], 5, 3),
"expected": [(2, 2)]
},
{
"input": ([(2, 2)], 5, 4),
"expected": []
},
{
"input": ([(2, 1)], 4, 2),
"expected": [(2, 1)]
},
{
... | from typing import List, Tuple
from collections import defaultdict
def solution(seed_positions: List[Tuple[int, int]], field_size: int, T: int) -> int:
"""
Determines which watermelon seeds remain alive at Day T, based on field size and growth rules.
Args:
seed_positions: List of (x,... | {
"Common Sense": null,
"Data Structures": [
"Matrix"
],
"Dynamic Patterns": [
"Propagation",
"Cross Pattern"
],
"Geometric Objects": [
"Square",
"Grid"
],
"Mathematical Operations": null,
"Spatial Transformations": [
"Grouping",
"Propagation"
],
"Topological Relations"... | Iterative Calculation | |
q90-3 | from typing import List, Tuple
from collections import defaultdict
def solution(seed_positions: List[Tuple[int, int]], field_size: int, T: int) -> int:
"""
Determines which watermelon seeds remain alive at Day T, based on field size and growth rules.
Args:
seed_positions: List of (x, y) coordinate... | # Problem Description
This is a grid-based watermelon growth simulation problem where:
- Watermelons start from seeds placed on a square grid
- Each seed grows in 4 directions (up, down, left, right) each day
- The simulation runs for T days
- Seeds can die under certain conditions
- We need to track which seeds surviv... |
def test():
test_cases = [
{
"input": ([(2, 2)], 5, 3),
"expected": [(2, 2)]
},
{
"input": ([(2, 2)], 5, 4),
"expected": [(2, 2)]
},
{
"input": ([(2, 1)], 4, 2),
"expected": [(2, 1)]
},
{... | from typing import List, Tuple
from collections import defaultdict
def solution(seed_positions: List[Tuple[int, int]], field_size: int, T: int) -> int:
"""
Determines which watermelon seeds remain alive at Day T, based on field size and growth rules.
Args:
seed_positions: List of (x,... | {
"Common Sense": null,
"Data Structures": [
"Matrix"
],
"Dynamic Patterns": [
"Propagation",
"Cross Pattern"
],
"Geometric Objects": [
"Square",
"Grid"
],
"Mathematical Operations": null,
"Spatial Transformations": [
"Grouping",
"Propagation"
],
"Topological Relations"... | Iterative Calculation | |
q91 | from typing import Tuple
import math
def solution(red: Tuple[float, float], angle: int, green: Tuple[float, float]) -> Tuple[float, float]:
"""
Calculate the new coordinates of a circle's center after applying the transformation.
Args:
red: A tuple (x, y) representing the coordinates of th... | # Problem Description
This is a geometric transformation problem where we need to:
1. Calculate the new position of a circle's center after rotation
2. The rotation occurs around a fixed point (green point)
3. The rotation angle is given in degrees (can be positive or negative)
4. The circle maintains its size and shap... | def test():
def tuples_almost_equal(t1, t2, tol: float = 1e-2) -> bool:
return all(abs(a - b) < tol for a, b in zip(t1, t2))
test_cases = [
{
'red': (5.0, 5.0),
'angle': 90,
'green': (3.0, 5.0),
'expected': (3.0, 7.0)
},
{
... | from typing import Tuple
def solution(red: Tuple[float, float], angle: int, green: Tuple[float, float]) -> Tuple[float, float]:
"""
Calculate the new coordinates of a circle's center after applying the transformation.
Args:
red: A tuple (x, y) representing the coordinates of the red point.... | {
"Common Sense": null,
"Data Structures": null,
"Dynamic Patterns": [
"Circular Motion"
],
"Geometric Objects": [
"Coordinate System",
"Angle",
"Point",
"Radius",
"Grid",
"Circle",
"Line Segment",
"Arrow"
],
"Mathematical Operations": null,
"Spatial Transformations":... | Direct Calculation | |
q91-2 | from typing import Tuple
import math
def solution(red: Tuple[float, float], angle: int, green: Tuple[float, float]) -> float:
"""
Calculate the area of the blue sector.
Args:
red: A tuple (x, y) representing the coordinates of the red point.
angle: An integer representing the rotation angl... | # Problem Description
This is a geometric transformation problem where we need to:
1. Calculate the new position of a circle's center after rotation
2. The rotation occurs around a fixed point (green point)
3. The rotation angle is given in degrees (can be positive or negative)
4. The circle maintains its size and shap... | def test():
def tuples_almost_equal(t1, t2, tol: float = 1e-2) -> bool:
return abs(t1 - t2) < tol
test_cases = [
{
'red': (5.0, 5.0),
'angle': 90,
'green': (3.0, 5.0),
'expected': 3.14
},
{
'red': (5.0, 5.0),
... | from typing import Tuple
import math
def solution(red: Tuple[float, float], angle: int, green: Tuple[float, float]) -> float:
"""
Calculate the area of the blue sector.
Args:
red: A tuple (x, y) representing the coordinates of the red point.
angle: An integer representing the rotat... | {
"Common Sense": null,
"Data Structures": null,
"Dynamic Patterns": [
"Circular Motion"
],
"Geometric Objects": [
"Coordinate System",
"Angle",
"Point",
"Radius",
"Grid",
"Circle",
"Line Segment",
"Arrow"
],
"Mathematical Operations": null,
"Spatial Transformations":... | Direct Calculation | |
q91-3 | from typing import Tuple
import math
def solution(red: Tuple[float, float], angle: int, green: Tuple[float, float]) -> float:
"""
Calculate the area of the blue sector.
Args:
red: A tuple (x, y) representing the coordinates of the red point.
angle: An integer representing the rotation angl... | # Problem Description
This is a geometric transformation problem where we need to:
1. Calculate the new position of a circle's center after rotation
2. The rotation occurs around a fixed point (green point)
3. The rotation angle is given in degrees (can be positive or negative)
4. The circle maintains its size and shap... | def test():
def tuples_almost_equal(t1, t2, tol: float = 1e-2) -> bool:
return abs(t1 - t2) < tol
test_cases = [
{
'red': (5.0, 5.0),
'angle': 90,
'green': (3.0, 5.0),
'expected':2.0
},
{
'red': (5.0, 5.0),
... | from typing import Tuple
import math
def solution(red: Tuple[float, float], angle: int, green: Tuple[float, float]) -> float:
"""
Calculate the area of the blue sector.
Args:
red: A tuple (x, y) representing the coordinates of the red point.
angle: An integer representing the rotat... | {
"Common Sense": null,
"Data Structures": null,
"Dynamic Patterns": [
"Circular Motion"
],
"Geometric Objects": [
"Coordinate System",
"Angle",
"Point",
"Radius",
"Triangle",
"Grid",
"Circle",
"Line Segment",
"Arrow"
],
"Mathematical Operations": null,
"Spatial T... | Direct Calculation | |
q92 | def solution(target: str) -> int:
"""
Calculates the cost of a target string according to defined rules.
Args:
target: The input string to calculate cost for
Returns:
The total cost as an integer
"""
# Initialize total cost
total_cost = 0
# Start from the initial posit... | # Problem Description
This is a string processing problem where we need to calculate the total cost of forming a target string using a circular disk mechanism. The disk contains lowercase letters (a-z) and a special 'check' character arranged in a circle. We need to select each character of the target string by rotatin... | def test():
test_cases = [
{"input": "a", "expected": 2},
{"input": "abc", "expected": 12},
{"input": "az", "expected": 4},
{"input": "jay", "expected": 26},
{"input": "zaz", "expected": 6},
{"input": "humanevalv", "expected": 138},
{"input": "paperaccepted",... | def solution(target: str) -> int:
"""
Calculates the cost of a target string according to defined rules.
Args:
target: The input string to calculate cost for
Returns:
The total cost as an integer
"""
| {
"Common Sense": [
"Knob"
],
"Data Structures": null,
"Dynamic Patterns": [
"Circular Motion",
"Circular Arrangement",
"Cyclic Motion"
],
"Geometric Objects": [
"Circle",
"Arrow"
],
"Mathematical Operations": [
"Counting"
],
"Spatial Transformations": [
"Rotation"
... | Iterative Calculation | |
q92-2 | def solution(target: str) -> int:
"""
Calculates the cost of a target string according to defined rules.
Args:
target: The input string to calculate cost for
Returns:
The total cost as an integer
"""
return len(target) * 27
| # Problem Description
This is a string processing problem where we need to calculate the total cost of forming a target string using a circular disk mechanism. The disk contains lowercase letters (a-z) and a special 'check' character arranged in a circle. We need to select each character of the target string by rotatin... |
def test():
test_cases = [
{"input": "a", "expected": 27},
{"input": "abc", "expected": 81},
{"input": "az", "expected": 54},
{"input": "jay", "expected": 81},
{"input": "zaz", "expected": 81},
{"input": "humanevalv", "expected": 270},
{"input": "paperaccept... | def solution(target: str) -> int:
"""
Calculates the cost of a target string according to defined rules.
Args:
target: The input string to calculate cost for
Returns:
The total cost as an integer
"""
| {
"Common Sense": [
"Knob"
],
"Data Structures": null,
"Dynamic Patterns": [
"Circular Motion",
"Circular Arrangement",
"Cyclic Motion"
],
"Geometric Objects": [
"Circle",
"Arrow"
],
"Mathematical Operations": [
"Counting"
],
"Spatial Transformations": [
"Rotation"
... | Iterative Calculation | |
q92-3 | def solution(target: str) -> int:
"""
Calculates the cost of a target string according to defined rules.
Args:
target: The input string to calculate cost for
Returns:
The total cost as an integer
"""
return len(target) * 27
| # Problem Description
This is a string processing problem where we need to calculate the total cost of forming a target string using a circular disk mechanism. The disk contains lowercase letters (a-z) and a special 'check' character arranged in a circle. We need to select each character of the target string by rotatin... |
def test():
test_cases = [
{"input": "a", "expected": 27},
{"input": "abc", "expected": 81},
{"input": "az", "expected": 54},
{"input": "jay", "expected": 81},
{"input": "zaz", "expected": 81},
{"input": "humanevalv", "expected": 270},
{"input": "paperaccept... | def solution(target: str) -> int:
"""
Calculates the cost of a target string according to defined rules.
Args:
target: The input string to calculate cost for
Returns:
The total cost as an integer
"""
| {
"Common Sense": [
"Knob"
],
"Data Structures": null,
"Dynamic Patterns": [
"Circular Motion",
"Circular Arrangement",
"Cyclic Motion"
],
"Geometric Objects": [
"Circle",
"Arrow"
],
"Mathematical Operations": [
"Counting"
],
"Spatial Transformations": [
"Rotation"
... | Iterative Calculation | |
q93 | from typing import List
def solution(sequence1: List[int], sequence2: List[int]) -> int:
"""
Applies a custom operation to two integer sequences and returns their combined result.
Args:
sequence1: First sequence of integers
sequence2: Second sequence of integers
Returns:
Integ... | # Problem Description
This is a problem about implementing a custom binary operation on two sequences of integers. The operation involves binary conversions, bitwise OR operations, and addition. Given two sequences of integers, we need to process each sequence independently using binary operations and then combine thei... | def test():
test_cases = [
{"input": ([2, 4, 3], [3, 3, 12]), "expected": 22},
{"input": ([4, 5, 6], [3, 1, 7]), "expected": 14},
{"input": ([1], [2]), "expected": 3},
{"input": ([0, 0, 0], [0, 0, 0]), "expected": 0},
{"input": ([8, 16, 32], [7, 3]), "expected": 63},
... | from typing import List
def solution(sequence1: List[int], sequence2: List[int]) -> int:
"""
Applies a custom operation to two integer sequences and returns their combined result.
Args:
sequence1: First sequence of integers
sequence2: Second sequence of integers
Returns:
Integ... | {
"Common Sense": null,
"Data Structures": [
"Sequence"
],
"Dynamic Patterns": null,
"Geometric Objects": null,
"Mathematical Operations": [
"Logical Operations",
"Basic Arithmetic",
"Value Comparison"
],
"Spatial Transformations": null,
"Topological Relations": null
} | Direct Calculation | |
q93-2 | from typing import List
def solution(sequence1: List[int], sequence2: List[int]) -> int:
"""
Applies a custom operation to two integer sequences and returns their combined result.
Args:
sequence1: First sequence of integers
sequence2: Second sequence of integers
Returns:
Integ... | # Problem Description
This is a problem about implementing a custom binary operation on two sequences of integers. The operation involves binary conversions, bitwise AND operations, and addition. Given two sequences of integers, we need to process each sequence independently using binary operations and then combine the... | def test():
test_cases = [
{"input": ([2, 4, 2], [3, 3, 13]), "expected": 1},
{"input": ([4, 5, 6], [3, 1, 7]), "expected": 5},
{"input": ([1], [2]), "expected": 3},
{"input": ([0, 0, 0], [0, 0, 0]), "expected": 0},
{"input": ([8, 16, 32], [7, 3]), "expected": 3},
{"... | from typing import List
def solution(sequence1: List[int], sequence2: List[int]) -> int:
"""
Applies a custom operation to two integer sequences and returns their combined result.
Args:
sequence1: First sequence of integers
sequence2: Second sequence of integers
Returns:
Integ... | {
"Common Sense": null,
"Data Structures": [
"Sequence"
],
"Dynamic Patterns": null,
"Geometric Objects": null,
"Mathematical Operations": [
"Logical Operations",
"Basic Arithmetic",
"Value Comparison"
],
"Spatial Transformations": null,
"Topological Relations": null
} | Direct Calculation | |
q93-3 | from typing import List
def solution(sequence1: List[int], sequence2: List[int]) -> int:
"""
Applies a custom operation to two integer sequences and returns their combined result.
Args:
sequence1: First sequence of integers
sequence2: Second sequence of integers
Returns:
Integ... | # Problem Description
This is a problem about implementing a custom binary operation on two sequences of integers. The operation involves binary conversions, bitwise XOR operations, and addition. Given two sequences of integers, we need to process each sequence independently using binary operations and then combine the... | def test():
test_cases = [
{"input": ([2, 4, 2], [3, 3, 12]), "expected": 16},
{"input": ([4, 5, 6], [3, 1, 7]), "expected": 12},
{"input": ([1], [2]), "expected": 3},
{"input": ([0, 0, 0], [0, 0, 0]), "expected": 0},
{"input": ([8, 16, 32], [7, 3]), "expected": 60},
... | from typing import List
def solution(sequence1: List[int], sequence2: List[int]) -> int:
"""
Applies a custom operation to two integer sequences and returns their combined result.
Args:
sequence1: First sequence of integers
sequence2: Second sequence of integers
Returns:
Integ... | {
"Common Sense": null,
"Data Structures": [
"Sequence"
],
"Dynamic Patterns": null,
"Geometric Objects": null,
"Mathematical Operations": [
"Logical Operations",
"Basic Arithmetic",
"Value Comparison"
],
"Spatial Transformations": null,
"Topological Relations": null
} | Direct Calculation | |
q94 | from typing import List
def solution(matrix: List[List[int]], operations: List[str]) -> List[List[int]]:
"""
Transforms a matrix by applying a sequence of operations.
Args:
matrix: A matrix represented as a list of lists, where each inner list is a row.
operations: A list of operation code... | # Problem Description
This is a matrix transformation problem where we need to implement shifting operations on a matrix. The operations move all elements in four possible directions (Left, Right, Up, Down), with specific rules for filling empty spaces after movement.
# Visual Facts
1. The matrix is 3x3 in all example... | def test():
test_cases = [
{
"input": ([[1, 1, 1], [0, 0, 1], [0, 0, 1]], ["R"]),
"expected": [[0, 1, 1], [0, 0, 0], [0, 0, 0]]
},
{
"input": ([[0, 1, 0], [0, 1, 1], [0, 0, 1]], ["U"]),
"expected": [[0, 1, 1], [0, 0, 1], [0, 0, 0]]
},
... | from typing import List
def solution(matrix: List[List[int]], operations: List[str]) -> List[List[int]]:
"""
Transforms a matrix by applying a sequence of operations.
Args:
matrix: A matrix represented as a list of lists, where each inner list is a row.
operations: A list of operation code... | {
"Common Sense": null,
"Data Structures": [
"Matrix"
],
"Dynamic Patterns": null,
"Geometric Objects": null,
"Mathematical Operations": null,
"Spatial Transformations": [
"Shifting",
"Translation"
],
"Topological Relations": [
"Adjacency"
]
} | Transformation | |
q94-2 | from typing import List
def solution(matrix: List[List[int]], operations: List[str]) -> List[List[int]]:
"""
Transforms a matrix by applying a sequence of operations.
Args:
matrix: A matrix represented as nested lists, where each inner list represents a row.
operations: A sequence of opera... | # Problem Description
This is a matrix transformation problem where we need to implement shifting operations on a matrix. The operations move all elements in four possible directions (Left, Right, Up, Down), with specific rules for filling empty spaces after movement.
# Visual Facts
1. The matrix is 3x3 in all example... | def test():
test_cases = [
{
"input": ([[1, 1, 1], [0, 0, 1], [0, 0, 1]], ["R"]),
"expected": [[1, 1, 1], [1, 0, 0], [1, 0, 0]]
},
{
"input": ([[0, 1, 0], [0, 1, 1], [0, 0, 1]], ["U"]),
"expected": [[0, 1, 1], [0, 0, 1], [0, 1, 0]]
},
... | from typing import List
def solution(matrix: List[List[int]], operations: List[str]) -> List[List[int]]:
"""
Transforms a matrix by applying a sequence of operations.
Args:
matrix: A matrix represented as nested lists, where each inner list represents a row.
operations: A sequence of opera... | {
"Common Sense": null,
"Data Structures": [
"Matrix"
],
"Dynamic Patterns": [
"Cyclic Motion"
],
"Geometric Objects": null,
"Mathematical Operations": null,
"Spatial Transformations": [
"Shifting",
"Translation"
],
"Topological Relations": [
"Adjacency"
]
} | Transformation | |
q94-3 | from typing import List
def solution(matrix: List[List[int]], operations: List[str]) -> List[List[int]]:
"""
Transforms a matrix by applying a sequence of operations.
Args:
matrix: A matrix represented as a list of lists, where each inner list is a row.
operations: A list of operation code... | # Problem Description
This is a matrix transformation problem where we need to implement shifting operations on a matrix. The operations move all elements in four possible directions (Left, Right, Up, Down), with specific rules for filling empty spaces after movement.
# Visual Facts
1. The matrix is 3x3 in all example... |
def test():
test_cases = [
{
"input": ([[1, 1, 1], [0, 0, 1], [0, 0, 1]], ["R"]),
"expected": [[1, 1, 1], [1, 0, 0], [1, 0, 0]]
},
{
"input": ([[0, 1, 0], [0, 1, 1], [0, 0, 1]], ["U"]),
"expected": [[0, 1, 1], [0, 0, 1], [1, 1, 1]]
},
... | from typing import List
def solution(matrix: List[List[int]], operations: List[str]) -> List[List[int]]:
"""
Transforms a matrix by applying a sequence of operations.
Args:
matrix: A matrix represented as a list of lists, where each inner list is a row.
operations: A list of operation code... | {
"Common Sense": null,
"Data Structures": [
"Matrix"
],
"Dynamic Patterns": null,
"Geometric Objects": null,
"Mathematical Operations": null,
"Spatial Transformations": [
"Shifting",
"Translation"
],
"Topological Relations": [
"Adjacency"
]
} | Transformation | |
q95 | from typing import List, Tuple
def solution(points: List[List], bounding_rect: List[Tuple[int, int]]) -> int:
"""
Calculate the matrix score based on points within specified boundaries.
Args:
points: List of lists, where each inner list contains:
- A point value (integer)
... | # Problem Description
This is a geometric scoring problem where points are placed on a coordinate grid with associated numerical values. The goal is to calculate a total score based on valid points within and on a given rectangular boundary. Points are considered valid if they lie within or on the boundary edges, excep... |
def test():
test_cases = [
{
"input": {
"points": [[-2, (3, 3)], [4, (5, 5)], [5, (1, 1)], [5, (5, 1)]],
"bounds": [(1, 2), (5, 6)]
},
"expected": 6
},
{
"input": {
"points": [[4, (3, 3)], [-2, (... | from typing import List, Tuple
def solution(points: List[List], bounding_rect: List[Tuple[int, int]]) -> int:
"""
Calculate the matrix score based on points within specified boundaries.
Args:
points: List of lists, where each inner list contains:
- A point value (integer)
... | {
"Common Sense": null,
"Data Structures": null,
"Dynamic Patterns": null,
"Geometric Objects": [
"Coordinate System",
"Rectangle",
"Point",
"Grid"
],
"Mathematical Operations": [
"Value Comparison",
"Absolute Value"
],
"Spatial Transformations": null,
"Topological Relations": ... | Aggregation | |
q95-2 | from typing import List, Tuple
def solution(points: List[List], bounding_rect: List[Tuple[int, int]]) -> int:
"""
Calculate the matrix score based on points within specified boundaries.
Args:
points: List of lists, where each inner list contains:
- A point value (integer)
... | # Problem Description
This is a geometric scoring problem where points are placed on a coordinate grid with associated numerical values. The goal is to calculate a total score based on valid points within and on a given rectangular boundary. Points are considered valid if they lie within or at the corners, except for b... | def test():
test_cases = [
{
"input": {
"points": [[-2, (3, 3)], [4, (5, 5)], [5, (1, 1)], [5, (5, 1)]],
"bounds": [(1, 2), (5, 6)]
},
"expected": 2
},
{
"input": {
"points": [[4, (3, 3)], [-2, (4... | from typing import List, Tuple
def solution(points: List[List], bounding_rect: List[Tuple[int, int]]) -> int:
"""
Calculate the matrix score based on points within specified boundaries.
Args:
points: List of lists, where each inner list contains:
- A point value (integer)
... | {
"Common Sense": null,
"Data Structures": null,
"Dynamic Patterns": null,
"Geometric Objects": [
"Coordinate System",
"Rectangle",
"Point",
"Grid"
],
"Mathematical Operations": [
"Value Comparison",
"Absolute Value"
],
"Spatial Transformations": null,
"Topological Relations": ... | Aggregation | |
q95-3 | from typing import List, Tuple
def solution(points: List[List], bounding_rect: List[Tuple[int, int]]) -> int:
"""
Calculate the matrix score based on points within specified boundaries.
Args:
points: List of lists, where each inner list contains:
- A point value (integer)
... | # Problem Description
This is a geometric scoring problem where points are placed on a coordinate grid with associated numerical values. The goal is to calculate a total score based on valid points within and on a given rectangular boundary. Points are considered valid if they lie within or on the boundary edges, excep... | def test():
test_cases = [
{
"input": {
"points": [[-2, (3, 3)], [4, (5, 5)], [5, (1, 1)], [5, (5, 1)]],
"bounds": [(1, 2), (5, 6)]
},
"expected": 8
},
{
"input": {
"points": [[4, (3, 3)], [-2, (4... | from typing import List, Tuple
def solution(points: List[List], bounding_rect: List[Tuple[int, int]]) -> int:
"""
Calculate the matrix score based on points within specified boundaries.
Args:
points: List of lists, where each inner list contains:
- A point value (integer)
... | {
"Common Sense": null,
"Data Structures": null,
"Dynamic Patterns": null,
"Geometric Objects": [
"Coordinate System",
"Rectangle",
"Point",
"Grid"
],
"Mathematical Operations": [
"Value Comparison",
"Absolute Value"
],
"Spatial Transformations": null,
"Topological Relations": ... | Aggregation | |
q96 | from typing import List
def solution(input_values: List[int]) -> int:
"""
Calculates X according to the specified rules.
Args:
input_values: A list containing two integers
Returns:
The calculated value of X as an integer
"""
# Extract the side lengths
a, b = ... | # Problem Description
This appears to be a geometric problem involving rectangle folding. The function takes two numbers representing the dimensions of a rectangle and needs to calculate a value X based on a specific folding pattern. The folding creates a triangular shape, and we need to calculate the area or some meas... | def test():
test_cases = [
{"input": [3, 4], "expected": 3},
{"input": [5, 10], "expected": 25},
{"input": [7, 8], "expected": 7},
{"input": [1, 1], "expected": 0},
{"input": [100, 200], "expected": 10000},
{"input": [5, 5], "expected": 0},
{"input": [5, 50],... | from typing import List
def solution(input_values: List[int]) -> int:
"""
Calculates X according to the specified rules.
Args:
input_values: A list containing two integers
Returns:
The calculated value of X as an integer
"""
| {
"Common Sense": null,
"Data Structures": null,
"Dynamic Patterns": null,
"Geometric Objects": [
"Triangle",
"Rectangle",
"Line Segment",
"Arrow",
"Line",
"Diagonal"
],
"Mathematical Operations": [
"Value Comparison"
],
"Spatial Transformations": [
"Folding"
],
"Topo... | Direct Calculation | |
q96-2 | from typing import List
def solution(input_values: List[int]) -> int:
"""
Calculates X according to the specified rules.
Args:
input_values: A list containing two integers
Returns:
The calculated value of X as an integer
"""
# Extract the side lengths
a, b = ... | # Problem Description
This appears to be a geometric problem involving rectangle folding. The function takes two numbers representing the dimensions of a rectangle and needs to calculate a value X based on a specific folding pattern. The folding creates a triangular shape, and we need to calculate the area or some meas... |
def test():
test_cases = [
{"input": [3, 4], "expected": 4.5},
{"input": [5, 10], "expected": 12.5},
{"input": [7, 8], "expected": 24.5},
{"input": [1, 1], "expected": 0.5},
{"input": [100, 200], "expected": 5000},
{"input": [5, 5], "expected": 12.5},
{"inpu... | from typing import List
def solution(input_values: List[int]) -> int:
"""
Calculates X according to the specified rules.
Args:
input_values: A list containing two integers
Returns:
The calculated value of X as an integer
"""
| {
"Common Sense": null,
"Data Structures": null,
"Dynamic Patterns": null,
"Geometric Objects": [
"Triangle",
"Rectangle",
"Line Segment",
"Arrow",
"Line",
"Diagonal"
],
"Mathematical Operations": [
"Value Comparison"
],
"Spatial Transformations": [
"Folding"
],
"Topo... | Direct Calculation | |
q96-3 | from typing import List
def solution(input_values: List[int]) -> int:
"""
Calculates X according to the specified rules.
Args:
input_values: A list containing two integers
Returns:
The calculated value of X as an integer
"""
# Extract the side lengths
a, b = ... | # Problem Description
This appears to be a geometric problem involving rectangle folding. The function takes two numbers representing the dimensions of a rectangle and needs to calculate a value X based on consecutively two specific folding operations. The folding creates two triangular shape and one rectangle, and we ... |
def test():
test_cases = [
{"input": [3, 4], "expected": 2},
{"input": [5, 10], "expected": 0},
{"input": [7, 8], "expected": 6},
{"input": [1, 1], "expected": 0},
{"input": [100, 200], "expected": 0},
{"input": [5, 5], "expected": 0},
{"input": [5, 10], "ex... | from typing import List
def solution(input_values: List[int]) -> int:
"""
Calculates X according to the specified rules.
Args:
input_values: A list containing two integers
Returns:
The calculated value of X as an integer
"""
| {
"Common Sense": null,
"Data Structures": null,
"Dynamic Patterns": null,
"Geometric Objects": [
"Triangle",
"Rectangle",
"Line Segment",
"Arrow",
"Line",
"Diagonal"
],
"Mathematical Operations": [
"Value Comparison"
],
"Spatial Transformations": [
"Folding"
],
"Topo... | Direct Calculation | |
q97 | def solution(input_s: str) -> bool:
"""
Determines if the input string represents a valid time for the operations.
Args:
input_s: A string in "HH:MM" format (e.g. "10:53") representing a time.
Returns:
bool: True if the time is valid for the operations, False otherwise.
"""
# D... | # Problem Description
This is a digital clock mirroring problem where:
- Input is a time string in "xx:xx" format (24-hour format)
- The time needs to be transformed by mirroring it horizontally
- We need to determine if the resulting mirrored time is valid
- The function should return true if the mirrored result is a ... | def test():
test_cases = [
# Valid cases
("05:01", True),
("00:00", True),
("11:11", True),
("08:20", False),
("02:58", False),
("12:34", False),
("06:45", False),
("13:37", False),
("24:00", False),
("00:60", False),
]
... | def solution(input_s: str) -> bool:
"""
Determines if the input string represents a valid time for the operations.
Args:
input_s: A string in "HH:MM" format (e.g. "10:53") representing a time.
Returns:
bool: True if the time is valid for the operations, False otherwise.
"""
| {
"Common Sense": [
"Clock",
"Seven-Segment Display"
],
"Data Structures": null,
"Dynamic Patterns": [
"Mirror Symmetry"
],
"Geometric Objects": null,
"Mathematical Operations": null,
"Spatial Transformations": [
"Mapping",
"Flipping"
],
"Topological Relations": null
} | Validation | |
q98 | from typing import List
def solution(input_map: List[str]) -> bool:
"""
Determines if a tank can successfully navigate through a 1D map.
Args:
input_map (List[str]): A list of strings representing the map layout, where:
- '.' represents an empty space
- 'x' represents an ob... | # Problem Description
This is a problem about a tank moving through a 1D map with obstacles. The tank needs to traverse from left to right, starting at index 0. The tank has two states: 'ready' and 'loading'. The goal is to determine if the tank can successfully reach the end of the map.
# Visual Facts
1. The map is r... | def test():
test_cases = [
{
"input_map": [".", ".", "x"],
"expected": True
},
{
"input_map": [".", "x", "x"],
"expected": False
},
{
"input_map": [".", "x", ".", "x", "."],
"expected": True
},
... | from typing import List
def solution(input_map: List[str]) -> bool:
"""
Determines if a tank can successfully navigate through a 1D map.
Args:
input_map (List[str]): A list of strings representing the map layout, where:
- '.' represents an empty space
- 'x' represents an ob... | {
"Common Sense": null,
"Data Structures": [
"Path",
"Sequence"
],
"Dynamic Patterns": [
"Propagation"
],
"Geometric Objects": null,
"Mathematical Operations": [
"Conditional Branching"
],
"Spatial Transformations": [
"Translation"
],
"Topological Relations": [
"Adjacency",... | Validation | |
q99 | from typing import List
def solution(matrix: List[List[int]], operations: List[str]) -> List[List[int]]:
"""
Transforms a matrix by applying a sequence of directional operations.
Args:
matrix: A 2D integer matrix (size M*N) represented as a list of lists.
operations: A list of operations e... | # Problem Description
This is a matrix transformation problem where we need to implement a gravity-like shifting mechanism for binary values (1s) in a matrix. Given a matrix of 0s and 1s and a sequence of directional commands (U, R, D, L), we need to shift all 1s in the specified direction until they can't move further... | def test():
test_cases = [
{
"matrix": [
[1, 0, 0],
[1, 0, 1],
[1, 1, 1]
],
"operations": ["U"],
"expected": [
[1, 1, 1],
[1, 0, 1],
[1, 0, 0]
]
... | from typing import List
def solution(matrix: List[List[int]], operations: List[str]) -> List[List[int]]:
"""
Transforms a matrix by applying a sequence of directional operations.
Args:
matrix: A 2D integer matrix (size M*N) represented as a list of lists.
operations: A list of operations e... | {
"Common Sense": null,
"Data Structures": [
"Matrix",
"Sequence"
],
"Dynamic Patterns": null,
"Geometric Objects": null,
"Mathematical Operations": null,
"Spatial Transformations": [
"Translation",
"Shifting"
],
"Topological Relations": [
"Boundary",
"Adjacency"
]
} | Transformation | |
q99-2 | from typing import List
def solution(matrix: List[List[int]], operations: List[str]) -> List[List[int]]:
"""
Transforms a matrix by applying a sequence of directional operations.
Args:
matrix: A 2D integer matrix (size M*N) represented as a list of lists.
operations: A list of operations e... | # Problem Description
The problem involves transforming a given 2D integer matrix by applying a sequence of directional operations. The operations are encoded as strings ("L", "R", "U", "D"), which stand for left, right, up, and down, respectively. Each operation modifies the matrix in a specific way by summing values ... | def test():
test_cases = [
{
"matrix": [
[1, 0, 0],
[1, 0, 1],
[1, 1, 1]
],
"operations": ["U"],
"expected": [
[3, 1, 2],
[0, 0, 0],
[0, 0, 0]
]
... | from typing import List
def solution(matrix: List[List[int]], operations: List[str]) -> List[List[int]]:
"""
Transforms a matrix by applying a sequence of directional operations.
Args:
matrix: A 2D integer matrix (size M*N) represented as a list of lists.
operations: A list of operations e... | {
"Common Sense": null,
"Data Structures": [
"Matrix",
"Sequence"
],
"Dynamic Patterns": [
"Propagation"
],
"Geometric Objects": null,
"Mathematical Operations": [
"Basic Arithmetic",
"Aggregation"
],
"Spatial Transformations": [
"Translation",
"Grouping",
"Shifting"
... | Aggregation | |
q99-3 | from typing import List
def solution(matrix: List[List[int]], operations: List[str]) -> List[List[int]]:
"""
Transforms a matrix by applying a sequence of directional operations.
Args:
matrix: A 2D integer matrix (size M*N) represented as a list of lists.
operations: A list of operations e... | # Problem Description
This is a matrix transformation problem where we need to implement a gravity-like shifting mechanism for binary values (0s) in a matrix. Given a matrix of 0s and 1s and a sequence of directional commands (U, R, D, L), we need to shift all 0s in the specified direction until they can't move further... | def test():
test_cases = [
{
"matrix": [
[1, 0, 0],
[1, 0, 1],
[1, 1, 1]
],
"operations": ["U"],
"expected": [[1, 0, 0], [1, 0, 1], [1, 1, 1]]
},
{
"matrix": [
[1, 0, 0... | from typing import List
def solution(matrix: List[List[int]], operations: List[str]) -> List[List[int]]:
"""
Transforms a matrix by applying a sequence of directional operations.
Args:
matrix: A 2D integer matrix (size M*N) represented as a list of lists.
operations: A list of operations e... | {
"Common Sense": null,
"Data Structures": [
"Matrix",
"Sequence"
],
"Dynamic Patterns": null,
"Geometric Objects": null,
"Mathematical Operations": null,
"Spatial Transformations": [
"Translation",
"Shifting"
],
"Topological Relations": [
"Boundary",
"Adjacency"
]
} | Transformation |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.