Created
October 11, 2020 13:59
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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