Retired
Find all pairs (retired)
166 of 5,124Rubos
Loading description...
Fundamentals
Arrays
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
This kata is a subject to deduplication process here: https://github.com/codewars/content-issues/issues/179.
Please join the discussion to help us identify duplicate kata and retire them.
This comment has been hidden.
Description uses pairs not in the normal meaning of the word pair. What is intended is two equal values.
This comment has been hidden.
C translation (author inactive)
Approved :)
This one or another duplicate should be retired. So please do not approve pending translations first !
how do translations affect the retirement process ?
It requires more work in transferring from one to another if the other one does not have specific languages in which this one had. ~~
@ejini: you have been told this already: Existing duplicates is not a reason to block all the translation process. Duplicates can last years to be deduplicated, some could never be. And what if the deduplication process decides eventually to keep both? More still: this is a low level kata, and there is no C translation in any of the two katas.
Okay, I don't remember I was being told tho, but since both of em didn't have C, feel free to translate ^^
Really nice kata!
Ruby 3.0 should be enabled, see this to learn how to do it
Please organize the structure of test fixture as following (although it has been mentioned in the attached link, I'm repeated here again)
Kata retired.
This comment has been hidden.
This comment has been hidden.
Lol I thought I was pretty good a coding b4, but then I saw everyone else's solutions xP
Approved. Keep them coming
I think this should be a 7 kyu problem.
Kotlin translation, would someone mind reviewing this please.
.
Ruby translation kumited -- please review and approve.
Note: I seriously simplified the description, as it was too lengthy for such a simple task...
see issue below plz (your translation is good, but that would be better to have the same constraints on the generator in all versions)
Republished translation with more elaborate random tests.
random array generation and moreover the choice of generating this or that kind of array (when this choice is at least implemented...) is inconsistent from one language to the other. Please update all languages so that they match the java version.
I can't rewrite all tests.
rewrite those you can, call for the translators for the others.
Looks good to me
Python: actual and expected values are swapped in the tests. It should be:
...not the other way round.
done
The tests currently break if the passed-in array is mutated. I'd recommend doing one of the following:
Problem solved :D
👍
[ 2, 284, 335, 375, 531, 400, 181, 531, 284, 330, 494, 893, 375, 993 ] Expected: 0, instead got: 3
???
I similarly got
Expected: 0
for 94 tests. The only ones I pass now are the 6 fixed tests.Are you mutating the array?
Yes ... so I suppose their code runs their solution on the same array after my function is done with it. OK, thanks.
They've now fixed that bug.
Description should specify how to count numbers occurring more than two times.
Leaving this to an example test is not specifying it. The description should be self-contained, and complete.
Issue is resolved.
This used to be an interesting little Kata because of the small range of numbers (0-1000) in the test set meant there was dozens of ways it could be solved. So it was interesting to see the different ways people went about it.
Now for some reason you have removed that condition so the array based solutions are no longer viable. It is going to mean most solutions will now look exactly same as each other.
Why would you want to deliberately make an interesting kata boring? I am hoping it was just accidental due to this dubious
shift
thing introduce in the tests that you got from @B4B.mmmh, unexpected thing. I checked the description before suggesting the implementation and didn't see any requirement about the vlues so went for that. But I effectively thought there was something about that before...
@Rubos: just change
generateRandArray(100,1000,rand.nextInt(500))
togenerateRandArray(100,500,rand.nextInt(500))
, that should do it. (edit: and don't forget to give the restriction about the values in the description again ;) )First there was max
max value 100
andmax length 100
, then i changed it both to 1000. Now I don't know what can be found in that random arrays. I will change tests as @Blind4Basics suggested.Fixed, now value range is: 0-1000 and array length is: 0-1000.
The description doesn't specify what to do with numbers occuring more than 2 times, or whether such cases won't be generated at all.
...!? the second example is especially about that, tho........... :o
But it doesn't explicitly tell, that "pair == 2 distinct elements".
yes it does... :o
And yet you're saying that the description explains what "a pair" is clearly? ;)
yes, because I actually didn't read the full description first. When seeing the problem, I read the second example and then...
Example 2 has enough detail for you to figure out all you need to know.
x)
You misunderstood the need here: now your test won't ever generate any pair, except in some rare cases. What you need is a mix of that and the opposite:
length=100 ; value=1000
generate arrays of size 100 with valueslength=1000 ; value=100
This comment has been hidden.
This comment has been hidden.
Fixed. I left third value same as in your code.
well... Would have been better to choose randomly between the different generations rather than use each of them always in the same order with the same parameters but...
ok, ok I added random third parameter.
This comment has been hidden.
I guess I don't know how to write tests.
to create a qualitative kata/problem is generally harder than to solve it. ;)
Suggest add edge case fixed test with some pairs of zeros. e.g
{0,0,0,0,0}
e.g{1000,1000}
(Not all solutions will work for edge cases)
Added.
No. I don't think this is done.
If there really were edge tests for pairs of
1000
then some of my earlier bad solutions should be invalidated, but they aren't.yep, typos when writting the test, it seems... ;)
Changed to:
array = new int[]{1000, 1000};
numOfPairs = 1;
hi,
I added fixed tests. I changed maximum value to 1000.