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

Home > Numbers
The class of ‘55’ (Posted on 2021-02-27) Difficulty: 3 of 5
How many numbers comply with the two conditions:
1. It is a permutation of 5 consecutive digits.
2. It is divisible by 55.

See The Solution Submitted by Ady TZIDON    
Rating: 5.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution Python sol'n with or without wrap-around Comment 4 of 4 |
----- Python code description -----
Initial lists are integers with the desired group of digits sorted in decreasing order to avoid having to deal with leading zeros.
The program checks every 5 digit number which is divisible by 55,
The integer "i" is converted to integer "j" with the digits rearranged in decreasing order using string functions.
Then check to see if "j" is in one of the lists.

-----  code -----
listNoWrap = [43210,54321,65432,76543,87654,98765]
listWrap = [98760,98710,98210,93210]
count = 0
for i in range(10010,100000,55):
    s = str(i)
    srt = sorted(list(s)) 
    srt.reverse()
    compress = ''
    for a in srt:
        compress = compress + a
    j = int(compress)
    if j not in (listNoWrap):
#    if j not in (listWrap):
        continue
    print (i)
    count += 1
print(count)

--- the 20 valid solutions (no wrapping around) and the 16 extra solutions if wrapping around allowed.

12430
13420
21340
24310
24365
26345
31240
34210
34265
36245
42130
43120
47685
48675
63745
64735
67485
68475
73645
74635
20   listNoWrap

12980
18920
21890
29810
67980
68970
76890
79860
81290
86790
89210
89760
92180
97680
98120
98670
16   listWrap

  Posted by Larry on 2021-02-27 17:01:19
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 (15)
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