Skip to content

Instantly share code, notes, and snippets.

@PM2Ring
Created June 6, 2017 16:55
Show Gist options
  • Save PM2Ring/7d2fa240679f02235aab72b1f642e898 to your computer and use it in GitHub Desktop.
Save PM2Ring/7d2fa240679f02235aab72b1f642e898 to your computer and use it in GitHub Desktop.
Hackerrank digit substring puzzle
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