Skip to main content
64 bytes!
Source Link
micsthepick
  • 411
  • 4
  • 14

Python 2, 83 ,78 7164 bytes

shortest version:

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

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!

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!

Python 2, 83 ,78 64 bytes

shortest version:

lambda x:sum(map(len,map(str,(range(0,x+cmp(x,.5),cmp(x,.5))))))

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!

added 71 byte version
Source Link
micsthepick
  • 411
  • 4
  • 14

Python 2, 83 78,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!

Python 2, 83 78 bytes

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!

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!

fixed some arithmetic
Source Link
micsthepick
  • 411
  • 4
  • 14

Python 2, 83 78 bytes

this version saved 105 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!

Python 2, 83 78 bytes

this version saved 10 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!

Python 2, 83 78 bytes

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!

added my own version
Source Link
micsthepick
  • 411
  • 4
  • 14
Loading
78-char version
Source Link
micsthepick
  • 411
  • 4
  • 14
Loading
added 3 characters in body
Source Link
micsthepick
  • 411
  • 4
  • 14
Loading
sum instead of ''.join()
Source Link
micsthepick
  • 411
  • 4
  • 14
Loading
Source Link
micsthepick
  • 411
  • 4
  • 14
Loading