image
Physics Forums Logo
image
image
* Register * Upgrade Blogs Library Staff Rules Mark Forums Read
image
image   image
image

Go Back   Physics Forums > PF Lounge > General Discussion > Fun, Photos & Games > Brain Teasers


Reply

image Non duplicate digits and arrangement puzzle Share It Thread Tools Search this Thread image
Old Jun10-09, 03:04 PM                  #1
K Sengupta

K Sengupta is Offline:
Posts: 89
Non duplicate digits and arrangement puzzle

B is a positive 8-digit base ten integer of the form PQRSTUVW that contains precisely 8 distinct digits from 1 to 9, and satisfies all of the following conditions:

(i) PQ is divisible by 2.
(ii) PQR is divisible by 3.
(iii) PQRS is divisible by 4.
(iv) PQRST is divisible by 5.
(v) PQRSTU is divisible by 6.
(vi) PQRSTUV is divisible by 7.
(vii) PQRSTUVW is divisible by 8.

Determine all possible value(s) that B can assume.
  Reply With Quote
Old Jun11-09, 12:00 PM                  #2
davee123

davee123 is Offline:
Posts: 468
Re: Non duplicate digits and arrangement puzzle

Quasi-brute force...

Spoiler
38165472


DaveE
  Reply With Quote
Old Aug8-09, 11:51 AM                  #3
Edgardo

Edgardo is Offline:
Posts: 492
Blog Entries: 3
Re: Non duplicate digits and arrangement puzzle

Spoiler

Using divisibility rules and after 6 pages of handwriting:
PQRSTUVW = 38165472
  Reply With Quote
Old Aug8-09, 12:45 PM       Last edited by mXSCNT; Aug8-09 at 12:55 PM..            #4
mXSCNT

mXSCNT is Offline:
Posts: 261
Re: Non duplicate digits and arrangement puzzle

It was a fun little programming exercise to do it in an efficient way:
Spoiler
12965408
30925864
36925840
38165472
72965480
78320416
78920456
80165472
92765408

my Python:
Code:
def finddigits2():
    def step(prefix,divisible):
        nextprefix = (prefix*10-1)/divisible*divisible
        while nextprefix < (prefix+1)*10-divisible:
            nextprefix += divisible
            if divisible < 8:
                step(nextprefix,divisible+1)
            else:
                if len(set(str(nextprefix))) == 8:
                    print nextprefix
    for f in range(1,10):
        step(f,2)
  Reply With Quote
Old Aug8-09, 04:09 PM                  #5
Edgardo

Edgardo is Offline:
Posts: 492
Blog Entries: 3
Re: Non duplicate digits and arrangement puzzle

Hey mXSCNT,

your program looks compact. Can you explain it a little bit especially how you dealt with the digits being distinct?
  Reply With Quote
Old Aug8-09, 04:54 PM                  #6
mXSCNT

mXSCNT is Offline:
Posts: 261
Re: Non duplicate digits and arrangement puzzle

I dealt with that in this line:
if len(set(str(nextprefix))) == 8:

str(nextprefix) writes the prefix as a string, such as 12965408 becomes "12965408". set(str(nextprefix)) turns the individual characters in the string into a set (ignoring duplicates) so in this case that would be set(['1','2','9','6','5','4','0','8']). len(set(str(nextprefix))) == 8 checks that the "length" of the set (the number of elements in the set) is 8.
  Reply With Quote
image image
Reply
Thread Tools


Similar Threads for: Non duplicate digits and arrangement puzzle
Thread Thread Starter Forum Replies Last Post
Decimal integers with nonzero digits and sum of powers puzzle K Sengupta Brain Teasers 7 Feb23-09 12:11 PM
Ten Digits And Operator Puzzle K Sengupta Brain Teasers 8 Aug2-08 05:11 PM
Arrangement problem coldcell Calculus & Beyond 3 Jun16-06 08:10 AM
Helmholtz arrangement Brainy_Mike Introductory Physics 2 Jan19-05 04:59 PM
Arrangement of voltmeter samuelwsc Introductory Physics 2 Dec20-04 10:53 AM

Powered by vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd. © 2009 Physics Forums
Sciam | physorgPhysorg.com Science News Partner
image
image   image