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.
Elm Translation: https://www.codewars.com/kumite/5c12c0bdb6128260660001c4?sel=5c12c0bdb6128260660001c4
Elm Translation: https://www.codewars.com/kumite/5c11329e85e9fff2bc000005?sel=5c11329e85e9fff2bc000005
Elm Translation: https://www.codewars.com/kumite/5c09cb60a8af37fef600020a?sel=5c09cb60a8af37fef600020a
This comment is hidden because it contains spoiler information about the solution
Elm translation: https://www.codewars.com/kumite/5c05e5464f380311c4000099?sel=5c05e5464f380311c4000099
I have added random tests. However, this experience has turned me off to contributing to this community in this way.
What is the value of unit tests?
Is the value of unit tests to enforce behavior? To some degree, yes. It's valuable to arrive at a problem with a suite of tests that will help you validate your new implementation meets all the known requirements. But if the tests enforce a single implementation, they are of less value to me as an engineer.
Say that I were an employer, who needs to build a system, and for whatever reason, there is a test suite already available that evaluates for the behavior my company is looking to build. Maybe the suite is in a different language than the target language for my project, and the suite can be easily ported. Then, say that I give the engineers on my team this test suite, expecting them to use it to guide their implementation. And, say that they use it to code up an "implementation" such as the one you have written, and then they snicker behind my back, for the whole of the two minutes that it takes for said "implementation" to fail catatstrophically when invoked to solve an actual problem in production.
My expectation was that they would apply a level of rigor to their production code, that they would, as responsible engineers, provide solutions that actually attempt to solve my problem. I provided them a test suite because I thought it would benefit them in their work, not because I believed the output of my test harness to be the word of god.
Fortunately, nothing we write here is production code; everything here is ad hoc and open. But still, the question begs to be answered: What is the value of tests?
This solution upset me because I feel it degrades the real value of tests. The real value of tests is the tension it provides between the production code's design and the requirements. I wrote the initial tests for this problem assuming that others would approach this problem from a similar mindset – that we would use the tests as helpful scaffolding, not as enemy code to be thwarted and subverted.
So, here are your random tests. Tests, which, by definition, must utilize my own implementation in order to function. Tests, which, by virtue of their existence, lock out some number of solutions which actually solve the problem, but fail to conform precisely to my particular implementation. I now cannot be pleasantly surprised by an implementation. The random tests will make sure that such implementations are unsubmittable.
All communities survive because their members can trust one another. This initial foray into kata creation has damaged the amount of trust I place in members of this community. I hope that this is an isolated inicident.
TypeScript translation posted.
My first implementation worked similarly to this, but I couldn't pass as I was blowing the heap on the test runner. Now I wish I had my original code so I could compare that to this.
Thank you!
TypeScript Translation added!
This comment is hidden because it contains spoiler information about the solution
Something weird going on. When I hit "attempt", I get back the following message:
Expected 'true' on input of
- Expected: true, instead got: false✘ Expected 'true' on input of - Expected: true, instead got: false
However, when I copied the contents of those messages and pasted/formatted them into my test harness as such:
Test.assertEquals(validSolution([[5, 3, 4, 6, 7, 8, 9, 1, 2],
[6, 7, 2, 1, 9, 5, 3, 4, 8],
[1, 9, 8, 3, 4, 2, 5, 6, 7],
[8, 5, 9, 7, 6, 1, 4, 2, 3],
[4, 2, 6, 8, 5, 3, 7, 9, 1],
[7, 1, 3, 9, 2, 4, 8, 5, 6],
[9, 6, 1, 5, 3, 7, 2, 8, 4],
[2, 8, 7, 4, 1, 9, 6, 3, 5],
[3, 4, 5, 2, 8, 6, 1, 7, 9]]), true);
Test.assertEquals(validSolution([[8, 2, 6, 3, 4, 7, 5, 9, 1],
[7, 3, 5, 8, 1, 9, 6, 4, 2],
[1, 9, 4, 2, 6, 5, 8, 7, 3],
[3, 1, 7, 5, 8, 4, 2, 6, 9],
[6, 5, 9, 1, 7, 2, 4, 3, 8],
[4, 8, 2, 9, 3, 6, 7, 1, 5],
[9, 4, 8, 7, 5, 1, 3, 2, 6],
[5, 6, 1, 4, 2, 3, 9, 8, 7],
[2, 7, 3, 6, 9, 8, 1, 5, 4]]), true);
The above passes when I "run examples."