 # 9 - 3 / 1/3 +1 =?

but I’m sure there are a few other answers to it too…

1 Like

Yep, I got 1 as well.

Here’s how to get there for anyone interested:

9 - 3 ÷ 1/3 + 1
= 9 + (-3) ÷ 1/3 + 1
= 9 + (-3 x 3) + 1
= 9 + (-9) + 1

3 Likes

I will probably come to learn why I am wrong in time, but my traditional approach to solving this would instead produce the answer of 9

Caused by resolving all divisions first.

The original equations was written as 9 - 3 ÷ 1/3 + 1, where the 1/3 is written as a proper fraction.
This is slightly less ambiguous than the alternative of writing it as 9 - 3 / 1/3 + 1.

The equation is still a little ambiguous but the way it’s written would suggest that it is an integer divided by a fraction, rather than three integers divided together.

2 Likes

That context makes more sense then. Thanks.

1 Like

I got 1 myself.

Thats how i solved this:

9 - 3 ÷ 1/3 +1
= 9 - 3 * 3/1 +1 (doesnt matter if you first simplify 3/1 to 3 or multiply by 3 resulting in 9/1)
= 9 - 3 * 3 + 1 (i simplified first)
= 9 - 9 + 1
= 1

Just to be clear:
What you mean is that the ambiguous part would be whether it is
9 - (3 / 1) / 3 + 1 = 9
or
9 - 3 / (1 / 3) + 1 = 1
and you can’t quite tell whch one it is, because % and / have no precedence over one another?

Edit:
For what it’s worth, Godot engine evaluates to 9: Do other engines use the same precedence?
Python evaluates to 9.0, JS evaluates to 9

Yeah, the placement of the parentheses is important.

The original equation was written as 9 - 3 ÷ 1/3 + 1, with 1/3 shown as a proper fraction (1 over 3), so some information is already being lost by converting it into plain text.

You are correct that 9 - 3 ÷ 1 ÷ 3 + 1 = 9, but in my opinion that’s not what the original equation is trying to represent. In this case, the correct way to convert it to code would be `text = str(9 - 3 / (1/3) + 1)`. All we’re really doing is explicitly stating that 1/3 is representing an proper fraction.

The reason these sorts of math puzzles cause so much confusion is because they are intentionally hard to read and can be interpreted in multiple ways.
This also highlights why it’s so important to be as clear as possible when writing equations with a fairly limited text editor.

Here’s the same equation, written with increasing clarity:
9 - 3 / 1/3 + 1
9 - 3 / (1/3) + 1
9 - 3 ÷ (1/3) + 1
9 - (3 ÷ (1/3)) + 1

Hopefully you can see how each small change makes a big difference to the readability without actually changing the equation. Just be careful about adding too many parentheses, as this can also harm readability.

2 Likes

Eh, I get 9 on this one. Logic:

9 - 3 / 1/3 + 1
BODMAS: 9 (-3 / 1/3) + 1
(-3 / 1/3) = -1
9-1+1 = 9
As far as I know with the order of operations, one always sorts out the division part before one does the rest. If one were to resolve it in a linear fashion then an answer of 1 makes sense, but math relies on the order of operations which dictates the order in which one must solve the equation.

there is no ambiguity in math even without brackets.

9 - 3 / 1 / 3 + 1 = 9
This evaluates to
= 9 - 3 /3 + 1
= 9 - 1 + 1
= 9

Every programming language should evaluate to 9. Otherwise its wrong.

As far as i undestood the problem is how to bring the equation (9 - 3 ÷ 1/3 +1) into code. And since the original equation used a fraction (1/3) we have to use brackets in code, because thats the only way how to represent a fraction in code only using default operators and no further helping functions.
So the correct way to code this up is: 9 - 3 / (1/3) + 1
This evaluates to 1.
If we do not use brackets to represent the fraction: 9 - 3 / 1/3 + 1 this would evaluate to 9.

1 Like

Hi,
well thats correct if you mean 9 - 3 / 1/3 + 1
Like: But in the lesson video the equation was slightly different: 1/3 is a fraction. Its not possible to simply break the fraction down to You have to look at a fraction like its a number.
Somewhat like this: 3 / fraction
And thats not the same like 3 / numerator / denominator.
So the correct way to do this is:
9 - 3 / (1/3) + 1
= 9 - 3 / 0.3333 + 1 (the 0.333 is actually one third)
= 9 - 9 + 1
= 1

Alternatively you can also do some math magic which makes it a bit easier to calculate this by hand:
9 - 3 / (1/3) + 1
= 9 - 3 * (3 /1) + 1 (if you divide by a fraction you can also multiply by its inverse)
= 9 - 3 * 3 + 1
= 9 - 9 + 1
= 1

2 Likes

FYI - Not sure where or how these discussion boards are seen but this thread is in answer to Ben’s pop question on the Math’s course, Division section, where he says the question is annoying / ambiguous with not enough info as proved with the discussion above… Yes, but spacing between operators/operands has no meaning (as Ben also mentioned in the course), so along with “keyboards be damned” for not having easy access to fractional representation and distinct division symbols, the subject-line as written should not have been as ambiguous as it was But that’s ok; it’s at least a prudent moment to remind that it’s dangerous to make any assumptions where ambiguities might exist.

That’s a bit harsh topdog
I was just getting the conversation going as Ben requested…
Yup - I don’t know how to show the division symbol on a keyboard so used spacing .
I also assumed only those who had just finished the tutorial would answer/comment so it wouldn’t be ‘as ambiguous’ to them… 1 Like

No criticism or bad blood intended from me - I too don’t have those things easily to hand on my keyboard. Sorry for any misunderstanding, definitely wasn’t close to being my intention For those interested, you can type the division symbol with Alt-246.
There are a bunch of other useful codes for maths symbols too so definitely worth checking out and committing a few of the more useful ones to memory.

I’ve asked a few times for a LaTeX plugin to be added to both the forum and discord but still no luck. Hopefully that will change at some point, as it will make discussing problems in the course much easier - especially when we we get into slightly more involved equations.

No worries topdog… Thx Gary - {hold alt and enter 246 on keyboard for any like me who’d have to google it ÷ }

1 Like

Yes, sorry. I probably should have mentioned that. Call it the curse of knowledge (I just assume everyone knows how to do alt-codes)!

I might put a separate thread together to cover some of the most useful math related codes, as it could be quite handy without LaTeX support on the forum.

1 Like

That’s Ok Gary 