interplane.Get Omega
Read in your language

omega-rosetta

aien-dev/omega-rosetta

Brought by drakestapleton

branch main Branches Tags History

omega-rosetta / exercises / saddle-points / test.om

238 lines · 4687 bytes Raw Blame History
1note ---- test harness (appended after the solution by exercise.sh) ----
2text tok "ok "
3text tnok "not ok "
4text tsep " - "
5text tnl "\n"
6global tfails ulong 1
7global tnum ulong 1
8fn temit a view uchar * to void
9o = ulong 0
10while lt o len a bound 4096
11k = write 1 a o sub len a o
12if le k 0
13exit 2
14end
15o = add o ulong k
16end
17end
18fn temitu n ulong to void
19d = new uchar 20 0
20i = ulong 20
21v = n
22while true bound 20
23i = sub i 1
24put d i uchar add rem v 10 48
25v = div v 10
26if eq v 0
27break
28end
29end
30temit part d i sub 20 i
31end
32note one TAP-style line per case; main returns the number of failed cases
33fn tcheck c bool what view uchar * to void
34put tnum 0 add get tnum 0 1
35if c
36temit tok
37else
38temit tnok
39put tfails 0 add get tfails 0 1
40end
41temitu get tnum 0
42temit tsep
43temit what
44temit tnl
45end
46note cases: exercism/problem-specifications exercises/saddle-points/canonical-data.json at
47note commit 650bebeb39ad40439175288042aece982b0a90a9 (2026-10-19), MIT licence,
48note https://github.com/exercism/problem-specifications
49note 9 cases kept, 0 skipped
50fn tueq a view ulong * b view ulong * to bool
51if ne len a len b
52ret false
53end
54for i ulong len a
55if ne get a i get b i
56ret false
57end
58end
59ret true
60end
61text c0 "saddlePoints: Can identify single saddle point"
62text c1 "saddlePoints: Can identify that empty matrix has no saddle points"
63text c2 "saddlePoints: Can identify lack of saddle points when there are none"
64text c3 "saddlePoints: Can identify multiple saddle points in a column"
65text c4 "saddlePoints: Can identify multiple saddle points in a row"
66text c5 "saddlePoints: Can identify saddle point in bottom right corner"
67text c6 "saddlePoints: Can identify saddle points in a non square matrix"
68text c7 "saddlePoints: Can identify that saddle points in a single column matrix are those with the minimum value"
69text c8 "saddlePoints: Can identify that saddle points in a single row matrix are those with the maximum value"
70note canonical case 3e374e63-a2e0-4530-a39a-d53c560382bd
71fn tc0 to bool
72a0 = new ulong 9 0
73put a0 0 9
74put a0 1 8
75put a0 2 7
76put a0 3 5
77put a0 4 3
78put a0 5 2
79put a0 6 6
80put a0 7 6
81put a0 8 7
82o = new ulong 256 0
83n = saddlepoints a0 3 3 o
84a1 = new ulong 2 0
85put a1 0 2
86put a1 1 1
87ret tueq part o 0 mul n 2 a1
88end
89note canonical case 6b501e2b-6c1f-491f-b1bb-7f278f760534
90fn tc1 to bool
91a0 = new ulong 1 0
92o = new ulong 256 0
93n = saddlepoints part a0 0 0 1 0 o
94ret eq mul n 2 0
95end
96note canonical case 8c27cc64-e573-4fcb-a099-f0ae863fb02f
97fn tc2 to bool
98a0 = new ulong 9 0
99put a0 0 1
100put a0 1 2
101put a0 2 3
102put a0 3 3
103put a0 4 1
104put a0 5 2
105put a0 6 2
106put a0 7 3
107put a0 8 1
108o = new ulong 256 0
109n = saddlepoints a0 3 3 o
110ret eq mul n 2 0
111end
112note canonical case 6d1399bd-e105-40fd-a2c9-c6609507d7a3
113fn tc3 to bool
114a0 = new ulong 9 0
115put a0 0 4
116put a0 1 5
117put a0 2 4
118put a0 3 3
119put a0 4 5
120put a0 5 5
121put a0 6 1
122put a0 7 5
123put a0 8 4
124o = new ulong 256 0
125n = saddlepoints a0 3 3 o
126a1 = new ulong 6 0
127put a1 0 1
128put a1 1 2
129put a1 2 2
130put a1 3 2
131put a1 4 3
132put a1 5 2
133ret tueq part o 0 mul n 2 a1
134end
135note canonical case 3e81dce9-53b3-44e6-bf26-e328885fd5d1
136fn tc4 to bool
137a0 = new ulong 9 0
138put a0 0 6
139put a0 1 7
140put a0 2 8
141put a0 3 5
142put a0 4 5
143put a0 5 5
144put a0 6 7
145put a0 7 5
146put a0 8 6
147o = new ulong 256 0
148n = saddlepoints a0 3 3 o
149a1 = new ulong 6 0
150put a1 0 2
151put a1 1 1
152put a1 2 2
153put a1 3 2
154put a1 4 2
155put a1 5 3
156ret tueq part o 0 mul n 2 a1
157end
158note canonical case 88868621-b6f4-4837-bb8b-3fad8b25d46b
159fn tc5 to bool
160a0 = new ulong 9 0
161put a0 0 8
162put a0 1 7
163put a0 2 9
164put a0 3 6
165put a0 4 7
166put a0 5 6
167put a0 6 3
168put a0 7 2
169put a0 8 5
170o = new ulong 256 0
171n = saddlepoints a0 3 3 o
172a1 = new ulong 2 0
173put a1 0 3
174put a1 1 3
175ret tueq part o 0 mul n 2 a1
176end
177note canonical case 5b9499ca-fcea-4195-830a-9c4584a0ee79
178fn tc6 to bool
179a0 = new ulong 6 0
180put a0 0 3
181put a0 1 1
182put a0 2 3
183put a0 3 3
184put a0 4 2
185put a0 5 4
186o = new ulong 256 0
187n = saddlepoints a0 2 3 o
188a1 = new ulong 4 0
189put a1 0 1
190put a1 1 1
191put a1 2 1
192put a1 3 3
193ret tueq part o 0 mul n 2 a1
194end
195note canonical case ee99ccd2-a1f1-4283-ad39-f8c70f0cf594
196fn tc7 to bool
197a0 = new ulong 4 0
198put a0 0 2
199put a0 1 1
200put a0 2 4
201put a0 3 1
202o = new ulong 256 0
203n = saddlepoints a0 4 1 o
204a1 = new ulong 4 0
205put a1 0 2
206put a1 1 1
207put a1 2 4
208put a1 3 1
209ret tueq part o 0 mul n 2 a1
210end
211note canonical case 63abf709-a84b-407f-a1b3-456638689713
212fn tc8 to bool
213a0 = new ulong 4 0
214put a0 0 2
215put a0 1 5
216put a0 2 3
217put a0 3 5
218o = new ulong 256 0
219n = saddlepoints a0 1 4 o
220a1 = new ulong 4 0
221put a1 0 1
222put a1 1 2
223put a1 2 1
224put a1 3 4
225ret tueq part o 0 mul n 2 a1
226end
227fn main to int
228tcheck tc0 c0
229tcheck tc1 c1
230tcheck tc2 c2
231tcheck tc3 c3
232tcheck tc4 c4
233tcheck tc5 c5
234tcheck tc6 c6
235tcheck tc7 c7
236tcheck tc8 c8
237ret int get tfails 0
238end