Skip to content

Instantly share code, notes, and snippets.

@kardolus
Created October 11, 2020 13:59
Show Gist options
  • Save kardolus/b6f541dcbea74244a4ab882fc3631e78 to your computer and use it in GitHub Desktop.
Save kardolus/b6f541dcbea74244a4ab882fc3631e78 to your computer and use it in GitHub Desktop.
Sometimes you need to convert runes to an index in an []int with size 26. And you need to convert back.
func rune2Index(r rune) int {
return int(r) - int('a')
}
func index2Rune(i int) rune {
return rune(i) + 'a'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment