Skip to content

Instantly share code, notes, and snippets.

@oten oten/look_and_say.py
Created Mar 27, 2017

Embed
What would you like to do?
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
You can’t perform that action at this time.