Antik Khan
Add annotations
3d3ae36
Raw
History Blame Contribute Delete
2.93 kB
{
"task": {
"id": "case_53",
"name": "increment_odd_indices",
"summary": "Increment elements at odd indices by 1",
"examples": [
{
"input": [
"BOS",
2,
4,
2,
6,
4,
8,
6,
1,
3
],
"output": [
"BOS",
2,
5,
2,
7,
4,
9,
6,
2,
3
]
},
{
"input": [
"BOS",
4,
1,
7,
5,
1,
4,
0,
9,
5
],
"output": [
"BOS",
4,
2,
7,
6,
1,
5,
0,
10,
5
]
},
{
"input": [
"BOS",
10,
10,
7,
4,
3,
7,
7,
2,
5
],
"output": [
"BOS",
10,
11,
7,
5,
3,
8,
7,
3,
5
]
},
{
"input": [
"BOS",
8,
0,
10,
10,
9,
2,
6,
3,
8
],
"output": [
"BOS",
8,
1,
10,
11,
9,
3,
6,
4,
8
]
},
{
"input": [
"BOS",
6,
3,
10,
7,
4,
6,
9,
2,
6
],
"output": [
"BOS",
6,
4,
10,
8,
4,
7,
9,
3,
6
]
}
],
"is_categorical": true
},
"program": "odd_index_marker = rasp.Map(lambda x: x % 2, rasp.indices).named(\"odd_index_marker\")\nincremented_elements = rasp.SequenceMap(lambda elem, mark: elem + mark, rasp.tokens, odd_index_marker).named(\"incremented_elements\")\nreturn incremented_elements",
"components": [
{
"id": "L0_MLP",
"hook": "blocks.0.mlp.hook_post",
"role": {
"tag": "MAPPER",
"note": "Computes the parity of each position's index (index mod 2) to produce a per-position binary value used as an increment signal."
},
"rasp_vars": [
"odd_index_marker"
],
"labels": [
"odd_index_marker_2"
]
},
{
"id": "L1_MLP",
"hook": "blocks.1.mlp.hook_post",
"role": {
"tag": "COMBINER",
"note": "Adds the odd-index marker to each element so only odd positions are incremented."
},
"rasp_vars": [
"incremented_elements"
],
"labels": [
"incremented_elements_1"
]
}
]
}