Post by Eric on Feb 3, 2008 17:09:00 GMT
We're off, we're off to programming challenge number two. (Runs and hides for being so ridiculous)
Anywho, yes it's the second one. Already. (cough Wrighty, cough).
In case you are unaware of what the Programming Challenges are, I've laid out the details in Programming Challenges Start. This address will also serve as the index for all the challenges, so later on when there are more, just look there.
First Order of Business: Ranking of Challenge #1
Well, I've decided that both of Wrighty and Chantry get the number one spot. Here's my reasoning:
Points:
Wrighty(1): 13
Chantry(1): 10
Programming Challenge Number 2:
The moment you've all been waiting for (especially Wrighty), the number two challenge. For this one I've decided to mix string manipulation with number calculation.
The challenge this time is to calculate a mathematical expression using reverse order of operations. Write a function that takes in the mathematical expression in string format, and returns it in number format. You can use anything tools available in your programming language aside from something like "eval()" which returns the answer to an expression.
Let me go over how this will work:
() - Parentheses remain the first, due to their nature of allowing exceptions.
+&- - Plus and minus go second
*&/ - Multiplying and dividing go third
^ - Exponents go last
So if you received a statement like this:
"(5 * 7) + 4 * 9 - 3 ^ 2 + 1"
It would break down to:
"35 + 4 * 9 - 3 ^ 2 + 1"
Then:
"39 * 6 ^ 3"
Then:
"234 ^ 3"
Then:
12812904
Have fun programming!
Anywho, yes it's the second one. Already. (cough Wrighty, cough).
In case you are unaware of what the Programming Challenges are, I've laid out the details in Programming Challenges Start. This address will also serve as the index for all the challenges, so later on when there are more, just look there.
First Order of Business: Ranking of Challenge #1
Well, I've decided that both of Wrighty and Chantry get the number one spot. Here's my reasoning:
- Wrighty: Yours was fairly good and simple, but you made one slight mistake in that you kept searching for more factors of a factor after one had already been found.
- Chantry: Yours got complex with the usage of the strings, which I know you explained was due to the necessity of specifying an array length. However, as I said, you could have just used an ArrayList and done toArray, and made yours incredibly simple (and rather elegant I might add) . However, your sub-factor search was correct, and you also even went up by twos in order to save time.
Points:
Wrighty(1): 13
Chantry(1): 10
Programming Challenge Number 2:
The moment you've all been waiting for (especially Wrighty), the number two challenge. For this one I've decided to mix string manipulation with number calculation.
The challenge this time is to calculate a mathematical expression using reverse order of operations. Write a function that takes in the mathematical expression in string format, and returns it in number format. You can use anything tools available in your programming language aside from something like "eval()" which returns the answer to an expression.
Let me go over how this will work:
() - Parentheses remain the first, due to their nature of allowing exceptions.
+&- - Plus and minus go second
*&/ - Multiplying and dividing go third
^ - Exponents go last
So if you received a statement like this:
"(5 * 7) + 4 * 9 - 3 ^ 2 + 1"
It would break down to:
"35 + 4 * 9 - 3 ^ 2 + 1"
Then:
"39 * 6 ^ 3"
Then:
"234 ^ 3"
Then:
12812904
Have fun programming!