7 kyu
The Mark of Zorro
Loading description...
Arrays
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.
Fork with fixing the return value for the first example (resolving this issue)
The first example in the description is wrong, it should return {'a', 'b', 'c', 'e', 'h', 'k', 'n', 'o', 'p', 'q'}
Thanks for your feedback. Description fixed.
The constraints on types aren't clear. For example, are the matrix and row types indexable (or the can be something like a linked list), should the output use the same container type as either of the input types or not?
I added it to the description.
So are the rows guaranteed to be indexable?
Yes
You're using templates incorrectly.
template <typename T, typename M> T zorro(const M matrix)
is not a meaningful usage of template, it does not display anything in common betweenT
andM
, or whatT
andM
can do. Basicallyzorro<int, std::string>("oh no")
is also a valid usage of the template, but the code will explode as it assumesT
andM
arestd::vector<T>
andstd::vector<std::vector<T>>
respectively.If you're using templates, use it correctly. It should be
template <typanem T> std::vector<T> zorro(const std::vector<std::vector<T>> matrix)
.Thanks for your support, the issue is resolved now, I redo the template
Initial code is still
template <typename T, typename M> T zorro(const M matrix)
.Sorry, i forgot to fix this in the initial solution
[]
and[[]]
are completely different things; the former is 0x0 and the latter is 1x0, which is not a square.I solved this problem by putting an exception in the description --> "(except the empty ones, which should return an empty array).".
That's absurd: the only reasonable meaning for "empty" for a 2D matrix is
[]
, not[[]]
, unless you're willing to claim that[[],[]]
,[[],[],[]]
, etc are also empty.Ok, now is CORRECTLY solved