import std/strutils const SAMESUM = int('a') + int('z') func encode(s: string): string = var written = 0 for ind, letter in s.toLowerAscii: if letter.isAlphaNumeric: written += 1 if letter in 'a'..'z': result.add(char(SAMESUM - int(letter))) else: result.add(letter) if written mod 5 == 0 and ind in 0..len(s) - 3: result &= ' ' func decode(s: string): string = encode(s).replace(" ") if isMainModule: echo("DOG".len) echo(encode("The quick brown fox jumps over the lazy dog.") & "WHY - 3??")