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-rosetta/blob/main/exercises/saddle-points/.meta/example.om # omega-rosetta aien-dev/omega-rosetta Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-rosetta / exercises / saddle-points / .meta / example.om` 38 lines ยท 1102 bytes Raw Blame History 1 note Exercism-style exercise "saddle-points": https://exercism.org/tracks/python/exercises/saddle-points 2 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 note m is a matrix of nr rows and nc columns, row after row. A saddle point is a value that is the 4 note largest in its row and the smallest in its column. saddlepoints writes the 1-based row and 5 note column of each saddle point into o as pairs, in row-major order, and returns the number of points. 6 note Check it with: sh exercise.sh exercises/saddle-points 7 om2 8 fn isrowmax m view ulong * nc ulong r ulong c ulong to bool 9 v = get m add mul r nc c 10 for j ulong nc 11 if gt get m add mul r nc j v 12 ret false 13 end 14 end 15 ret true 16 end 17 fn iscolmin m view ulong * nr ulong nc ulong r ulong c ulong to bool 18 v = get m add mul r nc c 19 for i ulong nr 20 if lt get m add mul i nc c v 21 ret false 22 end 23 end 24 ret true 25 end 26 fn saddlepoints m view ulong * nr ulong nc ulong o edit ulong * to ulong 27 k = ulong 0 28 for r ulong nr 29 for c ulong nc 30 if and isrowmax m nc r c iscolmin m nr nc r c 31 put o mul k 2 add r 1 32 put o add mul k 2 1 add c 1 33 k = add k 1 34 end 35 end 36 end 37 ret k 38 end