h4-polytopic-attention / data\arc2_solutions_retry6.json
grapheneaffiliates's picture
Upload data\arc2_solutions_retry6.json with huggingface_hub
eed3f02 verified
{
"4c3d4a41": "def solve(grid):\n rows = len(grid)\n cols = len(grid[0])\n out = [row[:] for row in grid]\n for r in range(rows):\n for c in range(9):\n out[r][c] = 0\n staircase_heights = []\n for sc in [1, 3, 5, 7]:\n h = 0\n for r in range(5, 0, -1):\n if grid[r][sc] == 5:\n h += 1\n else:\n break\n staircase_heights.append(h)\n top_border = -1\n bottom_border = -1\n for r in range(rows):\n if all(grid[r][c] == 5 for c in range(9, cols)):\n if top_border == -1:\n top_border = r\n else:\n bottom_border = r\n inner_top = top_border + 1\n inner_bottom = bottom_border - 1\n inner_height = inner_bottom - inner_top + 1\n for idx, (rc, sh) in enumerate(zip([11, 13, 15, 17], staircase_heights)):\n in_vals = [grid[r][rc] for r in range(inner_top, inner_bottom + 1)]\n input_top_5s = 0\n for v in in_vals:\n if v == 5:\n input_top_5s += 1\n else:\n break\n color = 0\n for v in in_vals:\n if v not in [0, 5]:\n color = v\n break\n output_top_5s = max(0, input_top_5s - 1)\n color_count = inner_height - output_top_5s - sh - 1\n new_col = []\n new_col.extend([5] * output_top_5s)\n new_col.extend([color] * color_count)\n new_col.extend([5] * sh)\n new_col.append(0)\n new_col = new_col[:inner_height]\n for j, r in enumerate(range(inner_top, inner_bottom + 1)):\n out[r][rc] = new_col[j]\n for sc, rc in zip([2, 4, 6], [12, 14, 16]):\n for r in range(inner_top, inner_bottom + 1):\n if grid[r][sc] == 5:\n out[r][rc] = 5\n return out\n"
}