Problem of the Day
A new programming or logic puzzle every Mon-Fri

Zero Replaced

Given the numbers 1-10000 inclusive, can you replace all the 0s with a plus sign and calculate the total of all distinct numbers. A distinct number is just one that is separated by a plus sign. For instance 1011 => 1 + 11 = 12. 1010 => 1 + 1 = 2.

Permalink: http://problemotd.com/problem/zero-replaced/

Comments:

  • Akshay Bist - 9 years, 1 month ago

    Python

    for i in xrange(10001):
        st = str(i).replace('0', '+')
        print sum([int(x) for x in st.split('+') if x.isdigit()])
    

    reply permalink

Content curated by @MaxBurstein