File size: 2,935 Bytes
3d3ae36 | 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 | {
"task": {
"id": "case_40",
"name": "sum_last_two_digits",
"summary": "Sum the last and previous to last digits of a number",
"examples": [
{
"input": [
"BOS",
6,
19,
28,
14,
10,
7,
28,
20,
6
],
"output": [
"BOS",
6,
10,
10,
5,
1,
7,
10,
2,
6
]
},
{
"input": [
"BOS",
25,
18,
22,
10,
10,
23,
20,
3,
7
],
"output": [
"BOS",
7,
9,
4,
1,
1,
5,
2,
3,
7
]
},
{
"input": [
"BOS",
16,
26,
26,
9,
27,
27,
15,
14,
14
],
"output": [
"BOS",
7,
8,
8,
9,
9,
9,
6,
5,
5
]
},
{
"input": [
"BOS",
27,
20,
0,
11,
25,
21,
28,
11,
24
],
"output": [
"BOS",
9,
2,
0,
2,
7,
3,
10,
2,
6
]
},
{
"input": [
"BOS",
23,
2,
21,
20,
1,
23,
11,
5,
1
],
"output": [
"BOS",
5,
2,
3,
2,
1,
5,
2,
5,
1
]
}
],
"is_categorical": true
},
"program": "tens_place = rasp.Map(lambda x: x // 10, rasp.tokens).named(\"tens_place\")\nones_place = rasp.Map(lambda x: x % 10, rasp.tokens).named(\"ones_place\")\nsum_digits = rasp.SequenceMap(lambda x, y: x + y, tens_place, ones_place).named(\"sum_digits\")\nreturn sum_digits",
"components": [
{
"id": "L0_MLP",
"hook": "blocks.0.mlp.hook_post",
"role": {
"tag": "MAPPER",
"note": "Derives the tens-place digit and also the ones-place digit from each input number."
},
"rasp_vars": [
"tens_place, ones_place"
],
"labels": [
"tens_place_2, ones_place_3"
]
},
{
"id": "L1_MLP",
"hook": "blocks.1.mlp.hook_post",
"role": {
"tag": "COMBINER",
"note": "Adds the tens-place and ones-place digits to produce the final per-token output."
},
"rasp_vars": [
"sum_digits"
],
"labels": [
"sum_digits_1"
]
}
]
}
|