Wednesday, June 24, 2009

Puzzle 35 – Solution

A MB and KB are special numbers simple because they can be expressed as powers of 2.
1 KB = 2(10) and 1 MB = 2(20). Java provides a simple operator to multiply by two better know as the left shift operator.

So the code snippet that does the trick is,

int oneMB = oneKB<<10;

The other answer that I got is,
int oneMB = oneKB+1047552; which look like a neat enough way to solve the puzzle!

Leaders board to be updated with the next post.

No comments:

Post a Comment

Solution for this question?