Skip to main content
8 of 9
added 71 byte version
micsthepick
  • 411
  • 4
  • 14

Python 2, 83 ,78 71 bytes

shortest version:

lambda x:sum(map(len,map(str,(range(x+1)if x>0 else range(0,x-1,-1)))))

this version saved 5 bytes, thanks to @numbermaniac :

x=input()
print len(''.join(map(str,(range(x+1)if x>0 else range(0,x-1,-1)))))

Try it online!

this one I came up with on my own after that (same amount of bytes):

x=input()
print sum(map(len,map(str,(range(x+1)if x>0 else range(0,x-1,-1)))))

Try it online!

micsthepick
  • 411
  • 4
  • 14