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.
Cool solution! But is it O(n^2) compared to O(n) for the stack approach?
Hi pretty cool,
what i have to mention is, what exactly are you doing if
the use case changes and you would have to compute any string within any valid braces?
To add on, I think it's also because the pair of brackets will only be replaced with "" if the open and close brackets are in the correct order, of the same type as well as next to each other, on each iteration. By the last iteration, it should give you a "" if the bracket orderings are valid.
Please use spoiler flag next time.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Imagine you had to choose which solution you prefer to debug. Good luck debugging that 3 liner.
Also, I can write shitty code and rank up as long as solutions I post work.
Lastly, what is the point replying to a 2 year old comment and ranting about how wrong I was as a beginner?
I don't agree, it is indeed a reasonable approach, and the code is perfectly readable as well.
No offence, but if you think what he wrote is unreadable, I wonder how you are 3 kyu.
I was wondering if someone could explain how this works, particularly if braces are out of order? For instance, if braces was "({[}])", wouldn't this code change the string to "{[}]", then to "{}"? Wouldn't this disregard the order of braces? I'm relatively new and would greatly appreciate if someone could help me out. Thanks!
you could replace the last few lines with:
return b.length() == 0
@raulbc777
In addition:
My result Python == my result Excel (calculation in Excel on basis of https://www.maa.org/sites/default/files/0746834215798.di020710.02p0187t.pdf for gcd==1)
I can my results send to you by e-mail(for p=2470 pos=219)
Hi!
I can't solve the task.
For this task (where Triangle has integtal side and one angle twice another):
gcd(a,b,c)=1
a=i2
b=j*i
c=j2-i2
where
i<j<i*20.5. The inequality for Python -> i<j<2i+1 or i<j<2i
Me code for p=2470 and side (715,729,1026) return order num = 219 (autor order number = 215). I think that my code return excess triangle, but I verified results for criterion of Heronian triangles.
I can send my code or You will send to me (smenergy@inbox.ru) list your results for order number 1...219
can any one tell me why he used \ and why {[()]} is ok but {(}) not ok :/
Okay I found it, we have to use completing the square...thanks
I would add a test inside the for loop to test if after the replace the b is identical with previous iteration. And if identical return false. That means that nothing has changed and there is an issue in the strig, so fail fast is covered here.
Otherwise the for goes to braces.length/2 doing nothing.
Loading more items...