interplane.Get Omega
Read in your language

omega-rosetta

aien-dev/omega-rosetta

Brought by drakestapleton

branch main Branches Tags History

omega-rosetta / exercises / rotational-cipher / .meta / example.om

21 lines · 682 bytes Raw Blame History
1note Exercism-style exercise "rotational-cipher": https://exercism.org/tracks/python/exercises/rotational-cipher
2note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3note rotate writes s into o with every letter shifted key places along the alphabet (keeping its
4note case, wrapping z to a) and every other byte unchanged; returns the length.
5note Check it with: sh exercise.sh exercises/rotational-cipher
6om2
7fn rotate s view uchar * key ulong o edit uchar * to ulong
8k = uchar rem key 26
9for i ulong len s
10c = get s i
11if and ge c 65 le c 90
12c = add 65 rem add sub c 65 k 26
13else
14if and ge c 97 le c 122
15c = add 97 rem add sub c 97 k 26
16end
17end
18put o i c
19end
20ret len s
21end