Post Reply 
Mini-challenge: digits by half
03-28-2022, 11:33 PM
Post: #4
RE: Mini-challenge: digits by half
(03-28-2022 10:34 PM)Allen Wrote:  I'm getting 12 unique pairs (a,b) of numbers that are nearly pandigital (1-9) and 2*a=b.

Ignoring the hint, I get 12 answers too ! Here is by brute force:

>>> from itertools import permutations
>>> for x in permutations(range(2,10)):
...            n = 1000*x[0] + 100*x[1] + 10*x[2] + x[3]
...            d = 1000*(10+x[4]) + 100*x[5] + 10*x[6] + x[7]
...            if n+n==d: print n,'/',d
...
6729 / 13458
6792 / 13584
6927 / 13854
7269 / 14538
7293 / 14586
7329 / 14658
7692 / 15384
7923 / 15846
7932 / 15864
9267 / 18534
9273 / 18546
9327 / 18654

Quote:All of the a's are multiples of 3 and all the b's are multiples of 6.

Yes ! That reduce search cases by a lot !
Because digits are limited from 1 to 9: (num + den) ≡ 0 (mod 9)

num * 2 ≡ den (mod 9)
num * 3 ≡ 0 (mod 9)
num ≡ 0 (mod 3)

Denominator, being even, is divible by 6.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Mini-challenge: digits by half - Allen - 03-28-2022, 10:34 PM
RE: Mini-challenge: digits by half - Albert Chan - 03-28-2022 11:33 PM



User(s) browsing this thread: 2 Guest(s)