tasks a-s

This commit is contained in:
Ingy döt Net 2013-04-10 23:57:08 -07:00
parent 47bf37c096
commit b83f433714
12433 changed files with 156208 additions and 123 deletions

View file

@ -0,0 +1,35 @@
class Rot13
{
static Str rot13 (Str input)
{
Str result := ""
input.each |Int c|
{
if ((c.lower >= 'a') && (c.lower <= 'm'))
result += (c+13).toChar
else if ((c.lower >= 'n') && (c.lower <= 'z'))
result += (c-13).toChar
else
result += c.toChar
}
return result
}
public static Void main (Str[] args)
{
if (args.size == 1)
{ // process each line of given file
Str filename := args[0]
File(filename.toUri).eachLine |Str line|
{
echo (rot13(line))
}
}
else
{
echo ("Test:")
Str text := "abcstuABCSTU123!+-"
echo ("Text $text becomes ${rot13(text)}")
}
}
}