Easy peasy, even got it on the first compile (honestly that’s not something to brag about). There’s an interesting wrinkle for today’s (the original problem is actually yesterday’s problem) version that is to minimize the character count by 25%. Eclipse doesn’t have a built-in character counter so I’m going to try to use the file size listed in WinExplorer. Current size is 1,168 bytes; my goal is 75% of that or 876 bytes. This is a neat addition since sometimes (embedded systems, mobile) size is a concern. Not as much as years ago when a computer only had 256kb of memory space but sure let’s be retro.
I removed all the white space I could (spaces, line breaks), the javadoc comments, the regular comments, and put all the if-statements on one line. This reduced the file size to 345 bytes! This puts the total at 30% of the original file size. Quite a shrink but some of the comments should probably be in there still and it’s more difficult for a human to read now. Ideally this could be minimized before compile time so the useful information sticks around somewhere so the next poor bastard who has to use the code has some idea of what was going on.
Building on yesterday’s problem, take your solution and cut the amount of code used by at least 25%. That means that if your solution was 100 characters your new one should be no more than 75 characters. New line, tab, and space characters all count towards your character total.