Ad
  • Custom User Avatar

    Lua translation open for review, feedback would be appreciated !

  • Custom User Avatar

    I found an error in my code. The resulting string contains an "end of line" character in the middle. It seems that how the result is printed is different from what is printed using the cout function.

  • Custom User Avatar

    Now the output is following:

    RESULT IS [275*+]
    Expected: equal to "275*+"
    Actual: "275*
    
  • Custom User Avatar

    To see where is your mistake, change your code to:

    ...
        auto out =  translate(full_expr);
        std::cout<<"RESULT IS ["<<out<<"]\n";
        return out;
    }
    
  • Custom User Avatar

    This translation has been rejected because it had no random tests, the reference solution was incorrect, and the author has not reacted several months after it has been pointed out.

  • Custom User Avatar
  • Custom User Avatar
  • Custom User Avatar

    C++ still needs to be fixed

  • Custom User Avatar

    I feel happy if it helped you. A bijection is a strict correspondance between the elements of two sets, in programming terms it would mean that for each input there is one and only one output matching with it, and vice versa.

  • Default User Avatar

    Intersting... very intersing. I tested 275*+ and 75*2+ ova here and both give same result 37. But ofc, you said in your 1st sentence of 1st comment that that is not the end goal.

    I must apply the rules to create the correct postfix, or so I understand. So basically whenever confronted with such a choice, my code should dump all the signs at the end.

    Sidenote - first time heard bijection but don't see why there is no bijection between 2+7*5 & 75*2...

    wtf. Lol i won't delete what I wrote, you're right! I see the bijection now! So basically my funk's ouptut should have the numbers in same order as they're given in the inputted infix string.

    Thanks a ton for your wonderful help & enlightenment of this simpleton! There's no way i'll be able to convert the solution in my brain to actual code lol, but at least good to know that my brain can solve this correctly now.

  • Custom User Avatar

    Construct a function that, when given a string containing an expression in infix notation, will return an identical expression in postfix notation.

    There exists a strict correspondance between an infix expression and the corresponding postfix expression (using mathematical terms, there exists a bijection between the two systems). Just like 2 + 7 * 5 is not the same as 2 + 5 * 7, though both evaluate to the same result, the postfix corresponding to 2+7*5 is 275*+, and not 75*2+, 257*+ or something else.

  • Default User Avatar

    I'm sorry but i don't follow you, could you please elaborate?

    The kata is not interested in testing if you returned any postfix expression that evaluates the same as the infix input.

    But i thought that is exactly what needs to be done. My func needs to return a postfix string, which when evaluated should equal the inputted infix str's evluation. Isn't that the whole point?

    Your 2nd sentence totally went over my smooth brain. 3rd sentence yes agreed, order of nos is same, but order of the signs can be different & yet give the same answer.

  • Custom User Avatar

    The kata is not interested in testing if you returned any postfix expression that evaluates the same as the infix input. You must apply the rules to create the postfix expression corresponding to the infix input (this is a classical topic). All the numbers have the same order in both expressions.

  • Default User Avatar

    Can someone explain why 275*+ and not 75*2+ is the correct answer to 2+7*5? Shouldn't both answers be acceptable?

  • Custom User Avatar

    Approved.

  • Loading more items...