7 kyu
Find array
1,068 of 2,805tim_othy
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.
We need tests with numbers exceeding the first array.
Scala translation
C Translation (author inactive).
Python update (new testing framework, reworked tests)
Approved.
Javascript Fork
update to node 18 and test using mocha
Approved
Language: C++
Test suit missing the required header
std::vector
.In C++ you propose as a starting template:
but there is no
in program. So it would be desirable either add this or change all "vector" to "std::vector" in template.
Good point, will add that.
In Python, I managed to pass all tests but I encounter an error that says "list index out of range". Now I know an index out of range is supposed to be ignored but how would I go about that?
The test cases don't cover the case where
arr2
has an index that is out of bounds inarr1
, so, for the kata, this code passes -while it shouldn't.
There is a test case in the description that states -
If you run the code above, for this case, you would get -
[4, undefined]
, as shown in this bin.The correct output should be just
[4]
.At random tests im getting an error that it is out of a boundaries...i found in comments that you saying the function just should return empty but when i did it now im getting that: Expected is System.Object[6]>, actual is System.Object[0]> Values differ at index [0] Missing: < 956, 450, 344... >
So you have to correct this or correct me if im wrong at understanding something.
Hi,
If an element of arr2 is out of bounds for arr1 then it should be ignored. However the other elements of arr2 should still be used.
Hope this helps.
Thanks! now working..but still i suggest you to write that in instruction because people need to know that while doing this kata. Thanks for this kata!
It's implicit in the description but will add it in writing.
Description says:
. . . it returns
4
at index2
of arr1 and ignores index6
which is out of bounds; ) )
oh yeah...my bad..i missed that part of example :)
Hi, I made a C# translation, please review and approve.
.
JS translation kumited.
BTW, coding this translation, I've thought about some specs which could be added :
arr1=["a","b","c","d"], arr2=[2,2,2] -> ["c","c","c"]
arr1=["a","b","c","d"], arr2=[3,0,2] -> ["d","a","c"]
What's your opinion ?
; ) )
Thanks for the suggestions, will add it to the description.
Is there a rule concerning out-of-bounds indices (eg
arr1=[1,2,3], arr2=[0,7,2]
) ?[1,3]
)[]
)"out-of-bound" may also mean
< 0
; ) )
Good point.
I think the function should ignore indices which are out of bounds but. For invalid input the function should just return [].
This comment has been hidden.
As it stands, out of bounds values in arr2 should be ignored while retaining the valid elements. For anything other than int's in arr2 the function should return empty. Will update the discussion and tests to reflect this.
Hi,
arr1 = []
and another witharr2 = []
(at least for arr2. For arr1, it will make the kata a small bit "harder")Thanks for the suggestions, will incorporate them.