6 kyu
Same Array?
484 of 1,025osofem
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 comment has been hidden.
This comment has been hidden.
Python, JavaScript, PHP:
Wrong array dimension in the describe block message,
'Simple 3x3 arrays'
should be'Simple 3x2 arrays'
python new test framework is required. updated in this fork
Approved
Ruby 3.0 should be enabled.
Enabled in this fork
There should be tests with outer arrays having same values spread across different sub-arrays.
Very nice kata! Cheers! :)
Very nice kata! Thanks!
I would translate this really good kata for C#. Are you still here online?
So I've got a question here about the test cases...I re-read the kata and my initial solution was to sum the different arrays and if they are == then it's True. Everything passed in the tests but am wondering if this test should be included.
Test.assert_equals(same([[5,5],[0,2]], [[7,3],[1,1]]), False, "Values that sum the same but are different")
This comment has been hidden.
I started in your same shoes, but luckily here was (and still is!) an awesome place to practice and learn :)
Pardon me if I may insist, but if you might consider my translation, as a side effect I would also be able to fix the JS version - just in case you don't have enough time or focus right now ^^'.
Approved! Sorry I was off for some time. Back now!
No problem man; there is still the Ruby translation to approve, then if you wish I do something for the JS version too :)
[If I do something now, I fear you get some merge problem; sorry about that^^']
Ruby translation? Can't find that here. Saw only the Python which I have approved already. And ofcourse you can improve the JS version, I believe that's what this community is meant for (improvement).
How strange about Ruby, mh... Can you confirm me if you can see (and eventually approve, if it is of your liking) this one?
Then I'll gladly look into the tests :)
Yes, approved!
First rework submitted, let me know (replying to my comment above, otherwise I think I won't be getting notifications) if everything is now fine :)
In the random tests I get "Expected: undefined, instead got: false" while when testing the same test arguments and the same code in JSbin the result is "undefined", in addition all my 'return' statements return undefined.
Might be related to @natesanity post about the "and" in the random test case.
This comment has been hidden.
AND instead of ',' in random test case? Am I doing something wrong or is the test case wrong?
Translated it into both Ruby and Python, if you want to approve them.
Also, the JS test cases seem like they may need some rework: let me know if a hand is appreciated there :)
The test cases are lacking a test for the first line
[[2,5], [3,6]] is NOT the same as [[2,3], [5,6]]
. Some solutions flatten the array for convenience and would not pass this test, yet they do while violating the very first of the numbered rules.Another thing that is not tested are duplicates. Different solutions have different opinions on whether
same([[1,2],[1,2],[3,4]],[[1,2],[3,4],[3,4]])
should evaluate to true or not.Please double check the random tests. I print out the input arguments, it doesn't match those arrays you mentioned after the 'value not expected'.
[ [ 14, 6 ], [ 6, 72 ], [ 78, 63 ], [ 32, 77 ], [ 39, 30 ], [ 47, 47 ], [ 55, 45 ], [ 34, 95 ], [ 2, 52 ], [ 50, 25 ], [ 47, 95 ], [ 1, 85 ], [ 39, 22 ], [ 77, 30 ], [ 31, 95 ], [ 9, 14 ], [ 32, 79 ], [ 6, 78 ], [ 62, 3 ], [ 30, 76 ], [ 3, 13 ], [ 87, 16 ], [ 30, 89 ], [ 10, 20 ], [ 92, 7 ], [ 56, 37 ], [ 35, 37 ], [ 29, 66 ], [ 78, 96 ], [ 60, 24 ], [ 50, 55 ], [ 37, 7 ], [ 47, 69 ], [ 28, 98 ], [ 44, 69 ], [ 55, 65 ], [ 15, 95 ], [ 47, 73 ], [ 17, 96 ], [ 21, 7 ], [ 97, 2 ], [ 79, 96 ], [ 46, 52 ], [ 78, 70 ], [ 42, 79 ], [ 71, 92 ], [ 87, 38 ], [ 8, 79 ], [ 64, 78 ], [ 73, 68 ], [ 9, 47 ], [ 25, 16 ], [ 87, 21 ], [ 81, 92 ], [ 27, 49 ], [ 99, 70 ], [ 50, 60 ], [ 31, 17 ], [ 44, 19 ], [ 94, 26 ], [ 99, 1 ], [ 56, 75 ], [ 28, 77 ], [ 10, 21 ] ] ======= [ [ 21, 10 ], [ 77, 28 ], [ 75, 56 ], [ 1, 99 ], [ 26, 94 ], [ 19, 44 ], [ 17, 31 ], [ 60, 50 ], [ 70, 99 ], [ 49, 27 ], [ 92, 81 ], [ 21, 87 ], [ 16, 25 ], [ 47, 9 ], [ 68, 73 ], [ 78, 64 ], [ 79, 8 ], [ 38, 87 ], [ 92, 71 ], [ 79, 42 ], [ 70, 78 ], [ 52, 46 ], [ 96, 79 ], [ 2, 97 ], [ 7, 21 ], [ 96, 17 ], [ 73, 47 ], [ 95, 15 ], [ 65, 55 ], [ 69, 44 ], [ 98, 28 ], [ 69, 47 ], [ 7, 37 ], [ 55, 50 ], [ 24, 60 ], [ 96, 78 ], [ 66, 29 ], [ 37, 35 ], [ 37, 56 ], [ 7, 92 ], [ 20, 10 ], [ 89, 30 ], [ 16, 87 ], [ 13, 3 ], [ 76, 30 ], [ 3, 62 ], [ 78, 6 ], [ 79, 32 ], [ 14, 9 ], [ 95, 31 ], [ 30, 77 ], [ 22, 39 ], [ 85, 1 ], [ 95, 47 ], [ 25, 50 ], [ 52, 2 ], [ 95, 34 ], [ 45, 55 ], [ 47, 47 ], [ 30, 39 ], [ 77, 32 ], [ 63, 78 ], [ 72, 6 ], [ 6, 14 ] ] Value not what is expected for [[14,6],[6,72],[78,63],[32,77],[39,30],[47,47],[55,45],[34,95],[2,52],[50,25],[47,95],[1,85],[39,22],[77,30],[31,95],[9,14],[32,79],[6,78],[62,3],[30,76],[3,13],[87,16],[30,89],[10,20],[92,7],[56,37],[35,37],[29,66],[78,96],[60,24],[50,55],[37,7],[47,69],[28,98],[44,69],[55,65],[15,95],[47,73],[17,96],[21,7],[97,2],[79,96],[46,52],[78,70],[42,79],[71,92],[87,38],[8,79],[64,78],[73,68],[9,47],[25,16],[87,21],[81,92],[27,49],[99,70],[50,60],[31,17],[44,19],[94,26],[99,1],[56,75],[28,77],[10,21]] and [[21,10],[77,28],[75,56],[1,99],[26,94],[19,44],[17,31],[60,50],[70,99],[49,27],[92,81],[21,87],[16,25],[47,47]] - Expected: false, instead got: true
Sorry for the late late response! Please check your code, there is no way the arguments and the printed result wont match. part of the test code that check this goes thus
...same(aArr, bArr), "Value not what is expected for " + JSON.stringify(aArr) + " and " + JSON.stringify(bArr));