6 kyu
Simple Fun #162: Pair Wise
183 of 526myjinxin2015
Loading description...
Algorithms
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.
Very good Kata! Thanks to author!!!
Haskell translation
Approved by Johan
python new test framework is required. updated in this fork
Approved
I cant figure this out "Note that any element of the array can only be counted in one Perfect Pair. Also if there are multiple correct answers, return the smallest one.", I dont understant why the answer to the following case is 10 and not 15.
kata.Pairwise(new int[]{0, 0, 0, 0, 1, 1},1);
if in the previous case the answer is 10, then what is the answer of the following:
kata.Pairwise(new int[]{0, 0, 1, 1, 0, 0},1);
In the first case, the pairs of indices are
0,4
and1,5
, summing to10
.In the second case, the pairs are
0,2
and1,3
, summing to6
.In both cases, use both
1
s once ( "element .. can only be counted in one Pair" ), and use the0
s at indices0
and1
( "return the smallest [ correct answer ]" ).I have no idea how you would arrive at
15
; it might have helped if you had explained that.Ruby translation should be updated 3.0, see relevent information here: https://github.com/codewars/content-issues/wiki/List-of-Ruby-Kata-to-Update
Enabled in this fork + Tests clean up
C# Random Test for: arr = new int[]{9, 1, 1, 6, 2, 11, 9, 1, 4} n = 6
Test Failed Expected: 12 But was: 1
Should be 1 because there is only one pair: 2+4 !
Read the description again... You need to return sum of INDICES.
OK. It's working. I misunderstood description.
Awaiting moderator approval