A small company with three bricklayers is hired to build a barbecue. Each worker can lay a certain integer number of bricks per minute. The company could assign any combination of 1, 2 or all 3 workers to the job, and each combination would complete the barbecue in a different integer number of minutes.
What is the minimum number of bricks in the barbecue?
We can assume no bricklayer can lay more than 200 bricks per minute. Also assume all workers take up the full time and none finishes even a minute or fraction of a minute before any other.
DECLARE FUNCTION gcd# (a#, b#)
DECLARE FUNCTION lcm# (a#, b#)
min = 9999999
FOR a = 1 TO 198
FOR b = a + 1 TO 199
FOR c = b + 1 TO 200
ab = a + b: ac = a + c: bc = b + c
abc = a + b + c
sz = lcm(a, lcm(b, lcm(c, lcm(ab, lcm(ac, lcm(bc, abc))))))
IF sz / a <> sz / bc AND sz / b <> sz / ac AND sz / c <> sz / ab THEN
IF sz <= min THEN
min = sz: mina = a: minb = b: minc = c
PRINT a; b; c, sz
FUNCTION gcd (a, b)
x = a: y = b
q = INT(x / y): r = x - y * q
IF r = 0 THEN gcd = y: EXIT FUNCTION
x = y: y = r
FUNCTION lcm (a, b)
lcm = a * b / gcd(a, b)
1 2 4 420
1 3 5 360
So 360 is the smallest number of bricks.
Edited on June 21, 2013, 1:01 pm
Posted by Charlie
on 2013-06-21 12:59:55