interplane.Get Omega
Read in your language

omega-rosetta

aien-dev/omega-rosetta

Brought by drakestapleton

branch main Branches Tags History

omega-rosetta / drafts / rosettacode / abc-problem.wiki

92 lines · 1617 bytes Raw Blame History
1=={{header|Omegese}}==
2{{works with|omc|sha256 2c824805, aien-dev/omega-mv e5b32567, Linux AArch64}}
3Omega has no imports, so the small output helpers (<code>emit</code> and friends) are part of the program.
4<syntaxhighlight lang="text">
5om2
6text nl "\n"
7text sp " "
8text tyes "yes"
9text tno "no"
10note the 20 blocks, two letters each, separated by spaces
11text blocks "BO XK DQ CP NA GT RE TG QD FS JW HU VI AN OB ER FS LY PC ZM"
12text w0 "A"
13text w1 "BARK"
14text w2 "BOOK"
15text w3 "TREAT"
16text w4 "COMMON"
17text w5 "SQUAD"
18text w6 "CONFUSE"
19global used uchar 20
20note emit writes every byte of a to stdout; a short write is retried, an error exits 1
21fn emit a view uchar * to void
22o = ulong 0
23while lt o len a bound 4096
24k = write 1 a o sub len a o
25if le k 0
26exit 1
27end
28o = add o ulong k
29end
30end
31fn emitb b bool to void
32if b
33emit tyes
34else
35emit tno
36end
37end
38note onblock: block b carries letter c
39fn onblock b ulong c uchar to bool
40x = mul b 3
41ret or eq get blocks x c eq get blocks add x 1 c
42end
43note can: letters i.. of w can be spelled with the unused blocks (depth-first, a block is taken
44note back when the rest fails)
45fn can w view uchar * i ulong to bool
46if eq i len w
47ret true
48end
49c = get w i
50for b ulong 20
51if eq get used b 0
52if onblock b c
53put used b 1
54if can w add i 1
55ret true
56end
57put used b 0
58end
59end
60end
61ret false
62end
63fn show w view uchar * to void
64for b ulong 20
65put used b 0
66end
67emit w
68emit sp
69emitb can w 0
70emit nl
71end
72fn main to int
73show w0
74show w1
75show w2
76show w3
77show w4
78show w5
79show w6
80ret 0
81end
82</syntaxhighlight>
83{{out}}
84<pre>
85A yes
86BARK yes
87BOOK no
88TREAT yes
89COMMON no
90SQUAD yes
91CONFUSE yes
92</pre>