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.
BigInteger actually has its own gcd method aptly named "gcd"
x.gcd(y) will return the gcd of x and y
This comment is hidden because it contains spoiler information about the solution
I advise you to try to figure it out on your own. I think there’s no point in immediately reading the solution or looking at the answers if something doesn’t work out.
It's better to try solving the problem yourself, and if it doesn’t work, lower the difficulty. If you're a beginner, it might be too early to tackle 4 kyu problems.
I can explain the solution without any problem, as can anyone else, but it won’t really help you. I'm sure that with time, as you gain experience, you'll be able to solve complex problems independently and efficiently. Good luck!
Could you please explain you code to me? I can't understand it beacause I am a junior developer.
fcurz, I think I made my point
As much as I agree with the general message, we still have to take care of the language on the platform and i need to hide the comment.
This comment has been reported as abusive
you have 3 point, buy two items, now you have 5 points, which is enough to get the last item for free, after which you have no more points available
Totally agree
This is the coolest and most clever solution I've seen on this website so far.
Well Done!
I would totally agree with you if I knew English better. But when I put those words into a translator, they came out with the same meaning
I agree. The description should replace "equidistant" with "evenly spaced", in my opinion. "Equidistant" had me picturing groups where all members were the same distance from each other, which would limit the groups to sizes of 1, 2, or 3.
The thing I lke the most is your gcd function.
What is
y[]
used for ?You have two chocolate bars. Each chocolate bar has portraits on it, but not necessarily in the same order. Your goal is to break the second chocolate bar as few times as possible in order to put the portraits in the same order as in the first bar. Each portrait is represented by a number from 1 to n.
For the example given:
first bar
|4|3|2|5|1|
second bar
|1|2|5|3|4|
There are three breaks you have to make in order to assemble the pieces in the correct order. One break between the 1 and 2, one between the 5 and 3, and one between the 3 and 4. That leaves you with the four pieces:
|1| + |2|5| + |3| + |4|
which can be rearranged to match the first bar:
|4| + |3| + |2|5| + |1|
I hope that makes sense.
Loading more items...