+--+
| |
+--+
/ \
/ \
/ \
/ \
/ \
/ \
/ \
/ \
+--+ +--+
| | | |
+--+ +--+
/|\ /|
/ | \ / |
/ | \ / |
/ | \ / |
/ | \ / |
/ | \ / |
/ | \ / |
/ | \ / |
+--+ +--+ +--+ +--+
| | | | | | | |
+--+ +--+ +--+ +--+
Using the digits from 1 to 9 exactly once, construct 7 positive integers so that each positive integer is equal to the sum of the positive integers in the squares that are connected to it from below. Some of these seven positive integers can contain
more than one digit.
DEFDBL A-Z
CLS
FOR a = 1 TO 9
FOR b = 1 TO 9
IF b <> a THEN
FOR c = 1 TO 9
IF c <> a AND c <> b THEN
FOR d = 1 TO 9
IF d <> a AND d <> b AND d <> c THEN
e = a + b + c
f = c + d
g = e + f
concat$ = LTRIM$(STR$(a)) + LTRIM$(STR$(b)) + LTRIM$(STR$(c)) + LTRIM$(STR$(d)) + LTRIM$(STR$(e)) + LTRIM$(STR$(f)) + LTRIM$(STR$(g))
good = 1
FOR i = 1 TO LEN(concat$) - 1
IF INSTR(MID$(concat$, i + 1), MID$(concat$, i, 1)) > 0 THEN good = 0
NEXT
IF LEN(concat$) <> 9 THEN good = 0
IF good THEN
PRINT g
PRINT e; f
PRINT a; b; c; d
PRINT
END IF
END IF
NEXT
END IF 'c<>a or b
NEXT
END IF ' b<>a
NEXT
NEXT
finds these solutions
25
18 7
6 9 3 4
25
18 7
9 6 3 4
as, of course, the two bottom-left figures are interchangeable.
Only single-digit numbers needed to be tested on the bottom row, as 2-digit numbers would propagate upward to make 2-digit numbers on all three levels while only two 2-digit numbers can be accommodated while using only nine digits in total.
|
Posted by Charlie
on 2013-09-13 12:24:44 |