7 kyu
Simple remove duplicates
398 of 14,962KenKamau
Loading description...
Fundamentals
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.
LC translation
It would be helpful to either add some small random tests, or provide a message that identifies the first element where actual differs from expected. Currently, if actual and expected are almost identical, debugging is quite difficult.
JS and Haskell updated.
LC added with random tests increasing in size.
Julia: random tests are affected by input modification:
i think i've fixed it
Yes, thanks.
C:
{} --> {}, {1} --> {1}, {1, ..., 1} --> {1}
)fork fixing all
Approved
Scala: basic tests don't compile:
(Attempt tests are ok)
Fixed
no honor after i solved this kata. This happens not the first time. There are bugs on this site...
Dart 2.14 update: https://www.codewars.com/kumite/648ea103d52f51688406b946
approved
Python update (new testing framework)
Approved
This comment has been hidden.
Scala translation
Approved
Can you address the issue I've risen above?
This kata is a subject to deduplication process here: https://github.com/codewars/content-issues/issues/136.
Please join the discussion to help us identify duplicate kata and retire them.
This kata was decided to stay.
C# Function name should use
PascalCase
(Please refer to implementation of backward compatibility here )Tell me, what about random tests? I solved the problem and pass the basic tests without any problems. However, my code does not pass random tests, and most importantly, the random test outputs only correct and incorrect results, and the original array is not shown.
https://docs.codewars.com/training/troubleshooting#error-messages-and-printing-your-inputoutput
Bro I'm having the exact same problem. Did you have to change your solution or you did something else.
have you tried printing the input?
This comment has been hidden.
Then you're solving another problem, not this one. The answer is right, only if it solves the task at hand.
JavaScript fork with update to
Node 14.x
and language-agnostic description
COBOL translation.
Approved
what is best taking performance/memory into account?
Same Big-O complexity ( either
O(n log w)
,O(n log n)
orO(n^2)
) depending on the complexity of counting / looking up items.Thanks Johan
It was interesting, thanks.
what parameter is this szout? arrin is for given array, szin is for size of array but what is this szout? plz anyone tell
Looks like the size of the returned array.
it is now explained in the initial code
This comment has been hidden.
C Fork kumited.
Hello The duplicates are removed, but the arrays are not sequence equals. Is it intentional? Expected: [4, 6, 3], instead got: [3, 4, 6] Expected: [4, 5, 2, 1], instead got: [1, 4, 5, 2] Expected: [2, 1, 3], instead got: [1, 2, 3]
Don't change the order.
same for me how did you solve it?
Same Question what to do with this
what is the solution
Thanks for this Kata series!
This comment has been hidden.
This comment has been hidden.
Why's it dumb? There are loads of real-world problems that would want you to discard prior instances of an element - e.g. a restaurant managing orders, typically they would want to process orders as they came in, but if an order in the queue was changed (e.g. customer changed their mind) then you discard the original order, and add the updated one to the back of the queue.
Not a dumb Kata at all!
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
Approved. Thx.
This comment has been hidden.
It's easy if you know how ;)
I think it depeds on the language. In C# it's fairly straightforward.
Man, read about slices in go. This is fundamentals.
This comment has been hidden.
language?
Javascript it seems, you can see from the description you should start removing from the beginning of the array, it seems you're doing it from the end instead.
javascript. I was doing based on the order of the array using '!includes' function
Do this:
a.push(a.shift())
[Assuming that you're returning arraya
and this is the general structure of the failure message]I think that'll solve only those 2 cases and it'll fail with some others.
This comment has been hidden.
It does, but the order of the resulting array is not the expected one, maybe you can change how your code does that (it is possible).
Could anyone please explain to me the application of this kata logic in the real world where it has to be reversed twice?
This comment has been hidden.
Yes it does:
This comment has been hidden.
This comment has been hidden.
^
PHP translation. Already had to fix a merge conflict :laughing:
Approved.
Apparently approval didn't work correctly (not in language menu, and root translation is not deprecated), try this: https://www.codewars.com/kumite/5d3f21b5b2985900265dc2dd?sel=5d3f50ea3304480017dfa59d
It's approved now. Thanks.
CoffeeScript :coffee:, Crystal :gem:, and Dart :dart: translations kumited.
Approved coffee.
There is a description conflict for Crystal and Dart. Can you fork so that I can approve?
https://www.codewars.com/kumite/5d3e0a34be64050020a0b087?sel=5d3f1ea5ebdcd90012474f60 https://www.codewars.com/kumite/5d3e1bb8b29859002649d706?sel=5d3f1ed491ee870018caa52b
Thanks. Approved.
.
This comment has been hidden.
Mark your post as having spoiler content next time. You're removing the rightmost duplicates with that code.
hi, for a test case of [2,1,2,3], I get the expted [1,2,3] in jupyter notebook, but not passing it here... any idea why?
Thanks!
To get help, please post your code here and mark it as spoiler. Someone will assist.
This comment has been hidden.
You're mutating the array in the loop, skipping values, check it here
This comment has been hidden.
Not a Kata issue. This is a question.
But how can I pass only with a print statement added? This should't change return end. Without the print line I couldn´t pass.
make a copy of input array using
ar = arr[:]
. Then usear
in your code.This comment has been hidden.
keep trying. There is nothing wrong with the Python solution. We have more than 200 correct solutions.
This comment has been hidden.
Never modify the input array. Start by making a copy of it using
arr1 = arr[:]
, then use that copy in your code. Also, I think something like arr.pop() would work better. Good luck.C translation kumited
please scrutinize for approval
thanks!
Approved! Thanks.
PureScript Translation Kumited - please accept :D
Approved. Thanks.
This comment has been hidden.
True at first glance, but most of them want first occurrences or unique occurrences, not last ones. That makes this different ( enough ), at least in my unhumble opinion.
Can you give an example of an actual duplicate?
This comment has been hidden.
Having to keep last occurrences is different from having to keep first or unique occurrences.
You think not, and I think so. I think it adds something to CodeWars.
This comment has been hidden.
I'ave had enough
There're already enough "remove the duplicate" katas.
An issue or an opinion? Is there a duplicate?
Duplicate kata sometimes are an opinion.
I share this opinion. Not because strictly no duplicates should be allowed, but because there are SOOO MANY duplicates.
I don't see the additional value of this version compared to the normal one, actually... :/
I do.
But it may depend on the language.
Ah, interesting. Could you develop a bit?
This comment has been hidden.
This comment has been hidden.
Ok
This comment has been hidden.
I think it would mostly just make this kata into "implement the forbidden thing yourself". Which is exceedingly easy, and which would make this kata a two-trick pony. Both are ungood really.
( JavaScript )
Should really check explicitly for modifying inputs.
can you approve?
I could, but since I only speak Haskell and JS I'd have to take your word for Ruby and Python being good. Also, I note that you haven't ( yet ) taken my suggestion. If you add an explicit check for modifying inputs ( one is enough to tell people what they're doing wrong ), I'll approve it. :P
So, I approved it. You are now morally obligated to add that test. :P
I will add it. Thx.