Ad
  • Custom User Avatar
  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Just thinking that "loop the same long string 26 times" already is O(n).

  • Custom User Avatar

    Follow lechevalier. I practically learnt Python from his solutions. And he is the best in onliners.

    When you see a oneliner (or any code) you don't understand, copy it and make trials on your computer to figure out how it works.

  • Custom User Avatar

    my feeling exactly. i did this. how does one get to the one liners?

  • Default User Avatar

    I was confused by the notation myself but its just what it says, a prime factors decomposition. Lets take example from description: 86240=2^5x5x7^2x11

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

  • Default User Avatar

    I would've been in the same boat if you hadn't commented. So thanks.

  • Default User Avatar

    thank you will check it out.

  • Custom User Avatar

    The explanation could be better. I found these 2 sites helpful to gain an understanding of the problem and arriving at a solution.

    https://math24.net/simpsons-rule.html

    https://www.intmath.com/integration/6-simpsons-rule.php

  • Loading more items...