Skip to content

Instantly share code, notes, and snippets.

View shepting's full-sized avatar

Steven Hepting shepting

View GitHub Profile
@shepting
shepting / rot13.swift
Last active August 29, 2015 14:08 — forked from jeremy-w/rot13.swift
// Playground - noun: a place where people can play
import UIKit
let lettersArray = Array("ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")
func rot13(input: String) -> String {
return reduce(input, "", { result, letter in
if let i = find(lettersArray, letter) {
return result + String(lettersArray[i + 13])
@shepting
shepting / rot13.swift
Last active August 29, 2015 14:05 — forked from jeremy-w/rot13.swift
Simple ROT13 function
// Playground - noun: a place where people can play
let lettersArray = Array("ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")
func rot13(input: String) -> String {
return reduce(input, "") { result, letter in
if let i = find(lettersArray, letter) {
return result + lettersArray[i + 13]
} else {
return result + letter