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

Home > Numbers
For I Was (Posted on 2024-05-16) Difficulty: 3 of 5
Solve:
FOR = I x WAS
where W, A, and S represent consecutive digits.

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 Two programs Comment 1 of 1
If it is required that W < A < S then there is a unique solution:
690 = 2 x 345

But if W,A,S can be in any order then there are 4 more solutions:
708 = 2 x 354
870 = 2 x 435
906 = 2 x 453
930 = 2 x 465

-----
triplets = [[i,i+1,i+2] for i in range(8)]

print('First Program') 
from itertools import permutations
for t in triplets:
    for perm in permutations(t):
        WAS = 100*perm[0] + 10*perm[1] + perm[2]
        for I in range(2,10):
            if I in t:
                continue
            FOR = I * WAS
            if FOR > 999:
                continue
            letters = str(FOR) + str(I) + str(WAS)
            if len(letters) < 7:
                continue
            if len(letters) != len(set(letters)):
                continue
            print('{} = {} x {}'.format(FOR, I, WAS))
            
            
print('\n','Second Program')            
for F in range(1,10):
    for O in range(10):
        if O in [F]:
            continue
        for R in range(10):
            if R in [F,O]:
                continue
            for I in range(1,10):
                if I in [F,O,R]:
                    continue
                for W in range(1,10):
                    if W in [F,O,R,I]:
                        continue
                    for A in range(10):
                        if A in [F,O,R,I,W]:
                            continue
                        for S in range(10):
                            if S in [F,O,R,I,W,A]:
                                continue
                            if sorted([W,A,S]) not in triplets:
                                continue
                            FOR = 100*F + 10*O + R
                            WAS = 100*W + 10*A + S
                            if FOR == I * WAS:
                                print('{} = {} x {}'.format(FOR, I, WAS))

----  Output
First Program
690 = 2 x 345
708 = 2 x 354
870 = 2 x 435
906 = 2 x 453
930 = 2 x 465

 Second Program
690 = 2 x 345
708 = 2 x 354
870 = 2 x 435
906 = 2 x 453
930 = 2 x 465

  Posted by Larry on 2024-05-16 11:22:13
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