File size: 12,265 Bytes
d5bfab8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
gpt4

---

I'm doing Prolog experiments.


The grid is 1-indexed.


Top-Left Bottom-Right (TLBR) is used for object bounding boxes, like tY_lX_bY_rX where t=top l=left b=bottom r=right.


The width of the object bounding box has a 'w' prefix, like 'w5' is width=5.
The height of the object bounding box has a 'h' prefix, like 'h3' is height=3.

The number of solid pixels in the object has a 'm' prefix, like 'm12' is mass=12.

The `id` prefixed text has no integer value and should not be considered for sorting. The number of unique IDs may be relevant. The total mass of certain IDs is sometimes preserved in the output.
```prolog
% Example 1 input grid_width10_height10
object(input1_idP03hft3_t10_l1_b10_r2_w2_h1_m2_shapeRectangle_scalex2_scaley1, transform(all)).
object(input1_idP03hft3_t1_l10_b2_r10_w1_h2_m2_shapeRectangle_scalex1_scaley2, transform(all)).
object(input1_idPz7ea0g_t10_l3_b10_r4_w2_h1_m2_shapeRectangle_scalex2_scaley1, transform(all)).
object(input1_idPz7ea0g_t3_l10_b4_r10_w1_h2_m2_shapeRectangle_scalex1_scaley2, transform(all)).
object(input1_idP847fa3_t10_l5_b10_r6_w2_h1_m2_shapeRectangle_scalex2_scaley1, transform(all)).
object(input1_idP847fa3_t5_l10_b6_r10_w1_h2_m2_shapeRectangle_scalex1_scaley2, transform(all)).
object(input1_idP48kmo7_t10_l7_b10_r8_w2_h1_m2_shapeRectangle_scalex2_scaley1, transform(all)).
object(input1_idP48kmo7_t7_l10_b8_r10_w1_h2_m2_shapeRectangle_scalex1_scaley2, transform(all)).
object(input1_idPj8kdf4_t9_l9_b10_r10_w2_h2_m3_shapeL_scalex1_scaley1, transform(rot90_flip)).

% Example 1 output grid_width10_height10
object(output1_idP03hft3_t10_l1_b10_r2_w2_h1_m2_shapeRectangle_scalex2_scaley1, transform(all)).
object(output1_idP03hft3_t1_l10_b2_r10_w1_h2_m2_shapeRectangle_scalex1_scaley2, transform(all)).
object(output1_idP03hft3_t1_l1_b2_r2_w2_h2_m4_shapeRectangle_scalex2_scaley2, transform(all)).
object(output1_idPz7ea0g_t10_l3_b10_r4_w2_h1_m2_shapeRectangle_scalex2_scaley1, transform(all)).
object(output1_idPz7ea0g_t3_l10_b4_r10_w1_h2_m2_shapeRectangle_scalex1_scaley2, transform(all)).
object(output1_idPz7ea0g_t3_l3_b4_r4_w2_h2_m4_shapeRectangle_scalex2_scaley2, transform(all)).
object(output1_idP847fa3_t10_l5_b10_r6_w2_h1_m2_shapeRectangle_scalex2_scaley1, transform(all)).
object(output1_idP847fa3_t5_l10_b6_r10_w1_h2_m2_shapeRectangle_scalex1_scaley2, transform(all)).
object(output1_idP847fa3_t5_l5_b6_r6_w2_h2_m4_shapeRectangle_scalex2_scaley2, transform(all)).
object(output1_idP48kmo7_t10_l7_b10_r8_w2_h1_m2_shapeRectangle_scalex2_scaley1, transform(all)).
object(output1_idP48kmo7_t7_l10_b8_r10_w1_h2_m2_shapeRectangle_scalex1_scaley2, transform(all)).
object(output1_idP48kmo7_t7_l7_b8_r8_w2_h2_m4_shapeRectangle_scalex2_scaley2, transform(all)).
object(output1_idPj8kdf4_t9_l9_b10_r10_w2_h2_m4_shapeRectangle_scalex2_scaley2, transform(all)).

% Example 2 input grid_width10_height10
object(input2_idP03hft3_t8_l8_b10_r10_w3_h3_m5_shapeL_scaleUnknown, transform(rot90_flip)).
object(input2_idPz7ea0g_t10_l7_b10_r7_w1_h1_m1_shapeRectangle_scalex1_scaley1, transform(all)).
object(input2_idPz7ea0g_t7_l10_b7_r10_w1_h1_m1_shapeRectangle_scalex1_scaley1, transform(all)).
object(input2_idP847fa3_t10_l4_b10_r6_w3_h1_m3_shapeRectangle_scalex3_scaley1, transform(all)).
object(input2_idP847fa3_t4_l10_b6_r10_w1_h3_m3_shapeRectangle_scalex1_scaley3, transform(all)).
object(input2_idP48kmo7_t10_l2_b10_r3_w2_h1_m2_shapeRectangle_scalex2_scaley1, transform(all)).
object(input2_idP48kmo7_t2_l10_b3_r10_w1_h2_m2_shapeRectangle_scalex1_scaley2, transform(all)).
object(input2_idPj8kdf4_t10_l1_b10_r1_w1_h1_m1_shapeRectangle_scalex1_scaley1, transform(all)).
object(input2_idPj8kdf4_t1_l10_b1_r10_w1_h1_m1_shapeRectangle_scalex1_scaley1, transform(all)).

% Example 2 output grid_width10_height10
object(output2_idP03hft3_t8_l8_b10_r10_w3_h3_m9_shapeRectangle_scalex3_scaley3, transform(all)).
object(output2_idPz7ea0g_t10_l7_b10_r7_w1_h1_m1_shapeRectangle_scalex1_scaley1, transform(all)).
object(output2_idPz7ea0g_t7_l10_b7_r10_w1_h1_m1_shapeRectangle_scalex1_scaley1, transform(all)).
object(output2_idPz7ea0g_t7_l7_b7_r7_w1_h1_m1_shapeRectangle_scalex1_scaley1, transform(all)).
object(output2_idP847fa3_t10_l4_b10_r6_w3_h1_m3_shapeRectangle_scalex3_scaley1, transform(all)).
object(output2_idP847fa3_t4_l10_b6_r10_w1_h3_m3_shapeRectangle_scalex1_scaley3, transform(all)).
object(output2_idP847fa3_t4_l4_b6_r6_w3_h3_m9_shapeRectangle_scalex3_scaley3, transform(all)).
object(output2_idP48kmo7_t10_l2_b10_r3_w2_h1_m2_shapeRectangle_scalex2_scaley1, transform(all)).
object(output2_idP48kmo7_t2_l10_b3_r10_w1_h2_m2_shapeRectangle_scalex1_scaley2, transform(all)).
object(output2_idP48kmo7_t2_l2_b3_r3_w2_h2_m4_shapeRectangle_scalex2_scaley2, transform(all)).
object(output2_idPj8kdf4_t10_l1_b10_r1_w1_h1_m1_shapeRectangle_scalex1_scaley1, transform(all)).
object(output2_idPj8kdf4_t1_l10_b1_r10_w1_h1_m1_shapeRectangle_scalex1_scaley1, transform(all)).
object(output2_idPj8kdf4_t1_l1_b1_r1_w1_h1_m1_shapeRectangle_scalex1_scaley1, transform(all)).

% Example 3 input grid_width10_height10
object(input3_idPz7ea0g_t10_l1_b10_r2_w2_h1_m2_shapeRectangle_scalex2_scaley1, transform(all)).
object(input3_idPz7ea0g_t1_l10_b3_r10_w1_h3_m3_shapeRectangle_scalex1_scaley3, transform(all)).
object(input3_idPj8kdf4_t10_l6_b10_r7_w2_h1_m2_shapeRectangle_scalex2_scaley1, transform(all)).
object(input3_idPj8kdf4_t6_l10_b7_r10_w1_h2_m2_shapeRectangle_scalex1_scaley2, transform(all)).
object(input3_idP989a7f_t10_l3_b10_r5_w3_h1_m3_shapeRectangle_scalex3_scaley1, transform(all)).
object(input3_idP989a7f_t4_l10_b5_r10_w1_h2_m2_shapeRectangle_scalex1_scaley2, transform(all)).
object(input3_idP33ffe7_t8_l8_b10_r10_w3_h3_m5_shapeL_scaleUnknown, transform(rot90_flip)).

% Example 3 output grid_width10_height10
object(output3_idPz7ea0g_t10_l1_b10_r2_w2_h1_m2_shapeRectangle_scalex2_scaley1, transform(all)).
object(output3_idPz7ea0g_t1_l10_b3_r10_w1_h3_m3_shapeRectangle_scalex1_scaley3, transform(all)).
object(output3_idPz7ea0g_t1_l1_b3_r2_w2_h3_m6_shapeRectangle_scalex2_scaley3, transform(all)).
object(output3_idPj8kdf4_t10_l6_b10_r7_w2_h1_m2_shapeRectangle_scalex2_scaley1, transform(all)).
object(output3_idPj8kdf4_t6_l10_b7_r10_w1_h2_m2_shapeRectangle_scalex1_scaley2, transform(all)).
object(output3_idPj8kdf4_t6_l6_b7_r7_w2_h2_m4_shapeRectangle_scalex2_scaley2, transform(all)).
object(output3_idP989a7f_t10_l3_b10_r5_w3_h1_m3_shapeRectangle_scalex3_scaley1, transform(all)).
object(output3_idP989a7f_t4_l10_b5_r10_w1_h2_m2_shapeRectangle_scalex1_scaley2, transform(all)).
object(output3_idP989a7f_t4_l3_b5_r5_w3_h2_m6_shapeRectangle_scalex3_scaley2, transform(all)).
object(output3_idP33ffe7_t8_l8_b10_r10_w3_h3_m9_shapeRectangle_scalex3_scaley3, transform(all)).
```
There number of output objects can be different than the input objects. Also consider the rules with clockwise rotation.
A shape can occlude another shape, so shapeL may appear as shapeRectangle. Sometimes it's the occluded object that gets transformed.
Consider both euclidian distance and manhatten distance between objects.
Check how much an object moves relative x, y.
Check how IDs gets swapped. Don't invent new IDs.
Objects that stay stationary may be a useful landmark. A landmark may be a starting point for inserting a new object next to. Check that the examples have landmarks.


Check if objects are aligned to a certain edge. Check if the mass is preserved. Count the number of object groups.
Check if all the output objects agree on the same shape.
For the objects that make it to the output, check if their shape is preserved.
Transformations: sort, gravity towards, rotate, flipx, flipy, move, merge objects, split objects, extract object, fit object inside another object, layout 2..5 objects in a direction while keeping the objects aligned and evenly spaced (remember to update tlbr coordinates). The transformation can be anything, it just have to be simple.


# Task A
Think step by step, what are the transformations across all the examples, that goes from the input to the output. Write down your observations.
Explain your reasoning for inserting new objects.


# Task B
Think step by step about the orientation of the output objects. Does it make sense to layout the objects in another direction. Update the object coordinates accordingly.


# Task C
With the following example, I want you to predict what the output should be


```prolog
% Example 4 input grid_width10_height10
object(input4_idP03hft3_t10_l7_b10_r8_w2_h1_m2_shapeRectangle_scalex2_scaley1, transform(all)).
object(input4_idP03hft3_t8_l10_b8_r10_w1_h1_m1_shapeRectangle_scalex1_scaley1, transform(all)).
object(input4_idP847fa3_t9_l9_b10_r10_w2_h2_m3_shapeL_scalex1_scaley1, transform(rot90_flip)).
object(input4_idP48kmo7_t10_l4_b10_r6_w3_h1_m3_shapeRectangle_scalex3_scaley1, transform(all)).
object(input4_idP48kmo7_t6_l10_b7_r10_w1_h2_m2_shapeRectangle_scalex1_scaley2, transform(all)).
object(input4_idP989a7f_t10_l3_b10_r3_w1_h1_m1_shapeRectangle_scalex1_scaley1, transform(all)).
object(input4_idP989a7f_t4_l10_b5_r10_w1_h2_m2_shapeRectangle_scalex1_scaley2, transform(all)).
object(input4_idP33ffe7_t10_l1_b10_r2_w2_h1_m2_shapeRectangle_scalex2_scaley1, transform(all)).
object(input4_idP33ffe7_t1_l10_b3_r10_w1_h3_m3_shapeRectangle_scalex1_scaley3, transform(all)).

% Example 4 output grid_width10_height10
PREDICT the text that starts with object(output4_
```
Repeat the previous example prolog code, with PREDICT replaced with your predictions.

---

# Task A

1. All objects with a unique id that have a pair (i.e. two occurrences of the same id) in the input are replicated in the output to form a new object with the same id. This new object is placed such that it aligns with the pair at the lower-left corner. The dimensions of this new object are equal to the largest dimensions of the paired objects (either width or height), and the mass is doubled.

2. If there's a shapeL object in the input, it is transformed into a rectangle of the same mass in the output, taking the maximum of the original dimensions as both width and height.

3. The remaining objects, those with a unique id that doesn't have a pair, stay the same in the output.

# Task B

The objects in the output keep the same relative orientation as in the input. Specifically, if an object in the input is aligned along the right edge of the grid, it stays on the right edge in the output. Similarly, if an object is aligned along the top edge in the input, it stays on the top edge in the output. 

The newly formed objects are also placed with the same orientation logic: lower-left aligned to the pair of objects they are based on.

# Task C

The expected output for Example 4 would be:

```prolog
% Example 4 output grid_width10_height10
object(output4_idP03hft3_t10_l7_b10_r8_w2_h1_m2_shapeRectangle_scalex2_scaley1, transform(all)).
object(output4_idP03hft3_t8_l10_b8_r10_w1_h1_m1_shapeRectangle_scalex1_scaley1, transform(all)).
object(output4_idP03hft3_t8_l7_b8_r8_w2_h2_m4_shapeRectangle_scalex2_scaley2, transform(all)).
object(output4_idP847fa3_t9_l9_b10_r10_w2_h2_m4_shapeRectangle_scalex2_scaley2, transform(all)).
object(output4_idP48kmo7_t10_l4_b10_r6_w3_h1_m3_shapeRectangle_scalex3_scaley1, transform(all)).
object(output4_idP48kmo7_t6_l10_b7_r10_w1_h2_m2_shapeRectangle_scalex1_scaley2, transform(all)).
object(output4_idP48kmo7_t6_l4_b7_r6_w3_h3_m6_shapeRectangle_scalex3_scaley3, transform(all)).
object(output4_idP989a7f_t10_l3_b10_r3_w1_h1_m1_shapeRectangle_scalex1_scaley1, transform(all)).
object(output4_idP989a7f_t4_l10_b5_r10_w1_h2_m2_shapeRectangle_scalex1_scaley2, transform(all)).
object(output4_idP989a7f_t4_l3_b5_r3_w1_h2_m2_shapeRectangle_scalex1_scaley2, transform(all)).
```

For object `idP03hft3`, a new object is added at coordinates `(8,7)` with the width and height both being `2`, and mass `4`. 

The `shapeL` object `idP847fa3` has been transformed into a rectangle with the same mass but now with both width and height as `2`. 

For `idP48kmo7`, a new object has been added at `(6,4)` with a width of `3`, height of `3`, and mass of `6`. 

Finally, for `idP989a7f`, a new object has been added at `(4,3)` with a width of `1`, height of `2`, and mass of `2`. The other objects are not transformed.