Skip to content

Instantly share code, notes, and snippets.

@wagle
Created December 1, 2017 02:53
Show Gist options
  • Save wagle/58a512790c5e6dd6b9cf8924b0b9fb94 to your computer and use it in GitHub Desktop.
Save wagle/58a512790c5e6dd6b9cf8924b0b9fb94 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"strings"
)
func main() {
rot13 := func(r rune) rune {
switch {
case r >= 'A' && r <= 'Z':
return 'A' + (r-'A'+13)%26
case r >= 'a' && r <= 'z':
return 'a' + (r-'a'+13)%26
}
return r
}
fmt.Println(strings.Map(rot13, "'Twas brillig and the slithy gopher..."))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment