Its already May 6th ]]>

How so? Like make the challenge a game? Or make the challenge's task to create a game in BASIC?

making a game in basic. the challenges need to either be something fun like a game, or at least make it be something people will use, i mean, really, how many people are going to use a program that does PEMDAS backwards?

]]>From my understanding, the challenges are a nice way to test your programming skills to accomplish a certain task as efficiently as possible. And to add to that, you get to pit your programming skills against other people (that's the fun aspect, seeing who can create the better program). The challenges test various areas in the programming arena, like my challenge tests string manipulation, comprehending mathematical operators, and size/speed optimizations. It sharpens your skill and allows you to study other programs entered by people (after the contest, of course) so that you can see what method is better. That's why I like the challenges.

However, I have noticed a lack of interest in these challenges. Perhaps better ones are needed like building a program from scratch in one day, or create a program that only uses Ans except for initial input.

Timothy Foster — My Site ~ My Blog

Here are the official rules:

- Only the operators +, -, *, /, (, ), ^,
^{2}√(,^{x}√,^{2},^{-1},‾, and implied multiplication will be used - Anything in parentheses are done first (therefore, rather than SADMEP, it's more like PSADME)
- Addition and subtraction are done first left to right
- Multiplication and division are done second left to right
- Exponentiation is done last left to right
- Negation will make a number negative. So ‾5+5 is still 0. ‾(5+5)+5 is ‾5.
^{2}and^{-1}are considered the same level as ^- I will always test with completed parenthetical pairs. In other words, I won't leave parentheses off.
^{2}√( and^{x}√ are considered their own function, and they will be done before anything.^{x}√ will operate before anything. So, 1+3^{x}√27*3 will simplify to 1+3*3, which simplifies to 12. If parentheses are used, respect them. (1+3)^{x}√(27*3) simplifies to 4^{x}√81, which is 3.- I will not use any variables. Only numbers.
- Your program must successfully pass 15 different expressions.
- The goal is for this to end May 10. If I do not have at least three contestants by then,
**this challenge will shut down.**

So, here is the final conclusion to the rooting issue. Rooting cannot be rewritten to be exponent. It will be its own function. Therefore, √(4)+3 is 2+3 which is 5. However, 2^2+3 will still be 2^5 which is 32. (2^2)+3 will be 7.

There is one exception. When using the ^{x}√ function, you need parentheses. Also, the index that precedes the ^{x} thing does not have parentheses. So, an expression 5-3^{x}√(4+12)+3 evaluates to 2^{x}√(16)+3. This is 4+3 = 7. You would need to add parentheses to clarify the index. 5-(3^{x}√(4+12))+3. The √( function and ^{3}√( function have implied parentheses, so they remain as square and cube root.

Does this clarify things? I guess this would put Weregoose back in now that I finally understand my mistake.

]]>

Here is my final decision on negation. Since it is controversial even when I am dealing with it on the paper, we'll just say that negation makes the number after it negative. So, 3+-2 is 1, and -2+3 is also 1. That way, negative numbers can come in more easily. In other words, negation became a form of expressing a negative number. Sorry if this causes trouble, but it will make things less controversial.

Unfortunately, I don't know if I'm still convinced about the roots. I checked 16^.5^2, and the calc says its 16 meaning it goes left to right. I shall ask my math teacher tomorrow, and he shall be the ultimate deciding factor.

]]>

I don't really like the rules about negation. Negation is mathematically equivalent to multiplication by -1. However, it is still an operation, a right-associative *unary* operation, to be exact. Therefore, no matter the precedence rules, it still has precedence over the binary addition operation in the expression `3+-2`.

In general, I don't agree with the rules about *rewriting* expressions; for example, rewriting radicals as exponents. Using ordinary order of operations, you never need to rewrite an expression before parsing it. For example, consider `Sqrt(16)^2 = 16`. You don't rewrite that as `(16)^.5^2`, which would come out to `16^.25 = 2`. The way I see it, PEMDAS doesn't apply to square roots, because the order of operations should be clear from the way the square root symbol is written. On paper, the root always applies to everything underneath the radical. On the computer, square root is written as a function: `Sqrt(x)`, or on the calculator, `√(x)`. Functions always come with a set of parentheses, so again, it's always clear what the function is being applied to — the function is applied to the number inside the parentheses. You could say that functions are covered under "Parentheses" in PEMDAS.

I will upload my parser with ordinary precedence rules, however, for instructive purposes.

]]>I want to evaluate 1+2*3. The answer is 7.

What if I switch it? You don't get 3*1+2. You get 3*2+1.

Under SADMEP,

Evaluate (-1)2+3. It is -5.

Now, switch. Don't do 3+(-1)2. Do 3+2(-1). (3+‾2)

So, negation becomes a fancy way of writing "times -1". You multiply a constant by negative one. A number, therefore, is only understood to be negative if enveloped in parentheses like this: (-2).

So, negations are extracted out of its parent "term". If I have 3+‾2-‾4, it turns into (‾1)(‾1)(3+2-4). This creates 1. The reason is negation multiplies the "term" by (‾1). Hope this helps. In your program, it doesn't handle negations directly after operators.

Also, I noticed your program has trouble evaluating √(4). It evaluates it as 0.5, but it evaluates √(4)+0 to be 2.

]]>

About the negation: remember, the order of operations is just a scheme that tells us how to *write* mathematical expressions. It doesn't actually have any bearing on the *math*. So you can't use the commutativity of addition to say that `-2+3=-5` implies `3+-2=-5`, because the first expression actually means `-(2+3)=-5`. If you used commutativity, you would actually get `-(3+2)=-5`, or with precedence reversed, `-3+2=-5`, which is still correct math.

Order of operations is just part of the grammar we write math with — and doing the order of operations backwards doesn't mean we need to screw up math.

]]>The negation does have a problem, but until I can sort out all the rules of terms, I can't give solid answers. Tomorrow, I will be able to say for sure. Reason is

-2+3 = -5

therefore

3+-2 = -5

I can't figure out why though, so if you are able to wait a little, I will be back.

]]>

]]>

You have -2+3. Addition takes precedence, so you have to do -(2+3) to get -5. Very strange.

]]>

√(4+12)+3

^{2/7}√(16)

The user doesn't have to write it in exponential form, but since rooting is essentially a form of exponentiation, it needs to be treated like one somehow. Or you could treat all exponents like roots where x^{2} is ^{1/2}√(x).

]]>

]]>

When dealing with negation and multiplication, it can all be done normally unless there is subtraction or addition. -2*-2*5 is still 20.

Finally, exponentiation takes on its own nuance. Normally, -2^{2} is evaluated as -(2^{2}) which is (-4). However, since multiplication comes first, you do (-2)^{2} which is now positive 4.

Implied multiplication is seen everywhere, so I am going to check for it. Something like 2(3+5) evaluates as 16. Really, the only things I won't check are trig, log stuff, summations, and irrational/complex numbers.

]]>

When I wrote my program, I assumed negation had the same precedence as addition, since otherwise, negative numbers would take a lot of effort to enter. Example, if negation had least precedence, instead of -2*-2*-5*2, you'd have to do (-2)*(-2)*(-5)*2.

Also, is implicit multiplication required? That is, will you expect expressions like 2(3+5) to be evaluated as 2*(3+5)?

]]>125

5

5

@Edward H

It is preferred if the user is able to input the √(, ^{3}√(, or ^{x}√ functions and for the program to automatically rewrite it into the exponent forms. I'll be checking both ways.

]]>

Would you have that interpreted as 26 or 125?

]]>- Addition
- Subtraction
- Multiplication
- Division
- Exponentiation
- Any Root (not just square)
- Negation

The roots provide an unusual twist. Say we have √(4+12). The parentheses are there, so it would simplify to 4. However, take a look at this:

√(4+12)**+3**. This is different, and the reason is because the √ must be rewritten as ^(.5). So,

√(4+12)+3

(4+12)^0.5+3

(16)^3.5

16384

where normal simplification yields 7.

As for exponentiation, do it from left to right.

Thanks for participating!

]]>

I'm assuming:

- Addition
- Subtraction
- Multiplication
- Division
- Exponentiation
- Square Root

Anything else? What about the negation operation?

By the way, roots always come with parentheses (on the calculator), so you don't need to specify its order; it's always known due to the parentheses.

Also, exponentiation is usually done right to left; so 2^2^2^2 = 2^2^4 = 2^16 = 65536. Did you mean to do it in reverse?

BTW, I'm totally in.

]]>- All parentheses are completed first
- Addition and Subtraction is done left to right
- Multiplication and Division are done left to right
- Exponents and roots are done left to right

This is almost the exact opposite of what is traditional.

So, if the expression was 2*3+6^10-2/4, it does this

2***3+6**^**10-2**/4

2*9^8/4

**2*9**^**8/4**

18^2

**324**

So, it solves it with a backwards version of PEMDAS. The normal answer is 60466181.5, so it makes a difference. SADMEP pretty much.

I'll be using 10 or so expressions when judging, so try to get it as accurate as possible.

]]>

]]>

]]>

Will it be small enough to use in just any program?

]]>Hello! | Hello! |

This is an example | This is an example |

]]>

]]>