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.
There are 20000 JS tests in total, your code handles about half of them, I have run it several times - the result is
10_000 - 12_000
. To be honest, I haven't looked closely at your code and can't tell you exactly what the problem is, but your algorithm needs to be improved. However, before you change anything, maybe you can add caching for some “heavy” calculations (if there are any and it is possible), it might work.I managed, not without difficulty, to find a solution to this Kata!
But I can't get past the random tests...
Code Wars gives me a timeout before the tests are finished.
I didn't use a brute force algorithm; the algorithm solves a puzzle in an average of 1ms, so I don't know what more I can do...
(Tests done in JS.)
I came back to it a month later, and re-wrote the solution and it worked. Really good Kata
How many tests are there in the random tests?
I have a solution that keeps timing out after about 10,000 tests, and I'm struggling to make it more efficient. There's no brute force in my solution.
It would be nice to know if it needs to get 10% or 100x more efficient
The question I want to ask is, whether this kata can be solved by pure logic instead of relying on algorithms to "try to get" a possible result?
In the sample test, I tried to use logic to infer the possibility of each cell. The final best result was to identify the leftmost and rightmost cells of the first row as C and E (and I was not sure which was C or E).
The rest parts can only rely on algorithms, not logic. In that case, I decided to give up.
If there is a better logical inference, please give me some tips, because I am stupid. O_o
Fixed
JavaScript translation
The Markdown on the Clues section are messed up. They should be fixed ;-)
For a new pple, exceptions should be created outside
SoulutionTest.class
like a regular multiple classes in one file."Left of" clues mean that s1 is in any column that is to the left of the colum s3 is in. (I hadn't noticed the example didn't make that clear as both left of clues are to the immediate left, but that is not a constraint). In other words, using A < Q and given that Q is in column 4, then A may be in columns 0,1,2, or 3.
"Next to" clues mean that the two object are in columns that are directly next to each other. So in the case of AQA and given Q is in column 2, then A must be in column 1 or 3.
Regarding the description; there's some ambiguity, could you clarify the description?
a. "Left of" clue: "This clue means that s1 exists in a column to the left of the column containing s3 --> This does not mean they are necessarily next to each other"
Is that the immediate left of the column containing s3, or any column to the left of s3?
Does "next to each other" mean "next to each other in the same row"?
b. "Next to" clue: " This clue means that s1 exists in a column next to the column containing s2"
Does this mean the immediate left or right of the column containing s2, or any column to the left of right of s2 (i.e. "not the same column as s2")?
Thanks!
This comment is hidden because it contains spoiler information about the solution
Did you find the solution/answer for this. I have the exact same question.
Loading more items...