-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgen_solution.jinja2
More file actions
112 lines (89 loc) · 4.97 KB
/
gen_solution.jinja2
File metadata and controls
112 lines (89 loc) · 4.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
You are an expert visual puzzle solver with advanced pattern recognition capabilities. Your task is to systematically analyze a complex visual transformation puzzle, break it down into clear logical steps, and implement a robust code solution that can generalize to new test cases.
## Visual Puzzle Problem Description
This is an Abstract Reasoning Challenge (ARC) puzzle that tests your ability to identify abstract patterns and transformations. The puzzle structure consists of:
### Training Examples
- Multiple example pairs (typically 2-4 pairs) that demonstrate a consistent transformation rule
- Each pair contains:
- **Input grid**: A 2D array of colored pixels representing the initial state
- **Output grid**: A 2D array of colored pixels showing the result after applying the transformation
- The transformation rule is **invariant** across all training pairs - your job is to discover this hidden rule
### Test Challenge
- You are provided with one or more test input grids
- These grids follow the same underlying transformation rule as the training examples
- Your goal is to apply the discovered rule to generate the correct output grid(s)
- The test grids may have different dimensions or slight variations, but the core transformation logic remains consistent
### Key Principles
- **Pattern Recognition**: Look for spatial relationships, color changes, shape manipulations, or geometric transformations
- **Abstraction**: The rule often involves abstract concepts like symmetry, repetition, conditional logic, or mathematical operations
- **Generalization**: Your solution must work not just for the training examples, but also for unseen test cases that follow the same rule
- **Precision**: Grid-based puzzles require exact pixel-level accuracy - small errors can invalidate the entire solution
### Image Color Code
The original problem is a 2D grid of pixels, each pixel value is a color. To make it easier to visualize, we use a color to represent the pixel value. The pixel value to color mapping is as follows:
{% for color in colors %}
- {{ color.name }} ({{ color.code }})
{% endfor %}
## Analysis of the Problem
The training data is a few input-output pairs of the same puzzle. The following are the observations of the grids for each pair. You need to pay attention to the them and find out the **USEFUL** information:
{% for observation in example_observations %}
### Example Pair {{ loop.index }}
#### Grid Pair Image

#### Pixel Color Statistics
{{ observation.color_stats }}
{% if observation.input_features %}
#### Input Grid Features
{{ observation.input_features }}
{% endif %}
{% if observation.output_features %}
#### Output Grid Features
{{ observation.output_features }}
{% endif %}
{% if observation.difference %}
#### Comparison between Input and Output Grids
{{ observation.difference }}
{% endif %}
{% endfor %}
## Your Task
Now try your best to break down the current problem, I want you first to write a solution design, and then write the code to solve the puzzle. The test problem input and description are as follows:
{% for test_case in tests %}
### Test Grid {{ loop.index }}
#### Test Grid Image

{% if test_case.features %}
#### Test Grid Features
{{ test_case.features }}
{% endif %}
{% endfor %}
### Useful Libraries
Detailed code in lib llm_libs.shapes.py is as follows, those code are useful for you to solve the puzzle.
```python
{% for lib in code_libs %}
{{ lib }}
{% endfor %}
```
### Requirements
Your answer should consist of two distinct parts:
**Part 1: Solution Design (wrapped in ```markdown ``` tags)**
- Analyze the transformation pattern observed in the training examples
- Identify the key rules and logic that govern the input-to-output transformation
- Break down the solution into clear, step-by-step pseudocode
- Explain how each step contributes to achieving the desired output
- Consider edge cases and how they should be handled
- Describe how you will apply this logic to the test input
**Part 2: Implementation Code (wrapped in ```python ``` tags)**
- Write clean, well-commented Python code that implements your solution design
- Use the provided libraries (Grid, Shape, BBox, Pixel) effectively
- Follow the exact function signature specified below
- Ensure your code handles all the transformation rules identified in your design
- Return a numpy array as the final output (not a Grid object)
- Test your logic mentally against the training examples to verify correctness
#### Function Signature
```python
from llm_libs.shapes import Grid, Shape, BBox, Pixel, ShapeType
import numpy as np
def solve(train_input_grid: list[Grid], train_output_grid: list[Grid], test_input_grid: Grid) -> np.ndarray:
```
- The training inputs and outputs are initialized by `Grid` class in the `llm_libs.grid` module.
- Do not return Grid object, return a numpy array instead.
- The test input is initialized by `Grid` class in the `llm_libs.grid` module.
- The output is a numpy array of data type int64.