Deadline: February 16th, 2005 at 24:00 GMT
Description
This contest is based on an obfuscated calculator(sorry, I needed to). This time, the code isn't obfuscated, but the way that the calculator gets it's input is. Input starts on the first column and the first line. From there, you read
the calculator and do the calculations like this:
w - multiply, begin going up
s - multiply, begin going down
a - multiply, begin going left
d - multiply, begin going right
t - add, begin going up
g - add, begin going down
f - add, begin going left
h - add, begin going right
i - subtract, begin going up
k - subtract, begin going down
j - subtract, begin going left
l - subtract, begin going right
e - end program
It will continue until the next character read is a number. So the format for the entire program will be number, letter, number, letter etc, the letter dictating the direction it goes and what the next operation is. Also note that there will not be any division.
Input:
Input will be read from a text file entitled "input.txt". The blanks in the equation will be spaces.
Output:
Your answer should be printed to stdout followed by a new line.
Example:
- Code: Select all
1h4s h9e
2 3
l3w
The above would output 30.
1+4=5
5*2=10
10-3=7
7*3=21
21+9=30
Optomize For:
2 Modules that each piece of code will be entered in (Thanks to Rodrigo for the suggestion)
- Code Brevity: The winner of this section will be the entry with the lowest token count. A token counter courtesy of jgbauman is available here. (stole it from one of Ryan's previous contests).
- Speed: The winnder of this section will be the entry whose code executes in the smallest ammount of time possible
Notes:
- No macros
- The equation will be longer than the example, but the entire thing won't be more than 25x25.
- All symbols will be lower case, so no need to worry about tolower() or anything.
- The result will be able to fit nicely into an int.
- Source must be in one *.cpp file called (your screen name).cpp.
- You must send the ENTIRE file, not just a function to do it. This means input, processing, and output.
- Program must compile on MSVC++ 2003 .NET
Submissions:
Send your entries completed in a single *.cpp file to darobat at gmail dot com with the title "Contest 44". If it doesn't compile, I will let you know the errors and you will be given the chance to fix it until the deadline. Each person will be allowed to enter two different entries, one for each section of the contest. If you only enter one, it will be enterd in both. If you do submit both, just stick them in a zip (not rar) file and send them as before.
If you have any questions, comments, concerns about this contest, feel free to post here.

