Skip to content

Instantly share code, notes, and snippets.

@oten
Created March 27, 2017 23:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oten/bc62cca9f5e5cc524fe05c58ae4dd116 to your computer and use it in GitHub Desktop.
Save oten/bc62cca9f5e5cc524fe05c58ae4dd116 to your computer and use it in GitHub Desktop.
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