All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Numbers
Repeating Digits (Posted on 2024-05-28) Difficulty: 3 of 5
Alex has before him some positive whole numbers, each consisting of a single digit, which may be repeated. The digit is different for each number, and the number of times it is repeated is also different for each number.

The sum of Alex's numbers is a number in which each digit is larger than the digit on its left, and it is the largest number for which this is possible, given the constraints described above.

What is the sum of Alex's numbers?

Note: Adapted from Enigma number:1765 which appeared on "New Scientist" in 2013.

See The Solution Submitted by K Sengupta    
Rating: 5.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution Computer Solution | Comment 1 of 2
689 = 1 + 22 + 666 meets all the requirements.

-----------------
def isStrictIncr(n, strict = True):
    """ input integer and determine if digits are strictly increasing
    set second parameter to False to remove the strict restriction"""
    n=int(n)
    l = list(str(n))
    for i,c in enumerate(l):
        if i == 0:
            x = c
        else:
            if strict:
                if c <= x:
                    return False
                else:
                    x = c
            else:
                if c < x:
                    return False
                else:
                    x = c
    return True

sols = {}
for a in range(1,10):
    for x in [int(str(a)*p) for p in range(1,10)]:
        for b in range(a+1,10):
            for y in [int(str(b)*q) for q in range(1,10)]:
                if len(str(y)) == len(str(x)):
                    continue
                for c in range(b+1,10):
                    for z in [int(str(c)*r) for r in range(1,10)]:
                        if len(str(z)) == len(str(x)):
                            continue
                        if len(str(z)) == len(str(y)):
                            continue
                        mysum = x+y+z
                        if not isStrictIncr(mysum):
                            continue
                        if mysum not in sols:
                            sols[mysum] = [[x,y,z]]
                        else:
                            sols[mysum].append([x,y,z])

ordered_sols  = sorted(list(sols.keys()))[::-1]
print(sols[ordered_sols[0]])

  Posted by Larry on 2024-05-28 17:55:33
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (3)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information