Skip to content

Instantly share code, notes, and snippets.

@seanhuggins1
Created November 26, 2020 20:48
Show Gist options
  • Select an option

  • Save seanhuggins1/775fd21d51f93b9c88bc3f18d3bb9f55 to your computer and use it in GitHub Desktop.

Select an option

Save seanhuggins1/775fd21d51f93b9c88bc3f18d3bb9f55 to your computer and use it in GitHub Desktop.
def lookAndSay(N):
s = '1'
for k in range(N):
print(s)
i = 0
count = 0
prev = s[0]
snew = ''
for i in range(len(s)):
if (s[i] != prev):
snew += str(count) + str(prev)
count = 0
count += 1
prev = s[i]
snew += str(count) + str(prev)
s = snew
lookAndSay(8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment