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

 Alexei And Boris (Posted on 2006-03-28)
Alexei and Boris both have a whole number of chocolates, lollipops and toffees, and the product of the number of each boy's of chocolates, lollipops and toffees is 336. It is known that:

(A) Each boy has fewer chocolates than lollipops.

(B) For each boy, the product of the number of chocolates and lollipops equals the total number of candies he has.

(C) Alexei has more lollipops than toffees.

Determine the number of chocolates, lollipops and toffees possessed by each of Alexei and Boris.

 See The Solution Submitted by K Sengupta Rating: 3.0000 (5 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
 Computer solution | Comment 9 of 11 |

Here's a VB.Net program to solve:

Module Module1
Sub main()
Dim chocolates, lollipops, toffees As Integer
Dim factor() As Integer = {1, 2, 3, 4, 6, 8, 12, 14, 16, 21, 24, 28, 42, 56, 84, 112, 168, 336}
For i As Integer = 0 To 16
chocolates = factor(i)
For j As Integer = i + 1 To 17
lollipops = factor(j)
toffees = CInt(336 / chocolates / lollipops)
If chocolates * lollipops = chocolates + lollipops + toffees Then
Console.WriteLine(chocolates & " " & lollipops & " " & toffees)
End If
Next
Next
End Sub
End Module

The program uses the list of all possible factors of 336 (18 of them, in the array called factor), and chooses all combinations of any 2 of them for the number of chocolates and lollipops, with the restriction that the number of chocolates must be less than the number of lollipops.  The number of toffees is then calculated by dividing 336 by (chocolates * lollipops).  When a combination is found such that chocolates * lollipops = sum of all 3 candies, it displays it.  Only two such combinations are found:
2 14 12
and
4 6 14
From the final statement of the problem, Alexei must have the first combination, and Boris has the other.

Edited on March 29, 2006, 12:20 am
 Posted by Ken Haley on 2006-03-29 00:11:39

 Search: Search body:
Forums (0)