Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
spoiler flag...
This comment is hidden because it contains spoiler information about the solution
Just thinking that "loop the same long string 26 times" already is O(n).
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.
my feeling exactly. i did this. how does one get to the one liners?
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
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.
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.
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 as2 + 5 * 7
, though both evaluate to the same result, the postfix corresponding to2+7*5
is275*+
, and not75*2+
,257*+
or something else.I'm sorry but i don't follow you, could you please elaborate?
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.
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.
Can someone explain why
275*+
and not75*2+
is the correct answer to 2+7*5? Shouldn't both answers be acceptable?I would've been in the same boat if you hadn't commented. So thanks.
thank you will check it out.
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...