26 lines
444 B
Plaintext
26 lines
444 B
Plaintext
import io.{lines, stdin}
|
|
|
|
def rot13( s ) =
|
|
buf = StringBuilder()
|
|
|
|
for c <- s
|
|
if isalpha( c )
|
|
n = ((ord(c) and 0x1F) - 1 + 13)%26 + 1
|
|
|
|
buf.append( chr(n or (if isupper(c) then 64 else 96)) )
|
|
else
|
|
buf.append( c )
|
|
|
|
buf.toString()
|
|
|
|
def rot13lines( ls ) =
|
|
for l <- ls
|
|
println( rot13(l) )
|
|
|
|
if _name_ == '-main-'
|
|
if args.isEmpty()
|
|
rot13lines( stdin() )
|
|
else
|
|
for f <- args
|
|
rot13lines( lines(f) )
|