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.
Because it is building a new string so it is appending a new value onto the string for each pass of loop. I did similar thing, except I had result += a ? b : c
Please use the spoiler flag next time you are posting code.
This comment is hidden because it contains spoiler information about the solution
Cannot get it, why we put += next to result. Can smb explain, pls?
The tests in Ruby are fine. Closing.
Post your code
Approved.
ruby test cases are wrong , the final test shows 89 hours but it should be 6 hours and 31 minutes
Ok. I've updated.
Many thanks.
I believe "Pair" was the worst offender.
This still needs changing! Doesn't make sense. After removing extra use of "range" and adding "is", it becomes:
The range requirement has however already been stated. This says nothing and can be removed. It is also not the groups that should be found (it is the smallest values of the groups) so it is non-information.
Suggestion:
Not when that makes relevant information sparsely scattered between other repeated information! The use of different terms and formats additionally makes it difficult to tell whether something is new information or something that's already been said. There's also something to be said for brevity and being able to fit an idea in ones head.
I also think implied rules/constraints are Good Things when faithfully implementing the description results in the implications being included. The area of a rectangle is also the area of a square. The sum of empty is 0.
I understand this may raise questions, but that might actually be a good thing. But I also understand that the traffic might not be desirable for you.
I've removed the word
pair
. Using the wordsgroup & grouping
now.This Kata defines group/grouping as having 2 or more members that have the same ratio. This is is not a notation issue. The definitions are given as follows:
Removed
nil
requirement for Ruby.Redundancies are good for descriptions here at Codewars. The point has to be belabored, otherwise its never understood. I know this, because I've authored more than 100 Katas. Anyway, I hope the changes work now.
The word "pair" is misleading. It is not what you mean and it isn't previously defined in the description either. Please use something like "grouping of size 2 or more" instead.
I find this notation to be confusing:
(6,28,496)
because it suggests that this is a tuple which in turn suggests that it is fixed length, or rather lacks length and has three values. It's a group and a group isn't specifically three values, it's a list. Ergo[6, 28, 496]
Here you are introducing a second notation for a range (the other one being
range(a, b)
). Better if you use the same one everywhere.nil
in Ruby is unneccessary, the sum of zero things is 0."range" is mentioned twice but only has meaning once, and it doesn't make sense/English syntax error
The task isn't fully described, it leans too much on examples.
That's redundant if you describe what a group is. Also, group is now a third term (grouping pair group) for the same thing.
There are many formats used for list:
They're all the same thing. One format.
Good question.
The two are different. Note that I've used
7/4.0 and not 7/4
because I want a float, not a truncated integer. You can use the following trick: ifx = 7 and y = 4
, then the ratio isx/(y * 1.0)
to get a float.x/y
gives an integer.Use this logic and you will see that
(5,133) cannot be grouped together because 1.2030075187969924 != 1.2, and so on
The trick here is to use a data structure that keeps track of the ratios you have already found, so that if you come across that ratio again, you ignore because you are only taking the lowest member in any ratio. It's quite simple😊
i didn't get it. between 1 to 200 there are a lot of harmony numbers [4, 165]=1.75 [5, 133] =1.2 [6, 28]=2 [8, 52]=8... and all of them are 0<=n<200 what should i do with them?
Although this would not be regarded as a 'clever' solution i still think this way is the best solution. One for loop, instead of three to be a 'single liner'.
Loading more items...