Let R denote Red, G denote Green and B denote blue.Â

First we consider the most worst case in which three different coloured cubes can be drawn. i.e. R G B

Then in next drawn one of the colour say R must be drawn so that one of the students get two same colour cubes. i.e. R G B R

Now the next worst case is to draw R at 5th draw again. So we have R G B R R.

If we draw any colour at 6th draw then another student will get 2 cubes of same colour hence let us draw any colour say G.

So we have R G B R R G after 6th draw.

After pairing, 2R and 2G, we have single R and B. So the next obvious worst case is to draw G again at 7th draw. i.e. R G B R R G G.

Thus, finally we have 2R, 2G, R, G, B and any 8th draw will make a pair with three single colour cubes.

So, the least number of cubes that need to be pulled out to be sure that every boy can get two cubes of the same color is 8.