Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
7
Task/Caesar-cipher/Groovy/caesar-cipher-2.groovy
Normal file
7
Task/Caesar-cipher/Groovy/caesar-cipher-2.groovy
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
def caesarEncode(cipherKey, text) {
|
||||
text.chars.collect { c ->
|
||||
int off = c.isUpperCase() ? 'A' : 'a'
|
||||
c.isLetter() ? (((c as int) - off + cipherKey) % 26 + off) as char : c
|
||||
}.join()
|
||||
}
|
||||
def caesarDecode(cipherKey, text) { caesarEncode(26 - cipherKey, text) }
|
||||
Loading…
Add table
Add a link
Reference in a new issue