Created
July 5, 2014 02:07
-
-
Save dyjjones/73b4c967a12475fd4382 to your computer and use it in GitHub Desktop.
unPythonic reverse
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
reverse = lambda s: ''.join([c for i,c in sorted(zip(range(len(s)), s), key=lambda c: -c[0])]) | |
reverse('burrito') # otirrub | |
# Or do it in a single line! | |
(lambda s: ''.join([c for i,c in sorted(zip(range(len(s)), s), key=lambda c: -c[0])]))('burrito') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment