Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/si/rosetta/exercises/change/test.om # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / si / rosetta / exercises / change / test.om` 307 lines ยท 5834 bytes Raw Blame History 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/change/canonical-data.json at 47 note commit `650bebeb39ad40439175288042aece982b0a90a9` (2026-10-19), MIT licence, 48 note https://github.com/exercism/problem-specifications 49 note 13 cases kept, 0 skipped 50 fn tueq a view ulong * b view ulong * to bool 51 if ne len a len b 52 ret false 53 end 54 for i ulong len a 55 if ne get a i get b i 56 ret false 57 end 58 end 59 ret true 60 end 61 text c0 "findFewestCoins: change for 1 cent" 62 text c1 "findFewestCoins: single coin change" 63 text c2 "findFewestCoins: multiple coin change" 64 text c3 "findFewestCoins: change with Lilliputian Coins" 65 text c4 "findFewestCoins: change with Lower Elbonia Coins" 66 text c5 "findFewestCoins: large target values" 67 text c6 "findFewestCoins: possible change without unit coins available" 68 text c7 "findFewestCoins: another possible change without unit coins available" 69 text c8 "findFewestCoins: a greedy approach is not optimal" 70 text c9 "findFewestCoins: no coins make 0 change" 71 text c10 "findFewestCoins: error testing for change smaller than the smallest of coins" 72 text c11 "findFewestCoins: error if no combination can add up to target" 73 text c12 "findFewestCoins: cannot find negative change values" 74 note canonical case `d0ebd0e1`-9d27-4609-a654-`df5c0ba1d83a` 75 fn tc0 to bool 76 a0 = new ulong 4 0 77 put a0 0 1 78 put a0 1 5 79 put a0 2 10 80 put a0 3 25 81 o = new ulong 256 0 82 n = findfewestcoins a0 1 o 83 if lt n 0 84 ret false 85 end 86 a1 = new ulong 1 0 87 put a1 0 1 88 ret tueq part o 0 ulong n a1 89 end 90 note canonical case `36887bea`-7f92-4a9c-b0cc-`c0e886b3ecc8` 91 fn tc1 to bool 92 a0 = new ulong 5 0 93 put a0 0 1 94 put a0 1 5 95 put a0 2 10 96 put a0 3 25 97 put a0 4 100 98 o = new ulong 256 0 99 n = findfewestcoins a0 25 o 100 if lt n 0 101 ret false 102 end 103 a1 = new ulong 1 0 104 put a1 0 25 105 ret tueq part o 0 ulong n a1 106 end 107 note canonical case `cef21ccc`-0811-4e6e-af44-`f011e7eab6c6` 108 fn tc2 to bool 109 a0 = new ulong 5 0 110 put a0 0 1 111 put a0 1 5 112 put a0 2 10 113 put a0 3 25 114 put a0 4 100 115 o = new ulong 256 0 116 n = findfewestcoins a0 15 o 117 if lt n 0 118 ret false 119 end 120 a1 = new ulong 2 0 121 put a1 0 5 122 put a1 1 10 123 ret tueq part o 0 ulong n a1 124 end 125 note canonical case `d60952bc`-0c1a-4571-bf0c-`41be72690cb3` 126 fn tc3 to bool 127 a0 = new ulong 5 0 128 put a0 0 1 129 put a0 1 4 130 put a0 2 15 131 put a0 3 20 132 put a0 4 50 133 o = new ulong 256 0 134 n = findfewestcoins a0 23 o 135 if lt n 0 136 ret false 137 end 138 a1 = new ulong 3 0 139 put a1 0 4 140 put a1 1 4 141 put a1 2 15 142 ret tueq part o 0 ulong n a1 143 end 144 note canonical case `408390b9`-fafa-4bb9-b608-`ffe6036edb6c` 145 fn tc4 to bool 146 a0 = new ulong 5 0 147 put a0 0 1 148 put a0 1 5 149 put a0 2 10 150 put a0 3 21 151 put a0 4 25 152 o = new ulong 256 0 153 n = findfewestcoins a0 63 o 154 if lt n 0 155 ret false 156 end 157 a1 = new ulong 3 0 158 put a1 0 21 159 put a1 1 21 160 put a1 2 21 161 ret tueq part o 0 ulong n a1 162 end 163 note canonical case `7421a4cb`-1c48-4bf9-99c7-`7f049689132f` 164 fn tc5 to bool 165 a0 = new ulong 7 0 166 put a0 0 1 167 put a0 1 2 168 put a0 2 5 169 put a0 3 10 170 put a0 4 20 171 put a0 5 50 172 put a0 6 100 173 o = new ulong 256 0 174 n = findfewestcoins a0 999 o 175 if lt n 0 176 ret false 177 end 178 a1 = new ulong 15 0 179 put a1 0 2 180 put a1 1 2 181 put a1 2 5 182 put a1 3 20 183 put a1 4 20 184 put a1 5 50 185 put a1 6 100 186 put a1 7 100 187 put a1 8 100 188 put a1 9 100 189 put a1 10 100 190 put a1 11 100 191 put a1 12 100 192 put a1 13 100 193 put a1 14 100 194 ret tueq part o 0 ulong n a1 195 end 196 note canonical case `f79d2e9b`-0ae3-4d6a-bb58-`dc978b0dba28` 197 fn tc6 to bool 198 a0 = new ulong 5 0 199 put a0 0 2 200 put a0 1 5 201 put a0 2 10 202 put a0 3 20 203 put a0 4 50 204 o = new ulong 256 0 205 n = findfewestcoins a0 21 o 206 if lt n 0 207 ret false 208 end 209 a1 = new ulong 5 0 210 put a1 0 2 211 put a1 1 2 212 put a1 2 2 213 put a1 3 5 214 put a1 4 10 215 ret tueq part o 0 ulong n a1 216 end 217 note canonical case `9a166411`-d35d-4f7f-a007-`6724ac266178` 218 fn tc7 to bool 219 a0 = new ulong 2 0 220 put a0 0 4 221 put a0 1 5 222 o = new ulong 256 0 223 n = findfewestcoins a0 27 o 224 if lt n 0 225 ret false 226 end 227 a1 = new ulong 6 0 228 put a1 0 4 229 put a1 1 4 230 put a1 2 4 231 put a1 3 5 232 put a1 4 5 233 put a1 5 5 234 ret tueq part o 0 ulong n a1 235 end 236 note canonical case `ce0f80d5`-51c3-469d-818c-`3e69dbd25f75` 237 fn tc8 to bool 238 a0 = new ulong 3 0 239 put a0 0 1 240 put a0 1 10 241 put a0 2 11 242 o = new ulong 256 0 243 n = findfewestcoins a0 20 o 244 if lt n 0 245 ret false 246 end 247 a1 = new ulong 2 0 248 put a1 0 10 249 put a1 1 10 250 ret tueq part o 0 ulong n a1 251 end 252 note canonical case `bbbcc154`-e9e9-4209-a4db-`dd6d81ec26bb` 253 fn tc9 to bool 254 a0 = new ulong 5 0 255 put a0 0 1 256 put a0 1 5 257 put a0 2 10 258 put a0 3 21 259 put a0 4 25 260 o = new ulong 256 0 261 n = findfewestcoins a0 0 o 262 if lt n 0 263 ret false 264 end 265 ret eq ulong n 0 266 end 267 note canonical case `c8b81d5a`-49bd-4b61-af73-`8ee5383a2ce1` 268 fn tc10 to bool 269 a0 = new ulong 2 0 270 put a0 0 5 271 put a0 1 10 272 o = new ulong 256 0 273 ret eq findfewestcoins a0 3 o -1 274 end 275 note canonical case `3c43e3e4`-63f9-46ac-9476-`a67516e98f68` 276 fn tc11 to bool 277 a0 = new ulong 2 0 278 put a0 0 5 279 put a0 1 10 280 o = new ulong 256 0 281 ret eq findfewestcoins a0 94 o -1 282 end 283 note canonical case `8fe1f076`-9b2d-4f44-89fe-`8a6ccd63c8f3` 284 fn tc12 to bool 285 a0 = new ulong 3 0 286 put a0 0 1 287 put a0 1 2 288 put a0 2 5 289 o = new ulong 256 0 290 ret eq findfewestcoins a0 -5 o -2 291 end 292 fn main to int 293 tcheck tc0 c0 294 tcheck tc1 c1 295 tcheck tc2 c2 296 tcheck tc3 c3 297 tcheck tc4 c4 298 tcheck tc5 c5 299 tcheck tc6 c6 300 tcheck tc7 c7 301 tcheck tc8 c8 302 tcheck tc9 c9 303 tcheck tc10 c10 304 tcheck tc11 c11 305 tcheck tc12 c12 306 ret int get tfails 0 307 end