Created
March 27, 2017 23:01
-
-
Save oten/bc62cca9f5e5cc524fe05c58ae4dd116 to your computer and use it in GitHub Desktop.
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
def look_and_say(numbers): | |
if len(numbers) == 1: | |
return '1' + numbers | |
say = 1 | |
out = '' | |
numbers += 'X' | |
for curr, _next in zip(numbers, numbers[1:]): | |
if curr == _next: | |
say += 1 | |
else: | |
out += str(say) | |
out += curr | |
say = 1 | |
return out | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment