interplane.Get Omega
Read in your language

omega-rosetta

aien-dev/omega-rosetta

Brought by drakestapleton

branch main Branches Tags History

omega-rosetta / exercises / raindrops / .meta / example.om

47 lines · 1019 bytes Raw Blame History
1note Exercism-style exercise "raindrops": https://exercism.org/tracks/python/exercises/raindrops
2note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3note convert writes "Pling" if n is divisible by 3, then "Plang" if by 5, then "Plong" if by 7,
4note or the decimal digits of n when it is divisible by none of them, into o; returns the length.
5note Check it with: sh exercise.sh exercises/raindrops
6om2
7text pling "Pling"
8text plang "Plang"
9text plong "Plong"
10fn app o edit uchar * p ulong s view uchar * to ulong
11q = p
12for i ulong len s
13put o q get s i
14q = add q 1
15end
16ret q
17end
18fn appnum o edit uchar * p ulong n ulong to ulong
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
30ret app o p part d i sub 20 i
31end
32fn convert n ulong o edit uchar * to ulong
33p = ulong 0
34if eq rem n 3 0
35p = app o p pling
36end
37if eq rem n 5 0
38p = app o p plang
39end
40if eq rem n 7 0
41p = app o p plong
42end
43if eq p 0
44p = appnum o p n
45end
46ret p
47end