Created
September 7, 2012 15:49
-
-
Save gorlum0/3667332 to your computer and use it in GitHub Desktop.
Some convenience funcs for algs4partI-class exercises - easier in numbers for me than in alphabet.
This file contains 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
#algs4partI-class | |
def str2nums(s): | |
return [ord(x)-ord('A') for x in s.split()] | |
def nums2str(l): | |
return ' '.join(chr(x + ord('A')) for x in l) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment