Sha256: 20e2ac8fd54e1e6376034d4757a71db2cee646b2b59930291434aff30a8fbc08

Contents?: true

Size: 509 Bytes

Versions: 1

Compression:

Stored size: 509 Bytes

Contents


def rot13 (value:string)
    result = ""
    d = ' '.toCharArray[0]
    value.toCharArray.each do |c|
        testChar = Character.toLowerCase(c)
        if testChar <= 'm'.toCharArray[0] && testChar >= 'a'.toCharArray[0] then 
            d = char(c + 13)
        end
        if testChar <= 'z'.toCharArray[0] && testChar >= 'n'.toCharArray[0] then 
            d = char(c - 13) 
        end 
        result += d
    end 
    result
end


puts rot13("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mirah-0.0.8-java examples/rosettacode/rot-13.mirah