omega-rosetta
aien-dev/omega-rosetta
Brought by drakestapleton
omega-rosetta / exercises / saddle-points / 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/saddle-points/canonical-data.json at |
| 47 | note commit 650bebeb39ad40439175288042aece982b0a90a9 (2026-10-19), MIT licence, |
| 48 | note https://github.com/exercism/problem-specifications |
| 49 | note 9 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 "saddlePoints: Can identify single saddle point" |
| 62 | text c1 "saddlePoints: Can identify that empty matrix has no saddle points" |
| 63 | text c2 "saddlePoints: Can identify lack of saddle points when there are none" |
| 64 | text c3 "saddlePoints: Can identify multiple saddle points in a column" |
| 65 | text c4 "saddlePoints: Can identify multiple saddle points in a row" |
| 66 | text c5 "saddlePoints: Can identify saddle point in bottom right corner" |
| 67 | text c6 "saddlePoints: Can identify saddle points in a non square matrix" |
| 68 | text c7 "saddlePoints: Can identify that saddle points in a single column matrix are those with the minimum value" |
| 69 | text c8 "saddlePoints: Can identify that saddle points in a single row matrix are those with the maximum value" |
| 70 | note canonical case 3e374e63-a2e0-4530-a39a-d53c560382bd |
| 71 | fn tc0 to bool |
| 72 | a0 = new ulong 9 0 |
| 73 | put a0 0 9 |
| 74 | put a0 1 8 |
| 75 | put a0 2 7 |
| 76 | put a0 3 5 |
| 77 | put a0 4 3 |
| 78 | put a0 5 2 |
| 79 | put a0 6 6 |
| 80 | put a0 7 6 |
| 81 | put a0 8 7 |
| 82 | o = new ulong 256 0 |
| 83 | n = saddlepoints a0 3 3 o |
| 84 | a1 = new ulong 2 0 |
| 85 | put a1 0 2 |
| 86 | put a1 1 1 |
| 87 | ret tueq part o 0 mul n 2 a1 |
| 88 | end |
| 89 | note canonical case 6b501e2b-6c1f-491f-b1bb-7f278f760534 |
| 90 | fn tc1 to bool |
| 91 | a0 = new ulong 1 0 |
| 92 | o = new ulong 256 0 |
| 93 | n = saddlepoints part a0 0 0 1 0 o |
| 94 | ret eq mul n 2 0 |
| 95 | end |
| 96 | note canonical case 8c27cc64-e573-4fcb-a099-f0ae863fb02f |
| 97 | fn tc2 to bool |
| 98 | a0 = new ulong 9 0 |
| 99 | put a0 0 1 |
| 100 | put a0 1 2 |
| 101 | put a0 2 3 |
| 102 | put a0 3 3 |
| 103 | put a0 4 1 |
| 104 | put a0 5 2 |
| 105 | put a0 6 2 |
| 106 | put a0 7 3 |
| 107 | put a0 8 1 |
| 108 | o = new ulong 256 0 |
| 109 | n = saddlepoints a0 3 3 o |
| 110 | ret eq mul n 2 0 |
| 111 | end |
| 112 | note canonical case 6d1399bd-e105-40fd-a2c9-c6609507d7a3 |
| 113 | fn tc3 to bool |
| 114 | a0 = new ulong 9 0 |
| 115 | put a0 0 4 |
| 116 | put a0 1 5 |
| 117 | put a0 2 4 |
| 118 | put a0 3 3 |
| 119 | put a0 4 5 |
| 120 | put a0 5 5 |
| 121 | put a0 6 1 |
| 122 | put a0 7 5 |
| 123 | put a0 8 4 |
| 124 | o = new ulong 256 0 |
| 125 | n = saddlepoints a0 3 3 o |
| 126 | a1 = new ulong 6 0 |
| 127 | put a1 0 1 |
| 128 | put a1 1 2 |
| 129 | put a1 2 2 |
| 130 | put a1 3 2 |
| 131 | put a1 4 3 |
| 132 | put a1 5 2 |
| 133 | ret tueq part o 0 mul n 2 a1 |
| 134 | end |
| 135 | note canonical case 3e81dce9-53b3-44e6-bf26-e328885fd5d1 |
| 136 | fn tc4 to bool |
| 137 | a0 = new ulong 9 0 |
| 138 | put a0 0 6 |
| 139 | put a0 1 7 |
| 140 | put a0 2 8 |
| 141 | put a0 3 5 |
| 142 | put a0 4 5 |
| 143 | put a0 5 5 |
| 144 | put a0 6 7 |
| 145 | put a0 7 5 |
| 146 | put a0 8 6 |
| 147 | o = new ulong 256 0 |
| 148 | n = saddlepoints a0 3 3 o |
| 149 | a1 = new ulong 6 0 |
| 150 | put a1 0 2 |
| 151 | put a1 1 1 |
| 152 | put a1 2 2 |
| 153 | put a1 3 2 |
| 154 | put a1 4 2 |
| 155 | put a1 5 3 |
| 156 | ret tueq part o 0 mul n 2 a1 |
| 157 | end |
| 158 | note canonical case 88868621-b6f4-4837-bb8b-3fad8b25d46b |
| 159 | fn tc5 to bool |
| 160 | a0 = new ulong 9 0 |
| 161 | put a0 0 8 |
| 162 | put a0 1 7 |
| 163 | put a0 2 9 |
| 164 | put a0 3 6 |
| 165 | put a0 4 7 |
| 166 | put a0 5 6 |
| 167 | put a0 6 3 |
| 168 | put a0 7 2 |
| 169 | put a0 8 5 |
| 170 | o = new ulong 256 0 |
| 171 | n = saddlepoints a0 3 3 o |
| 172 | a1 = new ulong 2 0 |
| 173 | put a1 0 3 |
| 174 | put a1 1 3 |
| 175 | ret tueq part o 0 mul n 2 a1 |
| 176 | end |
| 177 | note canonical case 5b9499ca-fcea-4195-830a-9c4584a0ee79 |
| 178 | fn tc6 to bool |
| 179 | a0 = new ulong 6 0 |
| 180 | put a0 0 3 |
| 181 | put a0 1 1 |
| 182 | put a0 2 3 |
| 183 | put a0 3 3 |
| 184 | put a0 4 2 |
| 185 | put a0 5 4 |
| 186 | o = new ulong 256 0 |
| 187 | n = saddlepoints a0 2 3 o |
| 188 | a1 = new ulong 4 0 |
| 189 | put a1 0 1 |
| 190 | put a1 1 1 |
| 191 | put a1 2 1 |
| 192 | put a1 3 3 |
| 193 | ret tueq part o 0 mul n 2 a1 |
| 194 | end |
| 195 | note canonical case ee99ccd2-a1f1-4283-ad39-f8c70f0cf594 |
| 196 | fn tc7 to bool |
| 197 | a0 = new ulong 4 0 |
| 198 | put a0 0 2 |
| 199 | put a0 1 1 |
| 200 | put a0 2 4 |
| 201 | put a0 3 1 |
| 202 | o = new ulong 256 0 |
| 203 | n = saddlepoints a0 4 1 o |
| 204 | a1 = new ulong 4 0 |
| 205 | put a1 0 2 |
| 206 | put a1 1 1 |
| 207 | put a1 2 4 |
| 208 | put a1 3 1 |
| 209 | ret tueq part o 0 mul n 2 a1 |
| 210 | end |
| 211 | note canonical case 63abf709-a84b-407f-a1b3-456638689713 |
| 212 | fn tc8 to bool |
| 213 | a0 = new ulong 4 0 |
| 214 | put a0 0 2 |
| 215 | put a0 1 5 |
| 216 | put a0 2 3 |
| 217 | put a0 3 5 |
| 218 | o = new ulong 256 0 |
| 219 | n = saddlepoints a0 1 4 o |
| 220 | a1 = new ulong 4 0 |
| 221 | put a1 0 1 |
| 222 | put a1 1 2 |
| 223 | put a1 2 1 |
| 224 | put a1 3 4 |
| 225 | ret tueq part o 0 mul n 2 a1 |
| 226 | end |
| 227 | fn main to int |
| 228 | tcheck tc0 c0 |
| 229 | tcheck tc1 c1 |
| 230 | tcheck tc2 c2 |
| 231 | tcheck tc3 c3 |
| 232 | tcheck tc4 c4 |
| 233 | tcheck tc5 c5 |
| 234 | tcheck tc6 c6 |
| 235 | tcheck tc7 c7 |
| 236 | tcheck tc8 c8 |
| 237 | ret int get tfails 0 |
| 238 | end |