Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
C++ version: Signature is C-style, which discourages use of modern C++,
int **
is something you never ever should have to write in C++.Suggestion:
std::array<std::array<int, 4>, 4> solve(const std::array<int, 16>& clues)
Great, approved! :-)
Awesome! Would have merged it, but it says the latest changes from the record must be merged first?
@adri326: Comment was directed at @ZED.CWT, who appears to be losing patience with me, judging from the number of question marks. Thanks a lot for your suggestions, I've updated the kata.
It would have helped to mention that we're now discussing the C implementation, instead of the C++ implementation. :-(
Added a sentence in the summary.
I could not reproduce the origin problem. I have increased the number of tests by 10x and inserted an
assert(false)
in the case no valid origin was found both in the test fixture and my solution, still my tests run through just fine. I've also changed the complete solution to return(1,1)
instead in case no*
was found, so that my complete solution and my validation solution contradict each other -- again without effect. Any help reproducing this bug would be appreciated.In the meantime I've extended the wording in the description to include the valid origin assumption. I will also add a comment to the custom types to explain that they should be used in the solution.
I don't know what I'm doing wrong, I'm really not seeing these errors on my end. I've pressed re-publish several times now in the hope it'll change anything, but I have not means to check whether the code actually changed other than resetting my solution. If it does not work this time, I'll just stop wasting our time and withdraw it.
Nevertheless, thanks for testing, really! Please don't mistake my incompetence for reluctance to improve my kata, or even maliciousness.
Regarding the types: I'm sticking to the approach because this is a beginner's kata, and code wars is all about "production ready" code. I always encourage younger colleagues to use speaking names and concepts from the problem domain to name their types, classes, variables, etc. Many of the katas on code wars really disregard this aspect, using
std::vector<int>
to represent 2D coordinates,int
for things where negative values make no sense, and so on. Also, on the job you're seldom in a position to re-invent everything from scratch; chances are, you'll have to use predefined types likePos
andBoard
, whether you like it or not.Regarding the missing origins: I will investigate this right now; it should not have happened, my intention was that you may safely assume that there will always be a valid origin.
True, because it is not required; all test cases have valid points of origin.
Just checked it again, I can run the initial solution. Maybe you need to reset it to the current state?
Oh, so, do I understand you correctly: The initial solution was working until you removed code?
I'm sorry, I really took extra time to clean it up, but obviously I have zero idea how to test katas. ☹ In my preview the initial solution compiles just fine - any pointers how I could test offline, or at least preview how the website merges the different code parts? Not even the line numbers make any sense here.
Argh, dammit! Sorry, my first kata. Now it should finally work. 😅
Fixed.
Done.
Loading more items...