The keystroke that does the trick for me is '0'. Yep adding a 0 to 52 changes it to 42.
int theAnswer = 052;
If you still wondering what has changed, it's that adding a leading 0 to a literal number means that the number is considered as an octal number. Doing a quick math would reveal that octal(52) = decimal (42).
This is also a pitfall – one should be careful of not adding any leading 0 in Java!
@SlimMo - Pretty neat thinking! That was indeed a unique solution - my favorite one for this puzzle!
No comments:
Post a Comment
Solution for this question?