I’ve started working on lifetime stats and it’s very time consuming. Did you know I used to half-ass my stat keeping? I too was shocked. SHOCKED I SAY. Now I have four seasons of stats to work through, updating them to our current standard. (this is very reminiscent of my time consuming endeavor to update Softball Stats Pro, almost like it’s something I need to do)
Oh well. One down, three to go.
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.
This is similar to the “FizzBuzz” problem that seems to be pretty popular in technical interviews. I think I used if-else statements when I did it. In this case it’d be very similar other than for “fizzbuzz” I checked higher-level multiples first; in order to print “problemoftheday” properly it has to go lower-to-higher multiples. But let’s see.
You’ve got an easy one for today. Create a program that iterates over the numbers [1-100] (inclusive). If a number is divisible by 1 print “problem”. If a number is divisible by 5 print “of”. If a number is divisible by 25 print “the”. If a number is divisible by 100 print “day”. Thus when you reach 100 your final line of output should be “problemoftheday”.