Timothy Foster - @tfAuroratide

Auroratide.com - Go here if you're nerdy like me

OK so basically you want "pretty print similar" to the 68k series.

Sort of, but not really. You receive an input, and the graph screen outputs a larger version.

Hello! | Hello! |

This is an example | This is an example |

Timothy Foster - @tfAuroratide

Auroratide.com - Go here if you're nerdy like me

I'm making a font! It might take a while to be finished though.

Yay!

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

I'm having a hard time with time constraints, but the font will be something Italic-like, with 6x5 ish letters.

Timothy Foster - @tfAuroratide

Auroratide.com - Go here if you're nerdy like me

Now that Challenge Six is completed (congratulations Zaphod, and thank you graphmastur for your patience), Challenge 7 can commence. Because of the unexpected delay, I changed the criteria so that no one accidentally had a head start. Now, you must create a program that does PEMDAS backwards. Have Fun!

Timothy Foster - @tfAuroratide

Auroratide.com - Go here if you're nerdy like me

I'm confused what exactly is it supposed to do?

Have the user input an expression (no trig or log stuff), and the calculator must simplify it in this method:

- 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.

Timothy Foster - @tfAuroratide

Auroratide.com - Go here if you're nerdy like me

What operations do we need to implement?

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.

Operations:

- 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!

Timothy Foster - @tfAuroratide

Auroratide.com - Go here if you're nerdy like me

Some more ambiguity: 5²+1.

Would you have that interpreted as 26 or 125?

So you're saying that all square root and xth root functions should be rewritten as exponents before parsing? To me that seems kind of arbitrary — you would be changing a function into an operation, which isn't exactly implied by the idea "PEMDAS backwards". If that's the case, though, I'll need to rewrite my program to account for that. It shouldn't be too difficult; I've already written the hard parts.

@Weregoose

125

5^{2}+1

5^{3}

@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.

Timothy Foster - @tfAuroratide

Auroratide.com - Go here if you're nerdy like me

What is the precedence of unary negation in relation to addition, multiplication, and exponentiation?

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)?

Negation is actually a form of multiplication when you think about it. Say you had -2. This is the same as -1(2) which is (-2). Now, if you have -2+3, this is -5, or -1(5) or (-5). However, (-2)+3 is 1.

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.

Timothy Foster - @tfAuroratide

Auroratide.com - Go here if you're nerdy like me

-2+3=1, not 5. Subtraction is used in pre-school, because a negative number is too hard to do. To find the negative of any number, simply do 0-X where X is your number.

There are a lot of messed up rules when dealing with backwards math. Normally, -2+3 is one. You can do all sorts of things to prove it such as using the communitive property to get 3-2=1. The problem is that those rules get screwy when you use a different method of math. You're right about finding the negative of a number, but you could also do it by multiplying by (-1). Here is what happens when you do -2+3 using the SADMEP method.

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

Timothy Foster - @tfAuroratide

Auroratide.com - Go here if you're nerdy like me

So, it is like doing the order of operations backwards?

Timothy Foster - @tfAuroratide

Auroratide.com - Go here if you're nerdy like me

I'm not happy with this. I'm more inclined to write the 2nd root as ^{2}√x instead of x^{½}, and this is the only dissension in my program that keeps me from submitting.

Unless you can do this:

√(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).

Timothy Foster - @tfAuroratide

Auroratide.com - Go here if you're nerdy like me

The root-extraction-to-exponentiation clause has put my 211 byte program out of the running.

Timothy Foster - @tfAuroratide

Auroratide.com - Go here if you're nerdy like me

I've submitted my solution as of now. It's 599 bytes and still needs some work, but I just want to know if it matches your criteria for negation, since I'm not too clear on that still. Could you tell me about any cases involving negation that the program handles incorrectly?

You're program is pretty good. However, it doesn't do implied multiplication very well.

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.

Timothy Foster - @tfAuroratide

Auroratide.com - Go here if you're nerdy like me

Heh, it doesn't do implied multiplication at all; I haven't programmed that yet.

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.

After playing with the numbers, I found some strange things. It seems that the definition of term has changed. Now, a term is any part of an expression bound by addition and subtraction. Here is what happens under PEMDAS rules.

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.

Timothy Foster - @tfAuroratide

Auroratide.com - Go here if you're nerdy like me

Thank you for pointing out the glitch about the square roots. It's fixed. However, I'm not sure if I want to submit a solution.

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.

You're right. Negation is crazy.

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.

Timothy Foster - @tfAuroratide

Auroratide.com - Go here if you're nerdy like me

Yes, the calculator does everything from left-to-right, because the developers got lazy. However, exponentiation is supposed to be right-associative. On Mathematica, for example, 16^.5^2 = 16^.25 = 2.

Ok, my math teacher has spoken. Rooting is distinct from exponentiation. They are related, like multiplying and dividing, but they are still different. The main difference is that rooting comes with its own set of parentheses.

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.

Timothy Foster - @tfAuroratide

Auroratide.com - Go here if you're nerdy like me

Yes, that's clear. Thanks for being reasonable and listening to our suggestions. Now all I need to do is implement implied multiplication. I'm not too sure how to do that the best way, but I'm working on that.

I have noticed that no one was participating in this challenge. This is partly my fault for making some controversial rules. But now, I have formed some definite guidelines that should hopefully reflect the concerns of previous previous posts and how it should be done without too much confusion.

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.**

Timothy Foster - @tfAuroratide

Auroratide.com - Go here if you're nerdy like me

in my opinion, these challenges are kinda boring, they need to be something exiting like a game or something.

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

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

Timothy Foster - @tfAuroratide

Auroratide.com - Go here if you're nerdy like me

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?

The challenge to make a program that does SADMEP sems quite a challenge to me, I personally think i have to use strings…*floating away*, well anyway i like these challenges, "Make a basic game" is a challenge too but a very trivial one and this is,as you said, usable as an improvement on your skills, i'll try to make something.

I like the challenges, i'm still new to this forum so it's already to late for me to enter in any of the challenges. But, if you added a new challenge like greating a game in basic (hopefully the challenge will be more detailed then just "a game".) then i'll gladly add an entry.

Since this is the 5th of may, is this challenge cancelled?

If so, I have a good idea for a new Challenge. Making the best quality game under 1 kilobyte. It would test not only the programmers optimization skill, but also their attention to precedence and creativity

How many bytes is a kylobyte?

So are we on for Challenge code name 1K?

Its already May 6th

I guess I'll go start It…