An organisation produces packets of balls. Each packet has ten balls of five colours. Total weight of packet is expected to be 10 KGs (1 KG) each ball. But, due to some machine error every time packet manufactured is of 12 KGs i.e. two balls of same colour are 2 KGs each. [4 Colours X 2 Balls X 1 KG =8 KG, 1 colour X 2 Balls X 2 KGs = 4 KGs. Total = 12 KGs] Note: Every packet may have different colour of defected ball.
Think of a logic/Program in any language to find out the colour of defected ball using a weighing machine in one attempt. Weighing machine has two sides X and Y and shows always shows the difference of both sides.
Colours are : Red, Green, Blue, White, Yellow.
Source: Windows Questions C++