h4-polytopic-attention / data /arc_python_solutions_b14.json
grapheneaffiliates's picture
Upload data/arc_python_solutions_b14.json with huggingface_hub
b6ec707 verified
{
"928ad970": {
"solve": "def solve_928ad970(grid):\n grid = copy.deepcopy(grid)\n rows, cols = len(grid), len(grid[0])\n\n # Find the rectangle (non-zero, non-5 cells)\n color = 0\n rect_cells = []\n dot_positions = []\n for r in range(rows):\n for c in range(cols):\n if grid[r][c] == 5:\n dot_positions.append((r, c))\n elif grid[r][c] != 0:\n color = grid[r][c]\n rect_cells.append((r, c))\n\n # Find bounding box of dots\n dot_rows = [p[0] for p in dot_positions]\n dot_cols = [p[1] for p in dot_positions]\n\n # The outer rectangle should be drawn between the dots\n # Looking at examples: the rectangle is drawn 1 cell inside from the dots\n top_dot = min(dot_rows)\n bottom_dot = max(dot_rows)\n left_dot = min(dot_cols)\n right_dot = max(dot_cols)\n\n # Draw outer rectangle border 1 cell inside from dots\n top = top_dot + 1\n bottom = bottom_dot - 1\n left = left_dot + 1\n right = right_dot - 1\n\n # Draw top and bottom edges\n for c in range(left, right + 1):\n grid[top][c] = color\n grid[bottom][c] = color\n # Draw left and right edges\n for r in range(top, bottom + 1):\n grid[r][left] = color\n grid[r][right] = color\n\n # Clear the interior of outer rect (except inner rect)\n for r in range(top + 1, bottom):\n for c in range(left + 1, right):\n if (r, c) not in set(rect_cells):\n grid[r][c] = 0\n\n return grid\n",
"train_outputs": [
[
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
[
0,
0,
0,
0,
5,
0,
0,
0,
0,
0,
0,
0,
0
],
[
0,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0
],
[
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
],
[
0,
0,
1,
0,
0,
1,
1,
1,
0,
0,
1,
0,
0
],
[
0,
0,
1,
0,
0,
1,
0,
1,
0,
0,
1,
0,
0
],
[
0,
5,
1,
0,
0,
1,
0,
1,
0,
0,
1,
5,
0
],
[
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0,
8,
0,
0,
0
],
[
0,
0,
0,
8,
0,
0,
0,
0,
0,
0,
0,
8,
0,
0,
0
],
[
0,
0,
0,
8,
8,
8,
8,
8,
8,
8,
8,
8,
0,
0,
0
],
[
0,
0,
0,
0,
0,
5,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
]
]
},
"93b581b8": {
"solve": "def solve_93b581b8(grid):\n grid = copy.deepcopy(grid)\n rows, cols = len(grid), len(grid[0])\n\n # Find the 2x2 block\n br, bc = -1, -1\n for r in range(rows - 1):\n for c in range(cols - 1):\n if grid[r][c] != 0 and grid[r][c+1] != 0 and grid[r+1][c] != 0 and grid[r+1][c+1] != 0:\n br, bc = r, c\n break\n if br >= 0:\n break\n\n tl = grid[br][bc]\n tr = grid[br][bc+1]\n bl = grid[br+1][bc]\n bri = grid[br+1][bc+1]\n\n # The corners of the grid (relative to block) get filled with the diagonally opposite value\n # Top-left corner area gets bottom-right value (bri), 2x2\n # Top-right corner area gets bottom-left value (bl), 2x2\n # Bottom-left corner area gets top-right value (tr), 2x2\n # Bottom-right corner area gets top-left value (tl), 2x2\n\n # Looking at example 1: block at (2,2)-(3,3), values 9,3,7,8\n # Output: top-left (0,0) 2x2 = 8(BR), top-right (0,4) 2x2 = 7(BL),\n # bottom-left (4,0) 2x2 = 3(TR), bottom-right (4,4) 2x2 = 9(TL)\n # Positions: TL area = (br-2, bc-2), TR area = (br-2, bc+2), BL area = (br+2, bc-2), BR area = (br+2, bc+2)\n\n # Top-left 2x2: rows [br-2, br-1], cols [bc-2, bc-1] -> value = bri (diagonal opposite)\n positions = [\n (br - 2, bc - 2, bri), # top-left gets bottom-right\n (br - 2, bc + 2, bl), # top-right gets bottom-left\n (br + 2, bc - 2, tr), # bottom-left gets top-right\n (br + 2, bc + 2, tl), # bottom-right gets top-left\n ]\n\n for r0, c0, val in positions:\n for dr in range(2):\n for dc in range(2):\n r2, c2 = r0 + dr, c0 + dc\n if 0 <= r2 < rows and 0 <= c2 < cols:\n grid[r2][c2] = val\n\n return grid\n",
"train_outputs": [
[
[
8,
8,
0,
0,
7,
7
],
[
8,
8,
0,
0,
7,
7
],
[
0,
0,
9,
3,
0,
0
],
[
0,
0,
7,
8,
0,
0
],
[
3,
3,
0,
0,
9,
9
],
[
3,
3,
0,
0,
9,
9
]
],
[
[
1,
0,
0,
2,
2,
0
],
[
0,
4,
6,
0,
0,
0
],
[
0,
2,
1,
0,
0,
0
],
[
6,
0,
0,
4,
4,
0
],
[
6,
0,
0,
4,
4,
0
],
[
0,
0,
0,
0,
0,
0
]
],
[
[
2,
2,
0,
0,
5,
5
],
[
2,
2,
0,
0,
5,
5
],
[
0,
0,
3,
6,
0,
0
],
[
0,
0,
5,
2,
0,
0
],
[
6,
6,
0,
0,
3,
3
],
[
6,
6,
0,
0,
3,
3
]
]
],
"test_outputs": [
[
[
0,
0,
0,
0,
0,
0
],
[
5,
5,
0,
0,
2,
2
],
[
5,
5,
0,
0,
2,
2
],
[
0,
0,
3,
1,
0,
0
],
[
0,
0,
2,
5,
0,
0
],
[
1,
1,
0,
0,
3,
3
]
]
]
},
"941d9a10": {
"solve": "def solve_941d9a10(grid):\n grid = copy.deepcopy(grid)\n rows, cols = len(grid), len(grid[0])\n\n # Find horizontal and vertical lines of 5\n h_lines = [r for r in range(rows) if all(grid[r][c] == 5 for c in range(cols))]\n v_lines = [c for c in range(cols) if all(grid[r][c] == 5 for r in range(rows))]\n\n h_bounds = [-1] + h_lines + [rows]\n v_bounds = [-1] + v_lines + [cols]\n\n # Build cell grid\n n_cell_rows = len(h_bounds) - 1\n n_cell_cols = len(v_bounds) - 1\n\n cell_grid = {}\n for i in range(n_cell_rows):\n for j in range(n_cell_cols):\n r1, r2 = h_bounds[i] + 1, h_bounds[i + 1]\n c1, c2 = v_bounds[j] + 1, v_bounds[j + 1]\n if r1 < r2 and c1 < c2:\n cell_grid[(i, j)] = (r1, r2, c1, c2)\n\n # Color 3 diagonal cells: top-left(0,0)=1, center=2, bottom-right=3\n colored = [\n (0, 0, 1),\n (n_cell_rows // 2, n_cell_cols // 2, 2),\n (n_cell_rows - 1, n_cell_cols - 1, 3),\n ]\n\n for ci, cj, color in colored:\n if (ci, cj) in cell_grid:\n r1, r2, c1, c2 = cell_grid[(ci, cj)]\n for r in range(r1, r2):\n for c in range(c1, c2):\n if grid[r][c] == 0:\n grid[r][c] = color\n\n return grid\n",
"train_outputs": [
[
[
1,
1,
5,
0,
0,
0,
0,
5,
0,
0
],
[
1,
1,
5,
0,
0,
0,
0,
5,
0,
0
],
[
1,
1,
5,
0,
0,
0,
0,
5,
0,
0
],
[
5,
5,
5,
5,
5,
5,
5,
5,
5,
5
],
[
0,
0,
5,
2,
2,
2,
2,
5,
0,
0
],
[
0,
0,
5,
2,
2,
2,
2,
5,
0,
0
],
[
0,
0,
5,
2,
2,
2,
2,
5,
0,
0
],
[
5,
5,
5,
5,
5,
5,
5,
5,
5,
5
],
[
0,
0,
5,
0,
0,
0,
0,
5,
3,
3
],
[
0,
0,
5,
0,
0,
0,
0,
5,
3,
3
]
],
[
[
1,
1,
1,
5,
0,
0,
0,
0,
5,
0
],
[
5,
5,
5,
5,
5,
5,
5,
5,
5,
5
],
[
0,
0,
0,
5,
0,
0,
0,
0,
5,
0
],
[
5,
5,
5,
5,
5,
5,
5,
5,
5,
5
],
[
0,
0,
0,
5,
2,
2,
2,
2,
5,
0
],
[
0,
0,
0,
5,
2,
2,
2,
2,
5,
0
],
[
5,
5,
5,
5,
5,
5,
5,
5,
5,
5
],
[
0,
0,
0,
5,
0,
0,
0,
0,
5,
0
],
[
5,
5,
5,
5,
5,
5,
5,
5,
5,
5
],
[
0,
0,
0,
5,
0,
0,
0,
0,
5,
3
]
],
[
[
1,
5,
0,
0,
5,
0,
5,
0,
5,
0
],
[
1,
5,
0,
0,
5,
0,
5,
0,
5,
0
],
[
1,
5,
0,
0,
5,
0,
5,
0,
5,
0
],
[
5,
5,
5,
5,
5,
5,
5,
5,
5,
5
],
[
0,
5,
0,
0,
5,
2,
5,
0,
5,
0
],
[
0,
5,
0,
0,
5,
2,
5,
0,
5,
0
],
[
5,
5,
5,
5,
5,
5,
5,
5,
5,
5
],
[
0,
5,
0,
0,
5,
0,
5,
0,
5,
3
],
[
0,
5,
0,
0,
5,
0,
5,
0,
5,
3
],
[
0,
5,
0,
0,
5,
0,
5,
0,
5,
3
]
]
],
"test_outputs": [
[
[
1,
5,
0,
5,
0,
0,
5,
0,
5,
0
],
[
5,
5,
5,
5,
5,
5,
5,
5,
5,
5
],
[
0,
5,
0,
5,
0,
0,
5,
0,
5,
0
],
[
0,
5,
0,
5,
0,
0,
5,
0,
5,
0
],
[
5,
5,
5,
5,
5,
5,
5,
5,
5,
5
],
[
0,
5,
0,
5,
2,
2,
5,
0,
5,
0
],
[
5,
5,
5,
5,
5,
5,
5,
5,
5,
5
],
[
0,
5,
0,
5,
0,
0,
5,
0,
5,
0
],
[
5,
5,
5,
5,
5,
5,
5,
5,
5,
5
],
[
0,
5,
0,
5,
0,
0,
5,
0,
5,
3
]
]
]
},
"94f9d214": {
"solve": "def solve_94f9d214(grid):\n # Top half is 3s pattern, bottom half is 1s pattern\n # Output: 4x4, cell=2 where both top and bottom are 0\n h = len(grid) // 2\n w = len(grid[0])\n output = [[0] * w for _ in range(h)]\n for r in range(h):\n for c in range(w):\n top_val = grid[r][c]\n bot_val = grid[r + h][c]\n if top_val == 0 and bot_val == 0:\n output[r][c] = 2\n return output\n",
"train_outputs": [
[
[
2,
2,
2,
0
],
[
0,
0,
0,
0
],
[
0,
0,
0,
0
],
[
0,
0,
2,
0
]
],
[
[
0,
0,
0,
0
],
[
2,
0,
0,
0
],
[
2,
0,
0,
0
],
[
0,
2,
2,
0
]
],
[
[
0,
0,
0,
0
],
[
0,
0,
2,
0
],
[
0,
0,
0,
2
],
[
0,
0,
0,
0
]
],
[
[
0,
0,
0,
0
],
[
0,
0,
0,
0
],
[
0,
2,
0,
0
],
[
0,
0,
0,
0
]
]
],
"test_outputs": [
[
[
2,
0,
0,
0
],
[
0,
0,
0,
0
],
[
2,
0,
2,
0
],
[
0,
0,
0,
2
]
]
]
},
"952a094c": {
"solve": "def solve_952a094c(grid):\n grid = copy.deepcopy(grid)\n rows, cols = len(grid), len(grid[0])\n\n # Find the rectangle border\n border_cells = []\n border_color = 0\n for r in range(rows):\n for c in range(cols):\n v = grid[r][c]\n if v != 0:\n border_cells.append((r, c, v))\n\n # Find the rectangle: find the most common non-zero color\n from collections import Counter\n colors = [v for _, _, v in border_cells]\n color_counts = Counter(colors)\n border_color = color_counts.most_common(1)[0][0]\n\n # Find rectangle bounds\n border_positions = [(r, c) for r, c, v in border_cells if v == border_color]\n rmin = min(r for r, c in border_positions)\n rmax = max(r for r, c in border_positions)\n cmin = min(c for r, c in border_positions)\n cmax = max(c for r, c in border_positions)\n\n # Find corner dots inside the rectangle\n inner_dots = {}\n for r, c, v in border_cells:\n if v != border_color and rmin < r < rmax and cmin < c < cmax:\n inner_dots[(r, c)] = v\n\n # Identify corners: top-left, top-right, bottom-left, bottom-right\n inner_r = [r for r, c in inner_dots]\n inner_c = [c for r, c in inner_dots]\n\n top_r = min(inner_r)\n bot_r = max(inner_r)\n left_c = min(inner_c)\n right_c = max(inner_c)\n\n tl = inner_dots.get((top_r, left_c), 0)\n tr = inner_dots.get((top_r, right_c), 0)\n bl = inner_dots.get((bot_r, left_c), 0)\n br = inner_dots.get((bot_r, right_c), 0)\n\n # Clear inner dots and all interior non-border content\n for r in range(rmin + 1, rmax):\n for c in range(cmin + 1, cmax):\n grid[r][c] = 0\n\n # Place dots outside at diagonally opposite corners\n # TL inner -> placed at (rmin-1, cmin-1) but as diagonal opposite value\n # Looking at example 1: box at (2,6)x(3,7), inner: (3,4)=4, (3,5)=3, (5,4)=2, (5,5)=6\n # Output: (1,2)=6, (1,7)=2, (7,2)=3, (7,7)=4\n # So TL(4) goes to BR outside, TR(3) goes to BL outside, BL(2) goes to TR outside, BR(6) goes to TL outside\n # That means each corner value goes to the diagonally opposite outside position\n\n grid[rmin - 1][cmin - 1] = br # outside TL gets BR value\n grid[rmin - 1][cmax + 1] = bl # outside TR gets BL value\n grid[rmax + 1][cmin - 1] = tr # outside BL gets TR value\n grid[rmax + 1][cmax + 1] = tl # outside BR gets TL value\n\n return grid\n",
"train_outputs": [
[
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
[
0,
0,
6,
0,
0,
0,
0,
2,
0,
0
],
[
0,
0,
0,
8,
8,
8,
8,
0,
0,
0
],
[
0,
0,
0,
8,
0,
0,
8,
0,
0,
0
],
[
0,
0,
0,
8,
0,
0,
8,
0,
0,
0
],
[
0,
0,
0,
8,
0,
0,
8,
0,
0,
0
],
[
0,
0,
0,
8,
8,
8,
8,
0,
0,
0
],
[
0,
0,
3,
0,
0,
0,
0,
4,
0,
0
],
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
],
[
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
[
0,
3,
0,
0,
0,
0,
0,
0,
9,
0
],
[
0,
0,
7,
7,
7,
7,
7,
7,
0,
0
],
[
0,
0,
7,
0,
0,
0,
0,
7,
0,
0
],
[
0,
0,
7,
0,
0,
0,
0,
7,
0,
0
],
[
0,
0,
7,
0,
0,
0,
0,
7,
0,
0
],
[
0,
0,
7,
0,
0,
0,
0,
7,
0,
0
],
[
0,
0,
7,
7,
7,
7,
7,
7,
0,
0
],
[
0,
8,
0,
0,
0,
0,
0,
0,
2,
0
],
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
],
[
[
3,
0,
0,
0,
0,
0,
0,
6,
0,
0
],
[
0,
1,
1,
1,
1,
1,
1,
0,
0,
0
],
[
0,
1,
0,
0,
0,
0,
1,
0,
0,
0
],
[
0,
1,
0,
0,
0,
0,
1,
0,
0,
0
],
[
0,
1,
0,
0,
0,
0,
1,
0,
0,
0
],
[
0,
1,
1,
1,
1,
1,
1,
0,
0,
0
],
[
5,
0,
0,
0,
0,
0,
0,
2,
0,
0
],
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
]
],
"test_outputs": [
[
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
[
0,
2,
0,
0,
0,
0,
0,
0,
8,
0
],
[
0,
0,
3,
3,
3,
3,
3,
3,
0,
0
],
[
0,
0,
3,
0,
0,
0,
0,
3,
0,
0
],
[
0,
0,
3,
0,
0,
0,
0,
3,
0,
0
],
[
0,
0,
3,
0,
0,
0,
0,
3,
0,
0
],
[
0,
0,
3,
3,
3,
3,
3,
3,
0,
0
],
[
0,
4,
0,
0,
0,
0,
0,
0,
6,
0
],
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
]
]
},
"9565186b": {
"solve": "def solve_9565186b(grid):\n grid = copy.deepcopy(grid)\n from collections import Counter\n flat = [grid[r][c] for r in range(len(grid)) for c in range(len(grid[0]))]\n most_common = Counter(flat).most_common(1)[0][0]\n for r in range(len(grid)):\n for c in range(len(grid[0])):\n if grid[r][c] != most_common:\n grid[r][c] = 5\n return grid\n",
"train_outputs": [
[
[
2,
2,
2
],
[
2,
5,
5
],
[
2,
5,
5
]
],
[
[
1,
1,
1
],
[
5,
1,
5
],
[
5,
5,
5
]
],
[
[
2,
2,
2
],
[
5,
5,
2
],
[
2,
2,
2
]
],
[
[
5,
5,
5
],
[
4,
4,
4
],
[
5,
5,
5
]
]
],
"test_outputs": [
[
[
5,
3,
5
],
[
3,
3,
5
],
[
5,
3,
5
]
]
]
},
"95990924": {
"solve": "def solve_95990924(grid):\n grid = copy.deepcopy(grid)\n rows, cols = len(grid), len(grid[0])\n\n # Find all 2x2 blocks of 5\n blocks = []\n visited = set()\n for r in range(rows - 1):\n for c in range(cols - 1):\n if (grid[r][c] == 5 and grid[r][c+1] == 5 and\n grid[r+1][c] == 5 and grid[r+1][c+1] == 5 and\n (r, c) not in visited):\n blocks.append((r, c))\n visited.update([(r,c),(r,c+1),(r+1,c),(r+1,c+1)])\n\n # For each block, place corner markers\n for r, c in blocks:\n # Top-left corner: (r-1, c-1) = 1\n if r-1 >= 0 and c-1 >= 0:\n grid[r-1][c-1] = 1\n # Top-right corner: (r-1, c+2) = 2\n if r-1 >= 0 and c+2 < cols:\n grid[r-1][c+2] = 2\n # Bottom-left corner: (r+2, c-1) = 3\n if r+2 < rows and c-1 >= 0:\n grid[r+2][c-1] = 3\n # Bottom-right corner: (r+2, c+2) = 4\n if r+2 < rows and c+2 < cols:\n grid[r+2][c+2] = 4\n\n return grid\n",
"train_outputs": [
[
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
[
0,
0,
0,
1,
0,
0,
2,
0,
0,
0
],
[
0,
0,
0,
0,
5,
5,
0,
0,
0,
0
],
[
0,
0,
0,
0,
5,
5,
0,
0,
0,
0
],
[
0,
0,
0,
3,
0,
0,
4,
0,
0,
0
],
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
],
[
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
[
0,
1,
0,
0,
2,
0,
0,
0,
0,
0
],
[
0,
0,
5,
5,
0,
0,
0,
0,
0,
0
],
[
0,
0,
5,
5,
0,
0,
0,
0,
0,
0
],
[
0,
3,
0,
0,
4,
0,
0,
0,
0,
0
],
[
0,
0,
0,
0,
0,
1,
0,
0,
2,
0
],
[
0,
0,
0,
0,
0,
0,
5,
5,
0,
0
],
[
0,
0,
0,
0,
0,
0,
5,
5,
0,
0
],
[
0,
0,
0,
0,
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0,
0
],
[
0,
0,
0,
0,
0,
5,
5,
0,
0,
0,
0,
1,
0,
0,
2
],
[
0,
0,
0,
0,
3,
0,
0,
4,
0,
0,
0,
0,
5,
5,
0
],
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
5,
5,
0
],
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
3,
0,
0,
4
],
[
0,
1,
0,
0,
2,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
[
0,
0,
5,
5,
0,
0,
0,
0,
1,
0,
0,
2,
0,
0,
0
],
[
0,
0,
5,
5,
0,
0,
0,
0,
0,
5,
5,
0,
0,
0,
0
],
[
0,
3,
0,
0,
4,
0,
0,
0,
0,
5,
5,
0,
0,
0,
0
],
[
0,
0,
0,
0,
0,
0,
0,
0,
3,
0,
0,
4,
0,
0,
0
],
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
]
]
},
"963e52fc": {
"solve": "def solve_963e52fc(grid):\n rows = len(grid)\n cols = len(grid[0])\n new_cols = cols * 2\n output = []\n\n for r in range(rows):\n row = grid[r]\n if all(v == 0 for v in row):\n output.append([0] * new_cols)\n else:\n # Find the repeating unit in the row\n # The pattern repeats - extend it to double width\n # Need to find the period of the pattern\n new_row = []\n for c in range(new_cols):\n # Try to continue the pattern\n # Find period\n new_row.append(row[c % cols] if c < cols else 0)\n\n # Actually, looking at examples more carefully:\n # The pattern continues seamlessly. Let me find the period.\n # Ex1: [2,8,2,8,2,8] -> [2,8,2,8,2,8,2,8,2,8,2,8] - period 2\n # Ex2: [2,3,3,2,3,3,2] -> [2,3,3,2,3,3,2,3,3,2,3,3,2,3] - period 3\n # Ex3: [1,2,2,1,2,2,1,2] -> [1,2,2,1,2,2,1,2,2,1,2,2,1,2,2,1] - period 3\n # [2,1,2,2,1,2,2,1] -> [2,1,2,2,1,2,2,1,2,2,1,2,2,1,2,2] - period 3\n\n # Find the minimal period\n best_period = None\n for p in range(1, cols + 1):\n valid = True\n for c in range(cols):\n if row[c] != row[c % p]:\n valid = False\n break\n if valid:\n best_period = p\n break\n\n new_row = [row[c % best_period] for c in range(new_cols)]\n output.append(new_row)\n\n return output\n",
"train_outputs": [
[
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
[
2,
8,
2,
8,
2,
8,
2,
8,
2,
8,
2,
8
],
[
2,
8,
2,
8,
2,
8,
2,
8,
2,
8,
2,
8
],
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
],
[
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
[
2,
3,
3,
2,
3,
3,
2,
3,
3,
2,
3,
3,
2,
3
],
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
],
[
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
[
1,
2,
2,
1,
2,
2,
1,
2,
2,
1,
2,
2,
1,
2,
2,
1
],
[
2,
1,
2,
2,
1,
2,
2,
1,
2,
2,
1,
2,
2,
1,
2,
2
],
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
]
],
"test_outputs": [
[
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
[
3,
1,
1,
3,
1,
1,
3,
1,
1,
3,
1,
1,
3,
1,
1,
3,
1,
1
],
[
3,
1,
1,
3,
1,
1,
3,
1,
1,
3,
1,
1,
3,
1,
1,
3,
1,
1
],
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
]
]
},
"97999447": {
"solve": "def solve_97999447(grid):\n grid = copy.deepcopy(grid)\n rows, cols = len(grid), len(grid[0])\n\n # Find non-zero cells\n dots = []\n for r in range(rows):\n for c in range(cols):\n if grid[r][c] != 0:\n dots.append((r, c, grid[r][c]))\n\n for r, c, val in dots:\n # Fill rightward: val, 5, val, 5, ...\n for i, cc in enumerate(range(c, cols)):\n if i == 0:\n grid[r][cc] = val\n elif i % 2 == 0:\n grid[r][cc] = val\n else:\n grid[r][cc] = 5\n\n return grid\n",
"train_outputs": [
[
[
0,
0,
0,
0,
0,
0,
0,
0
],
[
0,
0,
0,
0,
0,
0,
0,
0
],
[
0,
0,
2,
5,
2,
5,
2,
5
],
[
0,
0,
0,
0,
0,
0,
0,
0
],
[
0,
0,
0,
0,
0,
0,
0,
0
],
[
0,
0,
0,
6,
5,
6,
5,
6
],
[
0,
0,
0,
0,
0,
0,
0,
0
],
[
0,
0,
0,
0,
0,
0,
0,
0
],
[
0,
0,
0,
0,
0,
0,
0,
0
],
[
0,
0,
0,
0,
0,
0,
0,
0
]
],
[
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
[
0,
0,
2,
5,
2,
5,
2,
5,
2,
5,
2,
5
],
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
[
0,
3,
5,
3,
5,
3,
5,
3,
5,
3,
5,
3
],
[
0,
0,
0,
0,
0,
0,
6,
5,
6,
5,
6,
5
],
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
],
[
[
0,
0,
0,
0,
0,
0,
0,
0
],
[
0,
0,
0,
0,
0,
0,
0,
0
],
[
0,
0,
0,
0,
0,
0,
0,
0
],
[
0,
0,
0,
8,
5,
8,
5,
8
],
[
0,
0,
0,
0,
0,
0,
0,
0
],
[
0,
0,
0,
0,
0,
0,
0,
0
],
[
0,
0,
0,
0,
0,
0,
0,
0
]
]
],
"test_outputs": [
[
[
0,
0,
0,
0,
0,
0,
0,
0
],
[
0,
0,
0,
3,
5,
3,
5,
3
],
[
0,
0,
4,
5,
4,
5,
4,
5
],
[
0,
0,
0,
0,
0,
0,
0,
0
],
[
0,
0,
0,
0,
8,
5,
8,
5
],
[
0,
0,
0,
0,
0,
0,
0,
0
],
[
0,
0,
0,
2,
5,
2,
5,
2
],
[
0,
0,
0,
0,
0,
0,
0,
0
],
[
0,
0,
0,
0,
0,
0,
0,
0
]
]
]
},
"995c5fa3": {
"solve": "def solve_995c5fa3(grid):\n rows = len(grid)\n cols = len(grid[0])\n\n # Extract panels (separated by columns of 0)\n # Find separator columns\n sep_cols = []\n for c in range(cols):\n if all(grid[r][c] == 0 for r in range(rows)):\n sep_cols.append(c)\n\n # Extract panel column ranges\n panel_ranges = []\n starts = [0] + [s + 1 for s in sep_cols]\n ends = [s for s in sep_cols] + [cols]\n for s, e in zip(starts, ends):\n if s < e:\n panel_ranges.append((s, e))\n\n output = []\n for s, e in panel_ranges:\n # Extract panel\n panel = []\n for r in range(rows):\n panel.append([grid[r][c] for c in range(s, e)])\n\n # Check if full (all 5s)\n is_full = all(panel[r][c] == 5 for r in range(rows) for c in range(e - s))\n if is_full:\n output.append([2, 2, 2])\n continue\n\n # Find hole positions\n holes = []\n for r in range(rows):\n for c in range(e - s):\n if panel[r][c] == 0:\n holes.append((r, c))\n\n hole_rows = set(r for r, c in holes)\n hole_cols = set(c for r, c in holes)\n\n w = e - s # panel width\n\n # Categorize hole\n if hole_rows == {1, 2} and hole_cols == {1, 2}:\n # Center hole\n output.append([8, 8, 8])\n elif hole_rows == {2, 3} and hole_cols == {1, 2}:\n # Bottom center hole\n output.append([4, 4, 4])\n elif hole_rows == {0, 1} and hole_cols == {1, 2}:\n # Top center hole\n # Need to check if this exists\n output.append([6, 6, 6]) # placeholder\n elif hole_cols == {0, w - 1}:\n # Side holes\n output.append([3, 3, 3])\n elif hole_rows == {0, 1} and hole_cols == {0, 1}:\n output.append([3, 3, 3])\n else:\n output.append([2, 2, 2])\n\n return output\n",
"train_outputs": [
[
[
2,
2,
2
],
[
8,
8,
8
],
[
3,
3,
3
]
],
[
[
3,
3,
3
],
[
4,
4,
4
],
[
2,
2,
2
]
],
[
[
8,
8,
8
],
[
2,
2,
2
],
[
4,
4,
4
]
],
[
[
2,
2,
2
],
[
4,
4,
4
],
[
2,
2,
2
]
]
],
"test_outputs": [
[
[
4,
4,
4
],
[
3,
3,
3
],
[
8,
8,
8
]
]
]
}
}