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-mv/blob/main/si/rosetta/exercises/atbash-cipher/.meta/example.om # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / si / rosetta / exercises / atbash-cipher / .meta / example.om` 55 lines ยท 1125 bytes Raw Blame History 1 note Exercism-style exercise "atbash-cipher": https://exercism.org/tracks/python/exercises/atbash-cipher 2 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 note encode writes the Atbash cipher of s into o (a to z, b to y, ...; letters lower case, digits 4 note kept, everything else dropped) in groups of 5 separated by one space; decode writes the plain 5 note text of s (spaces dropped). Both return the number of bytes written. 6 note Check it with: sh exercise.sh exercises/atbash-cipher 7 om2 8 fn encode s view uchar * o edit uchar * to ulong 9 p = ulong 0 10 k = ulong 0 11 for i ulong len s 12 c = get s i 13 if and ge c 65 le c 90 14 c = add c 32 15 end 16 keep = false 17 if and ge c 97 le c 122 18 c = sub 219 c 19 keep = true 20 else 21 if and ge c 48 le c 57 22 keep = true 23 end 24 end 25 if keep 26 if and gt k 0 eq rem k 5 0 27 put o p 32 28 p = add p 1 29 end 30 put o p c 31 p = add p 1 32 k = add k 1 33 end 34 end 35 ret p 36 end 37 fn decode s view uchar * o edit uchar * to ulong 38 p = ulong 0 39 for i ulong len s 40 c = get s i 41 if and ge c 65 le c 90 42 c = add c 32 43 end 44 if and ge c 97 le c 122 45 put o p sub 219 c 46 p = add p 1 47 else 48 if and ge c 48 le c 57 49 put o p c 50 p = add p 1 51 end 52 end 53 end 54 ret p 55 end