Richard took glass, metal and plastic items to the recycling plant and received 1 "green point" for every 4 items in each category that he brought in. In any category, items in excess of a multiple of four were not counted, so, for example, if he brought in 21 glass items, 30 metal items and 43 plastic items, he'd earn [21/4] + [30/4] + [43/4] = 5 + 7 + 10 = 22 green points. (The [] square brackets indicate the floor function--the greatest integer not exceeding the value within.)
One week he brought in a 2-digit number of glass items, a larger 2-digit number of metal items and a still larger 2-digit number of plastic items. For each class of item he received a 1-digit number of green points.
Among the three 2-digit numbers and three 1-digit numbers involved, all the non-zero digits, 1 through 9, appeared exactly once.
If I told you the total number of items brought, you'd be able to deduce how many were glass, how many were metal and how many were plastic.
How many of each category were there?
I used the following code
CLS 0
FOR n1d1 = 1 TO 9
FOR n1d2 = 1 TO 9
IF n1d2 <> n1d1 THEN
glass = 10 * n1d1 + n1d2
gp1 = INT(glass / 4)
IF gp1 < 10 AND gp1 > 0 AND gp1 <> n1d1 AND gp1 <> n1d2 THEN
FOR n2d1 = 1 TO 9
IF n2d1 <> n1d1 AND n2d1 <> n1d2 AND n2d1 <> gp1 THEN
FOR n2d2 = 1 TO 9
IF n2d2 <> n1d1 AND n2d2 <> n1d2 AND n2d2 <> n2d1 AND n2d2 <> gp1 THEN
metal = 10 * n2d1 + n2d2
gp2 = INT(metal / 4)
IF metal > glass AND gp2 > 0 AND gp2 < 10 AND gp2 <> n1d1 AND gp2 <> n1d2 AND gp2 <> n2d1 AND gp2 <> n2d2 AND gp2 <> gp1 THEN
FOR n3d1 = 1 TO 9
IF n3d1 <> n1d1 AND n3d1 <> n1d2 AND n3d1 <> n2d1 AND n3d1 <> n2d2 AND n3d1 <> gp1 AND n3d1 <> gp2 THEN
FOR n3d2 = 1 TO 9
IF n3d2 <> n1d1 AND n3d2 <> n1d2 AND n3d2 <> n2d1 AND n3d2 <> n2d2 AND n3d2 <> n3d1 AND n3d2 <> gp1 AND n3d2 <> gp2 THEN
plastic = 10 * n3d1 + n3d2
gp3 = INT(plastic / 4)
IF plastic > metal AND gp3 > 0 AND gp3 < 10 AND gp3 <> n1d1 AND gp3 <> n1d2 AND gp3 <> n2d1 AND gp3 <> n2d2 AND gp3 <> n3d1 AND gp3 <> n3d2 AND gp3 <> gp1 AND gp3 <> gp2 THEN
tot = glass + metal + plastic
PRINT glass, metal, plastic, tot
END IF
END IF
NEXT n3d2
END IF
NEXT n3d1
END IF
END IF
NEXT n2d2
END IF
NEXT n2d1
END IF
END IF
NEXT n1d2
NEXT n1d1
and got these four results
glass metal plastic total
16 29 35 80
17 25 38 80
18 25 37 80
19 27 35 81
and of these only 19,27,35 results in a unique total
thus there were 19 glass 27 metal and 35 plastic items for a total of 81
|
Posted by Daniel
on 2009-05-31 13:07:45 |