Can you solve 8÷2(2+2)

The #1 community for Gun Owners in Indiana

Member Benefits:

  • Fewer Ads!
  • Discuss all aspects of firearm ownership
  • Discuss anti-gun legislation
  • Buy, sell, and trade in the classified section
  • Chat with Local gun shops, ranges, trainers & other businesses
  • Discover free outdoor shooting areas
  • View up to date on firearm-related events
  • Share photos & video with other members
  • ...and so much more!
  • jamil

    code ho
    Site Supporter
    Rating - 0%
    0   0   0
    Jul 17, 2011
    60,594
    113
    Gtown-ish
    I understand what you're doing in code to make it work. The problem is you keep trying to code it and inserting an operator that doesn't exist to make it compile. Stop and write it out.

    9/3/8/2(2+2)

    Parenthesis aren't just replaced with a multiplication symbol.
    X(A+B) = (X*A+X*B)
    is the correct way to use it when there is no symbol preceding it. Right? There's no multiplication operator between the 2 and the '(' of the original statement?

    You're shortcutting the property in a way that is attempting to drop the parenthesis, or remove the distribution, just to make the code compile. Which is not inherently wrong 99% of the time. If you were to distribute the full fraction, it'd look like

    (2*9/3/8/2 + 2*9/3/8/2)
    right? or if you want to solve 2+2 before distribution
    (4*9/3/8/2)

    Then you can eliminate the parenthesis as there's nothing left to perform on them. And I don't know about you, but that seems unnatural and definitely doesn't look right. I've never seen someone distribute a fraction into a grouping like that.

    You can copy and paste the below into the Javascript console in your browser to test if you want. I also get 3/4 using your method, but 3/64 by hand when distributing only what I think is supposed to be, which is everything before the parenthesis excluding any operators.

    Code:
    (function() {
    function jamil() {
        // evaluate 9 / 3 / 8 / 2 ( 2 + 2 )
        // compute left to right just using multiply
        var x = 9;
        x /= 3;
        x /= 8;
        x /= 2;
        x *= (2 + 2);
        console.log("Jamil says the answer is " + x);
        return x;
    }
    
    function danimal() {
        // evaluate 9 / 3 / 8 / 2 ( 2 + 2 )
        // distribute 1st available number pre-parenthesis, then compute
        var x = (2*2 + 2*2);
        var y = 9;
        y /= 3;
        y /= 8;
        y /= x;
        console.log("Danimal says the answer is " + y);
        return y;
    }
    
    jamil();
    danimal();
    })();
    You complain that I rewrote it to add the implied operator, and then you rewrote yours to distribute? And not just that. You rewrote it to do each operation in 5 lines. What gave you the permission to write it out differently than it was written? What gave you permission to willy-nilly drop the rest of the term and distribute that 2. Write it like it is. All I did was write it out to add an operator that exists implicitly that the language requires.

    Honestly, I’m surprised we’re still talking about this. INGO has already resolved the right answer and we were in the irrelevant banter portion of the thread lifecycle.
     

    danimal

    Marksman
    Rating - 0%
    0   0   0
    Jan 12, 2011
    217
    18
    Unincorporated Lake County
    You rewrote it to do each operation in 5 lines. What gave you the permission to write it out differently than it was written?
    Well, the java compiler more than likely analyzed your initial code and just directly assigned the final value to your variable instead of actually performing the operation at runtime for use in evaluating your assertion. You'd have to check the bytecode to see what it really did. I just wanted to try and force the JS interpreter to operate on only 1 operator at a time, so the results could be seen step by step. Everything should still be processed left to right like your statement, and gives the same result.

    What gave you permission to willy-nilly drop the rest of the term and distribute that 2. Write it like it is. All I did was write it out to add an operator that exists implicitly that the language requires.
    And that's what I'm not getting I guess. I don't think I'm doing anything that is implied, I'm just trying to remove the parenthesis first. There is clearly a factor attached to the parenthesis in the non-coded statement; how many operators are involved before the parenthesis lets ignore for now. You said you added an operator that exists implicitly, but then its used as though it was explicitly stated in determining the operations to perform and use in your code (even though this isn't originally a coding problem). I've not see this process of putting a multiplication operation between a factor and a grouping before. I was taught you can't remove or separate a grouping until both the factor and the exponent were both 1, or by some function performed on both sides of an equation (not applicable here). The multiplication operator you're inserting that you say is implicitly there, do you know what that is called or where I can find more on how or when it is applied?

    Honestly, I’m surprised we’re still talking about this. INGO has already resolved the right answer and we were in the irrelevant banter portion of the thread lifecycle.
    MOAR BANTER!!1!1!!.. maybe, but I always like learning new stuff when a problem comes along.
     

    ATOMonkey

    Grandmaster
    Rating - 0%
    0   0   0
    Jun 15, 2010
    7,635
    48
    Plainfield
    Well, the java compiler more than likely analyzed your initial code and just directly assigned the final value to your variable instead of actually performing the operation at runtime for use in evaluating your assertion. You'd have to check the bytecode to see what it really did. I just wanted to try and force the JS interpreter to operate on only 1 operator at a time, so the results could be seen step by step. Everything should still be processed left to right like your statement, and gives the same result.


    And that's what I'm not getting I guess. I don't think I'm doing anything that is implied, I'm just trying to remove the parenthesis first. There is clearly a factor attached to the parenthesis in the non-coded statement; how many operators are involved before the parenthesis lets ignore for now. You said you added an operator that exists implicitly, but then its used as though it was explicitly stated in determining the operations to perform and use in your code (even though this isn't originally a coding problem). I've not see this process of putting a multiplication operation between a factor and a grouping before. I was taught you can't remove or separate a grouping until both the factor and the exponent were both 1, or by some function performed on both sides of an equation (not applicable here). The multiplication operator you're inserting that you say is implicitly there, do you know what that is called or where I can find more on how or when it is applied?


    MOAR BANTER!!1!1!!.. maybe, but I always like learning new stuff when a problem comes along.

    You can't ignore the operations that happen before the parenthesis. Specifically because the division sign inverts the integer.

    Invert and multiply and it will all make much more sense.
     

    jachin

    Plinker
    Rating - 0%
    0   0   0
    Jul 31, 2019
    1
    1
    Henry County
    You are old if you remember what the acronyms COBOL and FORTRAN represent.

    You are very old if you remember doing bubble sorts on your 80 column card decks.

    I guess I'm just old. But not that old. My CS 101 class was taught in PL/1. COBOL and FORTRAN weren't options.
     

    BroodXI

    Sharpshooter
    Rating - 100%
    7   0   0
    Sep 15, 2010
    601
    43
    Salem
    What if i told you, "You are all wrong." You only think you are right because that's what we have been taught. The sky is blue, because someone told us it was blue. If we were taught it was red, then it would be red. Or would it? You decide if you take the red pill or the blue pill.
     

    ArcadiaGP

    Wanderer
    Site Supporter
    Rating - 100%
    11   0   0
    Jun 15, 2009
    31,726
    113
    Indianapolis
    tenor.gif
     
    Top Bottom