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

 Hexing Numbers (Posted on 2004-05-30)
```  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.)
 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

`  4 1 79 6 3 2 8  5`
`  4 7 13 6 9 8 2  5`
`  5 2 89 6 3 1 7  4`
`  5 8 23 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

 Search: Search body:
Forums (0)