Antik Khan
Add annotations
3d3ae36
Raw
History Blame Contribute Delete
3.7 kB
{
"task": {
"id": "case_129",
"name": "check_multiple_of_n",
"summary": "Checks if all elements are a multiple of n (default n=2).",
"examples": [
{
"input": [
"BOS",
0,
28,
2,
6,
22,
16,
26,
20,
10
],
"output": [
"BOS",
1,
1,
1,
1,
1,
1,
1,
1,
1
]
},
{
"input": [
"BOS",
0,
8,
2,
26,
9,
6,
20,
24,
12
],
"output": [
"BOS",
0,
0,
0,
0,
0,
0,
0,
0,
0
]
},
{
"input": [
"BOS",
4,
10,
14,
0,
6,
9,
12,
8,
18
],
"output": [
"BOS",
0,
0,
0,
0,
0,
0,
0,
0,
0
]
},
{
"input": [
"BOS",
0,
22,
8,
6,
26,
4,
2,
16,
24
],
"output": [
"BOS",
1,
1,
1,
1,
1,
1,
1,
1,
1
]
},
{
"input": [
"BOS",
2,
26,
8,
14,
29,
18,
0,
10,
16
],
"output": [
"BOS",
0,
0,
0,
0,
0,
0,
0,
0,
0
]
}
],
"is_categorical": true
},
"program": "checks = rasp.Map(lambda x: 1 if x % n == 0 else 0, rasp.tokens).named(f\"check_multiple_of_{n}\")\nzero_selector = rasp.Select(checks, rasp.Map(lambda x: 0, rasp.indices), rasp.Comparison.EQ)\nreturn rasp.Map(lambda x: 0 if x > 0 else 1, rasp.SelectorWidth(zero_selector))",
"components": [
{
"id": "L0_MLP",
"hook": "blocks.0.mlp.hook_post",
"role": {
"tag": "INDICATOR",
"note": "Computes a per-element pass/fail flag indicating whether each value is divisible by n."
},
"rasp_vars": [
"checks"
],
"labels": [
"check_multiple_of_2_4",
"map_5"
]
},
{
"id": "L1H0_ATTN",
"hook": "blocks.1.attn.hook_result[0]",
"role": {
"tag": "AGGREGATOR",
"note": "Aggregates positions where the divisibility flag is zero, producing a per-position count of non-multiple occurrences."
},
"rasp_vars": [
"zero_selector"
],
"labels": [
"selector_width_2_selector_width_attn_output"
]
},
{
"id": "L1_MLP",
"hook": "blocks.1.mlp.hook_post",
"role": {
"tag": "MAPPER",
"note": "Summarizes the mismatch count signal into a single global indicator shared across positions."
},
"rasp_vars": [
"mismatch_count"
],
"labels": [
"selector_width_2"
]
},
{
"id": "L2_MLP",
"hook": "blocks.2.mlp.hook_post",
"role": {
"tag": "INDICATOR",
"note": "Converts the global mismatch indicator into the final decision: all-multiples vs not-all-multiples."
},
"rasp_vars": [
"all_multiples"
],
"labels": [
"map_1"
]
}
]
}