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/tasks/abc-problem/abc-problem.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 / tasks / abc-problem / abc-problem.om` 79 lines ยท 1414 bytes Raw Blame History 1 note Rosetta Code task "ABC problem": https://rosettacode.org/wiki/ABC_problem 2 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 om2 4 text nl "\n" 5 text sp " " 6 text tyes "yes" 7 text tno "no" 8 note the 20 blocks, two letters each, separated by spaces 9 text blocks "BO XK DQ CP NA GT RE TG QD FS JW HU VI AN OB ER FS LY PC ZM" 10 text w0 "A" 11 text w1 "BARK" 12 text w2 "BOOK" 13 text w3 "TREAT" 14 text w4 "COMMON" 15 text w5 "SQUAD" 16 text w6 "CONFUSE" 17 global used uchar 20 18 note emit writes every byte of a to stdout; a short write is retried, an error exits 1 19 fn emit a view uchar * to void 20 o = ulong 0 21 while lt o len a bound 4096 22 k = write 1 a o sub len a o 23 if le k 0 24 exit 1 25 end 26 o = add o ulong k 27 end 28 end 29 fn emitb b bool to void 30 if b 31 emit tyes 32 else 33 emit tno 34 end 35 end 36 note onblock: block b carries letter c 37 fn onblock b ulong c uchar to bool 38 x = mul b 3 39 ret or eq get blocks x c eq get blocks add x 1 c 40 end 41 note can: letters i.. of w can be spelled with the unused blocks (depth-first, a block is taken 42 note back when the rest fails) 43 fn can w view uchar * i ulong to bool 44 if eq i len w 45 ret true 46 end 47 c = get w i 48 for b ulong 20 49 if eq get used b 0 50 if onblock b c 51 put used b 1 52 if can w add i 1 53 ret true 54 end 55 put used b 0 56 end 57 end 58 end 59 ret false 60 end 61 fn show w view uchar * to void 62 for b ulong 20 63 put used b 0 64 end 65 emit w 66 emit sp 67 emitb can w 0 68 emit nl 69 end 70 fn main to int 71 show w0 72 show w1 73 show w2 74 show w3 75 show w4 76 show w5 77 show w6 78 ret 0 79 end