Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
35
Task/Rot-13/Fantom/rot-13.fantom
Normal file
35
Task/Rot-13/Fantom/rot-13.fantom
Normal 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)}")
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue