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

Home > Numbers
Two to the Three = Three to the Two? (Posted on 2005-03-22) Difficulty: 3 of 5
264   This 2x3 grid has an interesting
200   property: 264x200 = 22x60x40.

Build a similar grid using all digits from 2 to 7.

See The Solution Submitted by Old Original Oskar!    
Rating: 5.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution solution and extension--computer search--spoiler | Comment 1 of 8

The solution is

567
432

If the requirement were only that the digits not be repeated, but not necessarily consecutive, there'd be the following:

273
180

492
160

189
640

648
350

194
276

567
432

The program:

DECLARE SUB permute (a$)
CLS
a$ = "234567": h$ = a$
DO
  tp = VAL(LEFT$(a$, 3))
  bt = VAL(RIGHT$(a$, 3))
  lt = VAL(MID$(a$, 1, 1) + MID$(a$, 4, 1))
  md = VAL(MID$(a$, 2, 1) + MID$(a$, 5, 1))
  rt = VAL(MID$(a$, 3, 1) + MID$(a$, 6, 1))
  IF tp * bt = lt * md * rt THEN PRINT tp: PRINT bt: PRINT
  permute a$
LOOP UNTIL a$ = h$

PRINT

FOR d1 = 0 TO 4
FOR d2 = d1 + 1 TO 5
FOR d3 = d2 + 1 TO 6
FOR d4 = d3 + 1 TO 7
FOR d5 = d4 + 1 TO 8
FOR d6 = d5 + 1 TO 9
  a$ = LTRIM$(STR$(d1)) + LTRIM$(STR$(d2)) + LTRIM$(STR$(d3)) + LTRIM$(STR$(d4)) + LTRIM$(STR$(d5)) + LTRIM$(STR$(d6))
  h$ = a$
  DO
    tp = VAL(LEFT$(a$, 3))
    bt = VAL(RIGHT$(a$, 3))
    lt = VAL(MID$(a$, 1, 1) + MID$(a$, 4, 1))
    md = VAL(MID$(a$, 2, 1) + MID$(a$, 5, 1))
    rt = VAL(MID$(a$, 3, 1) + MID$(a$, 6, 1))
    IF tp * bt = lt * md * rt THEN PRINT tp: PRINT bt: PRINT
    permute a$
  LOOP UNTIL a$ = h$
NEXT
NEXT
NEXT
NEXT
NEXT
NEXT


SUB permute (a$)
DEFINT A-Z
 x$ = ""
 FOR i = LEN(a$) TO 1 STEP -1
  l$ = x$
  x$ = MID$(a$, i, 1)
  IF x$ < l$ THEN EXIT FOR
 NEXT

 IF i = 0 THEN
  FOR j = 1 TO LEN(a$) \ 2
   x$ = MID$(a$, j, 1)
   MID$(a$, j, 1) = MID$(a$, LEN(a$) - j + 1, 1)
   MID$(a$, LEN(a$) - j + 1, 1) = x$
  NEXT
 ELSE
  FOR j = LEN(a$) TO i + 1 STEP -1
   IF MID$(a$, j, 1) > x$ THEN EXIT FOR
  NEXT
  MID$(a$, i, 1) = MID$(a$, j, 1)
  MID$(a$, j, 1) = x$
  FOR j = 1 TO (LEN(a$) - i) \ 2
   x$ = MID$(a$, i + j, 1)
   MID$(a$, i + j, 1) = MID$(a$, LEN(a$) - j + 1, 1)
   MID$(a$, LEN(a$) - j + 1, 1) = x$
  NEXT
 END IF
END SUB

 


  Posted by Charlie on 2005-03-22 14:07:08
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 (2)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2017 by Animus Pactum Consulting. All rights reserved. Privacy Information