Each of the letters in bold represents a base ten digit from 0 to 9 to satisfy these alphametic relationships. None of the numbers can contain any leading zero.
USA is a multiple of UK, and:
SA is a multiple of K
Determine the respective minimum and maximum values that
USA can assume.
DEFDBL A-Z
CLS
FOR u = 1 TO 9
used(u) = 1
FOR k = 0 TO 9
IF used(k) = 0 THEN
used(k) = 1
FOR s = 1 TO 9
IF used(s) = 0 THEN
used(s) = 1
FOR a = 0 TO 9
IF used(a) = 0 THEN
used(a) = 1
uk = 10 * u + k
usa = 100 * u + 10 * s + a
sa = 10 * s + a
IF INT(usa / uk) = usa / uk THEN
IF INT(sa / k) = sa / k THEN PRINT usa, uk, sa
END IF
used(a) = 0
END IF
NEXT
used(s) = 0
END IF
NEXT
used(k) = 0
END IF
NEXT
used(u) = 0
NEXT
produces results that I had to sort separately, as I neglected to cycle through the variables in U, S, A order. The sorted output, with heading added is:
USA UK SA
120 15 20
156 12 56
168 12 68
168 14 68
169 13 69
180 12 80
180 15 80
196 14 96
216 24 16
273 21 73
294 21 94
324 36 24
372 31 72
384 32 84
432 48 32
492 41 92
so USA can be as small as 120 and as large as 492.
|
Posted by Charlie
on 2013-01-21 12:12:29 |