6 kyu
Simple Fun #52: Pair Of Shoes
1,031 of 2,052myjinxin2015
Loading description...
Puzzles
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!!! Thanks to author!!!
Duplicates caught me offguard.
This test in java: For input: -> Shoe(LEFT, 31), Shoe(RIGHT, 31) <-, Shoe(LEFT, 30), Shoe(LEFT, 30) ==> expected: false but was: true is wrong, isn't it? Since there's two shoes with the size of 31 and both are left and right
you have two left shoes of size 30 here. You cannot pair them.
Please use the
question
tag to ask for help. Anissue
is a bug in the kataHi I'm getting this issue:
"tests/Fixture.cs(117,15): warning CS0219: The variable 'passed' is assigned but its value is never used"
Is this a problem with 'tests/Fixture.cs'?
C# tests un-myjinxinized. (this required a bit of reflection to keep backwards compatibility, as the method was an instance one for no reason)
Haskell translation
I tried to approve it, but the following error message occurred:
Description cannot be approved, recent changes from related record must be merged first.
Weird. Please try the fork.
Approved now. ^_^
^^
If its not working its because, Your solution is to simple. Take a good look on advanced tests ;)
Java translation, please review and approve :)
Approved. Thanks ^_^
Thank you. :)
Description is wrong. It talks about shoe sizes, then gives constraints:
2 ≤ shoes.length ≤ 50, 1 ≤ shoes[i][1] ≤ 100.
which does not match the description at all. Are shoe sizes between 2 and 50, or between 1 and 100?shoes.length
is not the shoe size, thats the length of the array of shoes.shoes[i][1]
then, according to the description, is the size of the shoe. So our constraints is an array of between2,50
shoes, each shoe being between sizes1,100
Small correction then: the description of the C translation is incorrect.
The description is the same in all languages. Does that mean the inputs in C are different than other langs? It looks the same to me, but I don't do C at all, so I could very well be wrong.
Well, then the description is wrong, because
shoes.length
is not valid in all languages.Yes, it is not code. I don't know of many languages (if any?) where
2 ≤ shoes.length ≤ 50
is valid code (which works as intended anyway). It is merely a much more concise way of saying "The length of the arrayshoes
is between2
and50
inclusive."Some translations may contains errors, but because the approver may not be proficient in this language, he can not find the existence of errors. In this case, we can only wait for the help of translator or enthusiasts to correct the mistakes. Thanks for your feedback ^_^
the issue here is between the chair and the keyboard
Yeah right. "Issue resolved". This is the exact mindset behind the myriad of shitty software specs.
Would changing
2 ≤ shoes.length ≤ 50, 1 ≤ shoes[i][1] ≤ 100
to be something like:2 ≤ length of shoes array ≤ 50, 1 ≤ size of shoe ≤ 100
resolve the issue, in your opinion?@Kacarott, it's the opposite, I think. The size of the shoes array is between 1 and 100 and the
size of one shoe
is between 2 and 50. Or am I wrong?Edit: I may be wrong actually... hmm, what about changing both to 100 so that we avoid the confusion?
@Kacarott, yes natural language is a better fit here.
Here's a fork
This comment has been hidden.
Sorting can be done in
O(1)
space andO(n log n)
time.log n
is generally negligible. And because the number of shoes is maximised to50
, it's at most a constant factor (log 50
) here. What's the constant factor of calculating hashes?You're not wrong, but world peace is a more pressing problem.
I think the random tests are kinda broken on c#
Why would you think so?
Because tests that should pass dont pass.
If you would give adequate information, maybe someone could actually fix any problems ( if they exist. there is no way to know ATM ).
Question should specify that the array is a jagged array and not a multidimensional one. It can be inferred from the arguments, but the main reason is to avoid miscommunications in the future for those who aren't aware there is a difference. Obv it's not a kata's job to teach terminology, but it'd be a nice gesture.
Factor translation
approved by someone
Big part of the answers are incorrect. [[0,1],[0,3],[1,2],[1,2]] this type of array will breake their code. So you can not just calculate sum of left and right shoes. You need to check every of pair (sort or something like this). And you can not make the array unique
fixed in JS
If I am not wrong, solution like this will not pass test on JS like
Test.assertEquals(pairOfShoes([[0,20],[0,21],[1,19],[1,22]]), false)
with equal sum of sizes for left and right shoes.
fixed for JS
C translation 👞👟👠 (author gone)
Approved
Missing fixed tests like
Test.assertEquals(pairOfShoes([[0,23],[1,23],[1,23],[0,23],[0,23],[0,23]]), false)
in JS, making such solutions faildone + enabled Node 14
Description formatting is broken.
The user can modify the input.
fixed for Python
This comment has been hidden.
@GiacomoSorbi, Ruby issue, please fix it, thanks.
Maybe related to the issue described (I can't see it since I haven't solved the kata, yet — but: I'm working on the Ruby version):
For random tests I get failures, like this one:
However, the shoes in that list pair up nicely (the pairs are even sorted in that list!) Maybe I'm entirely mistaken, but I think this is a bug in the kata's tests.
I've checked translator's code. It seems no problem in it. I've added two fix testcase:
After submit, the translator's code returns the correct result. Perhaps you've modified the input array? @seasidetesting, @Yuzik ;-)
And, have you seen the note:
LOL, so true (especially in javascript translations)! XD
I was considering about putting it as a default message in every kata with arrays, instead of just cloning the array...
Nice kata, thanks!
;-)
This comment has been hidden.
It's the end of yesterday ;-) Today's Kata feast is about to begin ;-)
At this point, not sure if I envy your talent or your time availability more, but I am certainly looking forward to the next challenges you will create :)!
Python, Ruby and Crystal are there; it pains me to admit I was unable to one-line the first one, let's see if someone like suic gets more inspired using something in the collection library or similar ;)
all approved, thanks ;-)
all approved, thanks ;-)
One-liner done! With the most used function of
collections
library, I admit ;-)Well in fact, no need for any library...
No more today ;-)
Thank God - i'm very busy at the moment:-)...!