Skip to content

Instantly share code, notes, and snippets.

@nimishbongale
Created November 20, 2025 05:28
Show Gist options
  • Select an option

  • Save nimishbongale/3f59c83040bc6620fe369099a7d87d52 to your computer and use it in GitHub Desktop.

Select an option

Save nimishbongale/3f59c83040bc6620fe369099a7d87d52 to your computer and use it in GitHub Desktop.
31d5ba1a
{"test": [{"input": [[9, 9, 0, 9, 0], [0, 0, 9, 0, 9], [0, 0, 0, 9, 9], [4, 4, 4, 0, 4], [4, 0, 4, 4, 4], [4, 4, 0, 0, 0]], "output": [[0, 0, 6, 6, 6], [6, 0, 0, 6, 0], [6, 6, 0, 6, 6]]}, {"input": [[0, 0, 9, 0, 9], [0, 9, 0, 0, 0], [9, 0, 9, 0, 0], [4, 0, 4, 4, 4], [0, 4, 4, 0, 4], [4, 0, 0, 0, 0]], "output": [[6, 0, 0, 6, 0], [0, 0, 6, 0, 6], [0, 0, 6, 0, 0]]}], "train": [{"input": [[9, 9, 0, 9, 0], [9, 0, 0, 9, 0], [0, 9, 9, 9, 9], [4, 0, 0, 4, 0], [4, 4, 0, 4, 4], [4, 4, 4, 0, 4]], "output": [[0, 6, 0, 0, 0], [0, 6, 0, 0, 6], [6, 0, 0, 6, 0]]}, {"input": [[9, 0, 0, 9, 9], [0, 0, 0, 0, 0], [0, 0, 9, 0, 9], [0, 0, 4, 4, 0], [4, 4, 4, 0, 0], [4, 0, 4, 0, 4]], "output": [[6, 0, 6, 0, 6], [6, 6, 6, 0, 0], [6, 0, 0, 0, 0]]}, {"input": [[0, 9, 0, 0, 0], [0, 9, 9, 0, 9], [9, 0, 0, 0, 9], [4, 4, 0, 4, 0], [0, 4, 4, 4, 0], [4, 4, 0, 0, 0]], "output": [[6, 0, 0, 6, 0], [0, 0, 0, 6, 6], [0, 6, 0, 0, 6]]}, {"input": [[0, 0, 9, 9, 0], [9, 9, 0, 9, 9], [0, 9, 0, 0, 0], [4, 4, 0, 0, 0], [4, 0, 4, 4, 4], [0, 4, 0, 0, 4]], "output": [[6, 6, 6, 6, 0], [0, 6, 6, 0, 0], [0, 0, 0, 0, 6]]}, {"input": [[0, 9, 9, 0, 0], [9, 0, 0, 0, 9], [9, 0, 0, 0, 0], [0, 0, 4, 0, 4], [4, 4, 0, 4, 0], [4, 0, 4, 4, 0]], "output": [[0, 6, 0, 0, 6], [0, 6, 0, 6, 6], [0, 0, 6, 6, 0]]}]}
195ba7dc
{"test": [{"input": [[7, 7, 0, 0, 0, 0, 2, 0, 7, 7, 0, 0, 7], [0, 7, 0, 0, 0, 0, 2, 7, 0, 0, 7, 0, 7], [7, 7, 7, 0, 0, 7, 2, 0, 7, 7, 7, 0, 7], [0, 0, 0, 0, 0, 0, 2, 7, 7, 7, 7, 0, 0], [0, 0, 7, 7, 7, 0, 2, 0, 7, 7, 0, 7, 7]], "output": [[1, 1, 1, 0, 0, 1], [1, 1, 0, 1, 0, 1], [1, 1, 1, 1, 0, 1], [1, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1]]}], "train": [{"input": [[0, 7, 7, 0, 7, 7, 2, 7, 0, 0, 0, 0, 7], [7, 0, 0, 0, 0, 7, 2, 7, 0, 0, 7, 7, 0], [7, 0, 7, 7, 0, 7, 2, 7, 0, 0, 7, 0, 0], [0, 7, 0, 0, 0, 0, 2, 7, 0, 7, 0, 7, 0], [7, 7, 0, 7, 7, 0, 2, 0, 7, 0, 0, 7, 0]], "output": [[1, 1, 1, 0, 1, 1], [1, 0, 0, 1, 1, 1], [1, 0, 1, 1, 0, 1], [1, 1, 1, 0, 1, 0], [1, 1, 0, 1, 1, 0]]}, {"input": [[0, 7, 7, 7, 0, 7, 2, 7, 7, 0, 7, 0, 7], [0, 0, 0, 7, 0, 7, 2, 0, 7, 7, 7, 0, 7], [7, 0, 7, 0, 0, 0, 2, 7, 7, 0, 0, 0, 0], [7, 7, 7, 0, 0, 0, 2, 7, 7, 0, 0, 7, 7], [0, 7, 7, 0, 7, 7, 2, 7, 7, 7, 0, 0, 7]], "output": [[1, 1, 1, 1, 0, 1], [0, 1, 1, 1, 0, 1], [1, 1, 1, 0, 0, 0], [1, 1, 1, 0, 1, 1], [1, 1, 1, 0, 1, 1]]}, {"input": [[7, 0, 7, 7, 0, 7, 2, 7, 7, 0, 0, 0, 0], [7, 0, 0, 7, 0, 0, 2, 0, 0, 0, 7, 0, 0], [0, 7, 7, 0, 0, 0, 2, 0, 0, 7, 7, 0, 0], [0, 7, 7, 7, 7, 0, 2, 7, 0, 0, 0, 7, 0], [7, 0, 7, 0, 7, 7, 2, 7, 7, 7, 7, 7, 7]], "output": [[1, 1, 1, 1, 0, 1], [1, 0, 0, 1, 0, 0], [0, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1]]}, {"input": [[7, 7, 0, 0, 7, 0, 2, 0, 7, 7, 7, 7, 7], [7, 0, 0, 0, 7, 7, 2, 7, 0, 0, 7, 7, 7], [0, 7, 0, 0, 7, 0, 2, 0, 0, 0, 0, 0, 0], [7, 7, 0, 7, 7, 7, 2, 7, 0, 7, 0, 0, 0], [7, 7, 0, 7, 7, 0, 2, 7, 7, 7, 0, 0, 0]], "output": [[1, 1, 1, 1, 1, 1], [1, 0, 0, 1, 1, 1], [0, 1, 0, 0, 1, 0], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 0]]}]}
bbb1b8b6
{"train": [{"input": [[0, 0, 0, 1, 5, 2, 2, 2, 0], [1, 0, 0, 0, 5, 0, 2, 2, 2], [1, 1, 0, 0, 5, 0, 0, 2, 2], [1, 1, 1, 0, 5, 0, 0, 0, 2]], "output": [[2, 2, 2, 1], [1, 2, 2, 2], [1, 1, 2, 2], [1, 1, 1, 2]]}, {"input": [[0, 0, 0, 1, 5, 2, 2, 0, 0], [1, 0, 0, 0, 5, 2, 2, 0, 0], [1, 1, 0, 0, 5, 0, 2, 2, 0], [1, 1, 1, 0, 5, 0, 2, 2, 0]], "output": [[0, 0, 0, 1], [1, 0, 0, 0], [1, 1, 0, 0], [1, 1, 1, 0]]}, {"input": [[1, 1, 0, 0, 5, 0, 0, 3, 3], [1, 0, 0, 1, 5, 0, 3, 3, 0], [1, 0, 0, 1, 5, 0, 3, 3, 0], [1, 1, 0, 0, 5, 0, 0, 3, 3]], "output": [[1, 1, 3, 3], [1, 3, 3, 1], [1, 3, 3, 1], [1, 1, 3, 3]]}, {"input": [[1, 1, 1, 1, 5, 0, 0, 0, 0], [1, 0, 0, 1, 5, 0, 6, 6, 0], [1, 0, 0, 1, 5, 0, 6, 6, 0], [1, 1, 1, 1, 5, 0, 0, 0, 0]], "output": [[1, 1, 1, 1], [1, 6, 6, 1], [1, 6, 6, 1], [1, 1, 1, 1]]}, {"input": [[1, 1, 1, 1, 5, 2, 2, 0, 0], [1, 0, 0, 1, 5, 2, 2, 0, 0], [1, 0, 0, 1, 5, 0, 0, 0, 0], [1, 1, 1, 1, 5, 0, 0, 0, 0]], "output": [[1, 1, 1, 1], [1, 0, 0, 1], [1, 0, 0, 1], [1, 1, 1, 1]]}, {"input": [[1, 1, 1, 1, 5, 3, 3, 0, 0], [1, 0, 0, 1, 5, 3, 3, 0, 0], [1, 0, 0, 1, 5, 3, 0, 0, 0], [1, 0, 0, 1, 5, 0, 0, 0, 0]], "output": [[1, 1, 1, 1], [1, 0, 0, 1], [1, 0, 0, 1], [1, 0, 0, 1]]}, {"input": [[1, 1, 1, 1, 5, 0, 0, 0, 0], [1, 0, 0, 0, 5, 0, 7, 7, 7], [1, 0, 1, 1, 5, 0, 7, 0, 0], [1, 0, 1, 0, 5, 0, 7, 0, 7]], "output": [[1, 1, 1, 1], [1, 7, 7, 7], [1, 7, 1, 1], [1, 7, 1, 7]]}], "test": [{"input": [[1, 1, 0, 0, 5, 0, 0, 3, 3], [1, 0, 0, 1, 5, 0, 3, 3, 0], [0, 0, 0, 1, 5, 3, 3, 3, 0], [0, 1, 1, 1, 5, 3, 0, 0, 0]], "output": [[1, 1, 3, 3], [1, 3, 3, 1], [3, 3, 3, 1], [3, 1, 1, 1]]}, {"input": [[1, 1, 1, 1, 5, 2, 0, 0, 0], [0, 1, 1, 0, 5, 2, 2, 2, 2], [0, 1, 1, 0, 5, 2, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0, 0, 0]], "output": [[1, 1, 1, 1], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]]}]}
c8b7cc0f
{"train": [{"input": [[0, 0, 0, 0, 0, 0, 0], [0, 4, 0, 0, 0, 4, 0], [0, 0, 4, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 4], [1, 0, 0, 0, 4, 1, 0], [1, 4, 0, 4, 0, 1, 0], [1, 1, 1, 1, 1, 1, 0]], "output": [[4, 4, 4], [0, 0, 0], [0, 0, 0]]}, {"input": [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 6, 1, 1, 1, 1, 1, 1], [0, 0, 0, 1, 6, 0, 6, 0, 1], [0, 0, 0, 1, 0, 6, 0, 0, 1], [0, 0, 0, 1, 0, 0, 0, 6, 1], [0, 6, 0, 1, 6, 0, 0, 0, 1], [0, 0, 0, 1, 1, 1, 1, 1, 1], [0, 0, 0, 6, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]], "output": [[6, 6, 6], [6, 6, 0], [0, 0, 0]]}, {"input": [[0, 0, 0, 0, 0, 3, 0, 0, 0], [3, 0, 1, 1, 1, 1, 1, 0, 0], [0, 0, 1, 0, 0, 3, 1, 0, 0], [0, 0, 1, 0, 0, 0, 1, 3, 0], [0, 0, 1, 0, 0, 3, 1, 0, 0], [0, 0, 1, 3, 0, 0, 1, 0, 0], [0, 3, 1, 0, 0, 0, 1, 0, 0], [0, 0, 1, 0, 3, 0, 1, 3, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0]], "output": [[3, 3, 3], [3, 0, 0], [0, 0, 0]]}], "test": [{"input": [[2, 0, 0, 0, 0, 0, 2, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 0, 2, 0, 0, 0, 1, 0, 0], [1, 0, 0, 0, 2, 0, 1, 2, 0], [1, 0, 0, 0, 0, 2, 1, 0, 0], [1, 2, 0, 0, 0, 0, 1, 0, 2], [1, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 2, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 2, 0]], "output": [[2, 2, 2], [2, 0, 0], [0, 0, 0]]}]}
class ArcAgent:
def __init__(self):
pass
def _extract_examples(
self, arc_problem: Any
) -> Dict[str, List[Dict[str, np.ndarray]]]:
# Primary: ARC dict format
if isinstance(arc_problem, dict):
result: Dict[str, List[Dict[str, np.ndarray]]] = {"train": [], "test": []}
for ex in arc_problem.get("train", []):
inp_arr = np.array(ex["input"], dtype=int)
out_arr = np.array(ex["output"], dtype=int)
result["train"].append({"input": inp_arr, "output": out_arr})
for ex in arc_problem.get("test", []):
inp_arr = np.array(ex["input"], dtype=int)
out_arr = np.array(ex["output"], dtype=int) if "output" in ex else None
result["test"].append({"input": inp_arr, "output": out_arr})
return result
# Fallback: ARC Python objects (best-effort)
result: Dict[str, List[Dict[str, np.ndarray]]] = {"train": [], "test": []}
try:
# test
try:
test_in = arc_problem.test_set().get_input_data().data()
result["test"].append(
{"input": np.array(test_in, dtype=int), "output": None}
)
except Exception:
pass
# train
try:
train_set = arc_problem.training_set()
for td in train_set:
try:
inp = td.get_input_data().data()
outp = td.get_output_data().data()
result["train"].append(
{
"input": np.array(inp, dtype=int),
"output": np.array(outp, dtype=int),
}
)
except Exception:
pass
except Exception:
pass
return result
except Exception:
return {"train": [], "test": []}
def make_predictions(self, arc_problem: Any) -> List[np.ndarray]:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment