Created
June 6, 2017 16:55
-
-
Save PM2Ring/7d2fa240679f02235aab72b1f642e898 to your computer and use it in GitHub Desktop.
Hackerrank digit substring puzzle
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
n = '12345678901234567890' | |
total = units = a = sum(map(int, n)) | |
for k, d in enumerate(n[:-1], 1): | |
units -= int(d) | |
a = (a - int(n[-k:])) * 10 + units | |
total += a | |
print(total) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment