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

Home > Numbers
Hexing Numbers (Posted on 2004-05-30) Difficulty: 3 of 5
  1
 2 3
4 5 6
 7 8
  9
By moving the numbers around in the diagram, make it so that every number is a factor of the sum of the numbers around it.

See The Solution Submitted by Gamer    
Rating: 4.3333 (3 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution | Comment 1 of 2

DEFINT A-Z
DECLARE SUB permute (a$)
CLS
a$ = "123456789": h$ = a$
DO
  n1 = VAL(MID$(a$, 1, 1))
  n2 = VAL(MID$(a$, 2, 1))
  n3 = VAL(MID$(a$, 3, 1))
  n4 = VAL(MID$(a$, 4, 1))
  n5 = VAL(MID$(a$, 5, 1))
  n6 = VAL(MID$(a$, 6, 1))
  n7 = VAL(MID$(a$, 7, 1))
  n8 = VAL(MID$(a$, 8, 1))
  n9 = VAL(MID$(a$, 9, 1))
  IF (n2 + n3) MOD n1 = 0 THEN
  IF (n1 + n3 + n4 + n5) MOD n2 = 0 THEN
  IF (n2 + n1 + n5 + n6) MOD n3 = 0 THEN
  IF (n2 + n5 + n7) MOD n4 = 0 THEN
  IF (n2 + n3 + n4 + n6 + n7 + n8) MOD n5 = 0 THEN
  IF (n5 + n3 + n8) MOD n6 = 0 THEN
  IF (n4 + n5 + n8 + n9) MOD n7 = 0 THEN
  IF (n5 + n6 + n7 + n9) MOD n8 = 0 THEN
  IF (n7 + n8) MOD n9 = 0 THEN
    PRINT "  "; MID$(a$, 1, 1)
    PRINT " "; MID$(a$, 2, 1); " "; MID$(a$, 3, 1)
    PRINT MID$(a$, 4, 1); " "; MID$(a$, 5, 1); " "; MID$(a$, 6, 1)
    PRINT " "; MID$(a$, 7, 1); " "; MID$(a$, 8, 1)
    PRINT "  "; MID$(a$, 9, 1)
    PRINT
  END IF
  END IF
  END IF
  END IF
  END IF
  END IF
  END IF
  END IF
  END IF
  permute a$
LOOP UNTIL a$ = h$


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

Leads to

  4
 1 7
9 6 3
 2 8
  5
  4
 7 1
3 6 9
 8 2
  5
  5
 2 8
9 6 3
 1 7
  4
  5
 8 2
3 6 9
 7 1
  4

which are all basically the same solution in various reflections/rotation.


  Posted by Charlie on 2004-05-30 11:41:17
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 (9)
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