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. |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
Mini-challenge: digits by half - David Hayden - 03-28-2022, 05:46 PM
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
RE: Mini-challenge: digits by half - Albert Chan - 03-28-2022, 10:48 PM
RE: Mini-challenge: digits by half - David Hayden - 03-29-2022, 12:42 PM
RE: Mini-challenge: digits by half - Albert Chan - 03-29-2022, 01:47 PM
RE: Mini-challenge: digits by half - David Hayden - 03-29-2022, 04:31 PM
RE: Mini-challenge: digits by half - Albert Chan - 03-29-2022, 04:52 PM
RE: Mini-challenge: digits by half - David Hayden - 03-29-2022, 08:21 PM
RE: Mini-challenge: digits by half - DavidM - 03-30-2022, 11:32 AM
RE: Mini-challenge: digits by half - Albert Chan - 03-30-2022, 04:25 PM
RE: Mini-challenge: digits by half - DavidM - 03-31-2022, 11:07 AM
|
User(s) browsing this thread: 2 Guest(s)