omega-rosetta
aien-dev/omega-rosetta
Brought by drakestapleton
omega-rosetta / exercises / sum-of-multiples / test.om
| 1 | note ---- test harness (appended after the solution by exercise.sh) ---- |
| 2 | text tok "ok " |
| 3 | text tnok "not ok " |
| 4 | text tsep " - " |
| 5 | text tnl "\n" |
| 6 | global tfails ulong 1 |
| 7 | global tnum ulong 1 |
| 8 | fn temit a view uchar * to void |
| 9 | o = ulong 0 |
| 10 | while lt o len a bound 4096 |
| 11 | k = write 1 a o sub len a o |
| 12 | if le k 0 |
| 13 | exit 2 |
| 14 | end |
| 15 | o = add o ulong k |
| 16 | end |
| 17 | end |
| 18 | fn temitu n ulong to void |
| 19 | d = new uchar 20 0 |
| 20 | i = ulong 20 |
| 21 | v = n |
| 22 | while true bound 20 |
| 23 | i = sub i 1 |
| 24 | put d i uchar add rem v 10 48 |
| 25 | v = div v 10 |
| 26 | if eq v 0 |
| 27 | break |
| 28 | end |
| 29 | end |
| 30 | temit part d i sub 20 i |
| 31 | end |
| 32 | note one TAP-style line per case; main returns the number of failed cases |
| 33 | fn tcheck c bool what view uchar * to void |
| 34 | put tnum 0 add get tnum 0 1 |
| 35 | if c |
| 36 | temit tok |
| 37 | else |
| 38 | temit tnok |
| 39 | put tfails 0 add get tfails 0 1 |
| 40 | end |
| 41 | temitu get tnum 0 |
| 42 | temit tsep |
| 43 | temit what |
| 44 | temit tnl |
| 45 | end |
| 46 | note cases: exercism/problem-specifications exercises/sum-of-multiples/canonical-data.json at |
| 47 | note commit 650bebeb39ad40439175288042aece982b0a90a9 (2026-10-19), MIT licence, |
| 48 | note https://github.com/exercism/problem-specifications |
| 49 | note 16 cases kept, 0 skipped |
| 50 | text c0 "sum: no multiples within limit" |
| 51 | text c1 "sum: one factor has multiples within limit" |
| 52 | text c2 "sum: more than one multiple within limit" |
| 53 | text c3 "sum: more than one factor with multiples within limit" |
| 54 | text c4 "sum: each multiple is only counted once" |
| 55 | text c5 "sum: a much larger limit" |
| 56 | text c6 "sum: three factors" |
| 57 | text c7 "sum: factors not relatively prime" |
| 58 | text c8 "sum: some pairs of factors relatively prime and some not" |
| 59 | text c9 "sum: one factor is a multiple of another" |
| 60 | text c10 "sum: much larger factors" |
| 61 | text c11 "sum: all numbers are multiples of 1" |
| 62 | text c12 "sum: no factors means an empty sum" |
| 63 | text c13 "sum: the only multiple of 0 is 0" |
| 64 | text c14 "sum: the factor 0 does not affect the sum of multiples of other factors" |
| 65 | text c15 "sum: solutions using include-exclude must extend to cardinality greater than 3" |
| 66 | note canonical case 54aaab5a-ce86-4edc-8b40-d3ab2400a279 |
| 67 | fn tc0 to bool |
| 68 | a0 = new ulong 2 0 |
| 69 | put a0 0 3 |
| 70 | put a0 1 5 |
| 71 | ret eq sum a0 1 0 |
| 72 | end |
| 73 | note canonical case 361e4e50-c89b-4f60-95ef-5bc5c595490a |
| 74 | fn tc1 to bool |
| 75 | a0 = new ulong 2 0 |
| 76 | put a0 0 3 |
| 77 | put a0 1 5 |
| 78 | ret eq sum a0 4 3 |
| 79 | end |
| 80 | note canonical case e644e070-040e-4ae0-9910-93c69fc3f7ce |
| 81 | fn tc2 to bool |
| 82 | a0 = new ulong 1 0 |
| 83 | put a0 0 3 |
| 84 | ret eq sum a0 7 9 |
| 85 | end |
| 86 | note canonical case 607d6eb9-535c-41ce-91b5-3a61da3fa57f |
| 87 | fn tc3 to bool |
| 88 | a0 = new ulong 2 0 |
| 89 | put a0 0 3 |
| 90 | put a0 1 5 |
| 91 | ret eq sum a0 10 23 |
| 92 | end |
| 93 | note canonical case f47e8209-c0c5-4786-b07b-dc273bf86b9b |
| 94 | fn tc4 to bool |
| 95 | a0 = new ulong 2 0 |
| 96 | put a0 0 3 |
| 97 | put a0 1 5 |
| 98 | ret eq sum a0 100 2318 |
| 99 | end |
| 100 | note canonical case 28c4b267-c980-4054-93e9-07723db615ac |
| 101 | fn tc5 to bool |
| 102 | a0 = new ulong 2 0 |
| 103 | put a0 0 3 |
| 104 | put a0 1 5 |
| 105 | ret eq sum a0 1000 233168 |
| 106 | end |
| 107 | note canonical case 09c4494d-ff2d-4e0f-8421-f5532821ee12 |
| 108 | fn tc6 to bool |
| 109 | a0 = new ulong 3 0 |
| 110 | put a0 0 7 |
| 111 | put a0 1 13 |
| 112 | put a0 2 17 |
| 113 | ret eq sum a0 20 51 |
| 114 | end |
| 115 | note canonical case 2d0d5faa-f177-4ad6-bde9-ebb865083751 |
| 116 | fn tc7 to bool |
| 117 | a0 = new ulong 2 0 |
| 118 | put a0 0 4 |
| 119 | put a0 1 6 |
| 120 | ret eq sum a0 15 30 |
| 121 | end |
| 122 | note canonical case ece8f2e8-96aa-4166-bbb7-6ce71261e354 |
| 123 | fn tc8 to bool |
| 124 | a0 = new ulong 3 0 |
| 125 | put a0 0 5 |
| 126 | put a0 1 6 |
| 127 | put a0 2 8 |
| 128 | ret eq sum a0 150 4419 |
| 129 | end |
| 130 | note canonical case 624fdade-6ffb-400e-8472-456a38c171c0 |
| 131 | fn tc9 to bool |
| 132 | a0 = new ulong 2 0 |
| 133 | put a0 0 5 |
| 134 | put a0 1 25 |
| 135 | ret eq sum a0 51 275 |
| 136 | end |
| 137 | note canonical case 949ee7eb-db51-479c-b5cb-4a22b40ac057 |
| 138 | fn tc10 to bool |
| 139 | a0 = new ulong 2 0 |
| 140 | put a0 0 43 |
| 141 | put a0 1 47 |
| 142 | ret eq sum a0 10000 2203160 |
| 143 | end |
| 144 | note canonical case 41093673-acbd-482c-ab80-d00a0cbedecd |
| 145 | fn tc11 to bool |
| 146 | a0 = new ulong 1 0 |
| 147 | put a0 0 1 |
| 148 | ret eq sum a0 100 4950 |
| 149 | end |
| 150 | note canonical case 1730453b-baaa-438e-a9c2-d754497b2a76 |
| 151 | fn tc12 to bool |
| 152 | a0 = new ulong 1 0 |
| 153 | ret eq sum part a0 0 0 10000 0 |
| 154 | end |
| 155 | note canonical case 214a01e9-f4bf-45bb-80f1-1dce9fbb0310 |
| 156 | fn tc13 to bool |
| 157 | a0 = new ulong 1 0 |
| 158 | put a0 0 0 |
| 159 | ret eq sum a0 1 0 |
| 160 | end |
| 161 | note canonical case c423ae21-a0cb-4ec7-aeb1-32971af5b510 |
| 162 | fn tc14 to bool |
| 163 | a0 = new ulong 2 0 |
| 164 | put a0 0 3 |
| 165 | put a0 1 0 |
| 166 | ret eq sum a0 4 3 |
| 167 | end |
| 168 | note canonical case 17053ba9-112f-4ac0-aadb-0519dd836342 |
| 169 | fn tc15 to bool |
| 170 | a0 = new ulong 5 0 |
| 171 | put a0 0 2 |
| 172 | put a0 1 3 |
| 173 | put a0 2 5 |
| 174 | put a0 3 7 |
| 175 | put a0 4 11 |
| 176 | ret eq sum a0 10000 39614537 |
| 177 | end |
| 178 | fn main to int |
| 179 | tcheck tc0 c0 |
| 180 | tcheck tc1 c1 |
| 181 | tcheck tc2 c2 |
| 182 | tcheck tc3 c3 |
| 183 | tcheck tc4 c4 |
| 184 | tcheck tc5 c5 |
| 185 | tcheck tc6 c6 |
| 186 | tcheck tc7 c7 |
| 187 | tcheck tc8 c8 |
| 188 | tcheck tc9 c9 |
| 189 | tcheck tc10 c10 |
| 190 | tcheck tc11 c11 |
| 191 | tcheck tc12 c12 |
| 192 | tcheck tc13 c13 |
| 193 | tcheck tc14 c14 |
| 194 | tcheck tc15 c15 |
| 195 | ret int get tfails 0 |
| 196 | end |