Bat and ball
A bat and a ball cost $1.10 together. The bat costs $1.00 more than the ball. How much does the ball cost?
Show hint
The quick answer, 10 cents, is wrong. Check it: if the ball is 10 cents, how much is the bat, and what is the total?
Show solution
5 cents. Call the ball's price x. The bat is x + 1.00, so x + x + 1.00 = 1.10, which gives 2x = 0.10 and x = 0.05.
The lesson for programmers: write the condition down and test your answer against it, instead of trusting the first number that feels right.
Want a problem like this every day? See today's problem and keep a streak going.