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

Home > Numbers
Singular Squares II (Posted on 2022-08-06) Difficulty: 3 of 5
A duodecimal perfect square N has strictly ascending digits from left to right.
Determine the maximum value of N.

How about the maximum value of N when it has strictly descending duodecimal digits from left to right.

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 Solution | Comment 1 of 3
Answers for increasing and decreasing:
Base 12:  2369  and  B7621
Base 10:  3969  and  241081

Program output (with some manual formatting clean up):
Increasing
decimal square base12
63 3969 2369
15 225 169
9 81 69
4 16 14
3 9 9
2 4 4
1 1 1

Decreasing
decimal square base12
491 241081 B7621
136 18496 A854
114 12996 7630
41 1681 B81
37 1369 961
35 1225 861
30 900 630
11 121 A1
10 100 84
8 64 54
7 49 41
6 36 30
5 25 21
3 9 9
2 4 4
1 1 1

-----------------------
def isIncrAlpha(a, strict = True):
    """ input string such as a number in a base higher than 10.  Determine if 
    characters are strictly increasing. 
    Set second parameter to False to remove the strict restriction"""
    a = str(a)
    a = a.upper()
    l = [ord(i) for i in a]
    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

def isDecrAlpha(a, strict = True):
    """ input string such as a number in a base higher than 10.  Determine if 
    characters are strictly decreasing. 
    Set second parameter to False to remove the strict restriction"""
    a = str(a)
    a = a.upper()
    l = [ord(i) for i in a]
    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


decimalMaxIncr12 = int(base2base('123456789AB',12,10)**.5)
decimalMaxDecr12 = int(base2base('BA9876543210',12,10)**.5)

print('Increasing')
print('decimal', 'square', 'base12')
for n in range(decimalMaxIncr12,0,-1):
    x = base2base(n*n,10,12)
    if isIncrAlpha(x):
        print(n, '\t', n**2,'\t', x)

print('')
print('Decreasing')
print('decimal', 'square', 'base12')

for n in range(decimalMaxDecr12,0,-1):
    x = base2base(n*n,10,12)
    if isDecrAlpha(x):
        print(n, '\t', n**2, '\t', x)

  Posted by Larry on 2022-08-06 09:28:07
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