About The Contest

The first ever Olympiad of Misguided Geeks contest at Worse Than Failure (or OMGWTF for short) is a new kind of programming contest. Readers are invited to be creative with devising a calculator with the craziest code they can write. One lucky and potentially insane winner will get either a brand new MacBook Pro or comparable Sony VAIO laptop.



Entry #100103: TerseCalc

by Welbog
This is my original description (with stuff after the truncation made up if I could remember it): See the ZIP file for my design document (TerseCalc.pdf) written from the point of view of the idiot who could have conceivably written this calculator. My goal was to create an application from a few flawed base assumptions that an uninformed but creative coder could have made. In fact, from the point of view of the assumptions made, this code is rather good. I didn't do anything "stupid" or unnecessarily slow or awkward beyond the initial assumptions, so this submission is pretty small, has a fairly low memory footprint (at least before the leaks :)) and runs pretty swiftly, at least compared to what I've seen people say on the OMGWTF forums.
You should look for a few things specifically:
- "return" isn't used - in favour of "throw new string()" - since exceptions bubble up "faster" than returns, allowing the "math" layer to throw a string directly to the UI layer.
- Operations are implemented as acting on vectors of Number objects, so technically they are robust enough to handle n-ary operations instead of just binary. Too bad nothing else in the pipeline is capable of handling anything other than two operands.
- Number objects store unsigned int as strings and return them as signed strings. This makes for some interesting quirks for division, which needs to return decimal places.
- Arithmetic is not used anywhere in the application. Addition is defined in terms of <<, & and ^. The other operations just call each other (see diagram in TerseCalc.pdf) hierarchally, with Addition at the bottom.
- Look for the construstor that throws its own result. I'm rather proud of its utter uselessness.

Download0 Comments