Created
November 26, 2020 20:48
-
-
Save seanhuggins1/775fd21d51f93b9c88bc3f18d3bb9f55 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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