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.
Understood. So in my move count this is move 20, and the next move would be Red inserting E3, finishing the line before Yellow can. I guess I know what to fix my implementation then, thank you so much! :-))
And of course you were right that this was no issue, it was an edge case!
I think that most likely, your solution incorrectly sees a Yellow diagonal from B1 to F5 on move 21:
you should try to test your function with moves.slice(0, 21) and see the result
I see that by mapping the object with input "colors" of each move to the object with insertion number of each move, so I cannot really log the changing state in my implementation. Also, my number counts all start from 0, including the insertion, so this might mislead if I try to put that into visuals.
Maybe I will double check again if I have any errors in my code, or try to check if there might be more random tests ahead that my function wouldn't pass either currently. I guess I took away too much time from you as well already.
Yeah sorry, my function exits as soon as there is a winner, this is why not all moves were represented. I did not remember that in this kata the game can keep going even though there is a winner already. I printed the full board and it is the same as yours, so it seems like your function fails to recknognize the winner at some point. Can you print the state of the grid as soon as you detect a winner ? You wrote in your first message that you see Yellow winning at move 20.
Sure, but you have different data! Maybe my wording was the problem: My input for the function is from the third kata of the basic test, but not the third of the "first round" tests.
The input is as mentioned above, which are all possible 42 moves, so you should not have empty slots.
(console.log([ 'F_Yellow', 'G_Red', 'D_Yellow', 'C_Red', 'A_Yellow', 'A_Red', 'E_Yellow', 'D_Red', 'D_Yellow', 'F_Red', 'B_Yellow', 'E_Red', 'C_Yellow', 'D_Red', 'F_Yellow', 'D_Red', 'D_Yellow', 'F_Red', 'G_Yellow', 'C_Red', 'F_Yellow', 'E_Red', 'A_Yellow', 'A_Red', 'C_Yellow', 'B_Red', 'E_Yellow', 'C_Red', 'E_Yellow', 'G_Red', 'A_Yellow', 'A_Red', 'G_Yellow', 'C_Red', 'B_Yellow', 'E_Red', 'F_Yellow', 'G_Red', 'G_Yellow', 'B_Red', 'B_Yellow', 'B_Red' ].length)
=== 42)
Here is the visualization:
Yellow wins with diagonal from B1 to G6
Red has two "opposing" diagonals:
One from C1 to G6, the other one in the opposing direction from G1 to B6.
You can't see the winner from this visualization, however. The fourth move in all lines is inserted in row 4 (the first row is at the bottom in this graphic). That is why I added the insertion order before.
Can you try to make a visual representation of the game board after all the moves have been played ? This is what i get:
Red wins by completing the diagonal from D to G.
My bad, I just assumed that if someone passes 205 tests, including all random tests, but fails on a single fixed test, you would sure want to have a look at it without much ado. Will pass more data below for better justification!
I understand that all previous solutions speak for themselves, but I thought people might also have updated the test suite, and could have introduced an error later. Is that not the case?
Below you can see a visualization of the filled board, first with the user handles, then with the order of insertion for each coin. As you can see from the data, Yellow has one winning line, while Red has two. The fourth inserted coin of Yellow's winning line is move no. 20, while Red only inserted his with move no. 21. Yellow wins on move 20, a diagonal.
Data:
User handles:
{
row: [
[
'Y', 'Y', 'R',
'Y', 'Y', 'Y',
'R'
],
[
'R', 'R', 'Y',
'R', 'R', 'R',
'Y'
],
[
'Y', 'Y', 'R',
'Y', 'R', 'Y',
'R'
],
[
'R', 'R', 'Y',
'R', 'Y', 'R',
'Y'
],
[
'Y', 'Y', 'R',
'R', 'Y', 'Y',
'R'
],
[
'R', 'R', 'R',
'Y', 'R', 'Y',
'Y'
]
],
col: [
[ 'Y', 'R', 'Y', 'R', 'Y', 'R' ],
[ 'Y', 'R', 'Y', 'R', 'Y', 'R' ],
[ 'R', 'Y', 'R', 'Y', 'R', 'R' ],
[ 'Y', 'R', 'Y', 'R', 'R', 'Y' ],
[ 'Y', 'R', 'R', 'Y', 'Y', 'R' ],
[ 'Y', 'R', 'Y', 'R', 'Y', 'Y' ],
[ 'R', 'Y', 'R', 'Y', 'R', 'Y' ]
],
diagonalUp: [
[ 'R' ],
[ 'Y', 'R' ],
[ 'R', 'Y', 'R' ],
[ 'Y', 'R', 'R', 'Y' ],
[ 'R', 'Y', 'Y', 'R', 'R' ],
[ 'Y', 'R', 'R', 'R', 'Y', 'Y' ],
[ 'Y', 'Y', 'Y', 'Y', 'Y', 'Y' ],
[ 'R', 'R', 'R', 'R', 'R' ],
[ 'Y', 'R', 'Y', 'Y' ],
[ 'Y', 'R', 'R' ],
[ 'Y', 'Y' ],
[ 'R' ]
],
diagonalDown: [
[ 'Y' ],
[ 'R', 'Y' ],
[ 'Y', 'R', 'R' ],
[ 'R', 'Y', 'Y', 'Y' ],
[ 'Y', 'R', 'R', 'R', 'Y' ],
[ 'R', 'Y', 'Y', 'Y', 'R', 'Y' ],
[ 'R', 'R', 'R', 'R', 'R', 'R' ],
[ 'R', 'R', 'Y', 'Y', 'Y' ],
[ 'Y', 'Y', 'R', 'R' ],
[ 'R', 'Y', 'Y' ],
[ 'Y', 'R' ],
[ 'Y' ]
]
}
Insertion order:
{
row: [
[
4, 10, 3, 2,
6, 0, 1
],
[
5, 25, 12, 7,
11, 9, 18
],
[
22, 34, 19, 8,
21, 14, 29
],
[
23, 39, 24, 13,
26, 17, 32
],
[
30, 40, 27, 15,
28, 20, 37
],
[
31, 41, 33, 16,
35, 36, 38
]
],
col: [
[ 4, 5, 22, 23, 30, 31 ],
[ 10, 25, 34, 39, 40, 41 ],
[ 3, 12, 19, 24, 27, 33 ],
[ 2, 7, 8, 13, 15, 16 ],
[ 6, 11, 21, 26, 28, 35 ],
[ 0, 9, 14, 17, 20, 36 ],
[ 1, 18, 29, 32, 37, 38 ]
],
diagonalUp: [
[ 31 ],
[ 30, 41 ],
[ 23, 40, 33 ],
[ 22, 39, 27, 16 ],
[ 5, 34, 24, 15, 35 ],
[ 4, 25, 19, 13, 28, 36 ],
[ 10, 12, 8, 26, 20, 38 ],
[ 3, 7, 21, 17, 37 ],
[ 2, 11, 14, 32 ],
[ 6, 9, 29 ],
[ 0, 18 ],
[ 1 ]
],
diagonalDown: [
[ 4 ],
[ 5, 10 ],
[ 22, 25, 3 ],
[ 23, 34, 12, 2 ],
[ 30, 39, 19, 7, 6 ],
[ 31, 40, 24, 8, 11, 0 ],
[ 41, 27, 13, 21, 9, 1 ],
[ 33, 15, 26, 14, 18 ],
[ 16, 28, 17, 29 ],
[ 35, 20, 32 ],
[ 36, 37 ],
[ 38 ]
]
}
why should we investigate if you are not even sure that the expected result is wrong ? have you played the moves manually to check ? there have been close to 1100 completions in JavaScript, the odds of a fixed test being wrong are very small. please provide more evidence before opening an issue (or ask a question instead)
The third basic test seems odd, is there an error in the test suite data possibly?
Passed in data :
[ 'F_Yellow',
'G_Red',
'D_Yellow',
'C_Red',
'A_Yellow',
'A_Red',
'E_Yellow',
'D_Red',
'D_Yellow',
'F_Red',
'B_Yellow',
'E_Red',
'C_Yellow',
'D_Red',
'F_Yellow',
'D_Red',
'D_Yellow',
'F_Red',
'G_Yellow',
'C_Red',
'F_Yellow',
'E_Red',
'A_Yellow',
'A_Red',
'C_Yellow',
'B_Red',
'E_Yellow',
'C_Red',
'E_Yellow',
'G_Red',
'A_Yellow',
'A_Red',
'G_Yellow',
'C_Red',
'B_Yellow',
'E_Red',
'F_Yellow',
'G_Red',
'G_Yellow',
'B_Red',
'B_Yellow',
'B_Red' ]
According to my function, Yellow's winning move is no. 20, while Red only finishes the line of 4 with move no. 21, so Yellow should have won. However, the test suite expects Red to have won.
My function is passing 205 other tests.
me too 😭
thank you!
Yes, it is possible. You need to find a way without arrow functions and without keywords.
I am confused, is this actually possible in JS? Line breaks between an arrow functions parameter list and the fat arrow symbol are forbidden, and keywords spread to multiple lines become variables.
It's been veeery long ago :-))) Thank you for explaining the rule book, @B1ts! 🙏
Have you played poker? :P In this case it's point #3. 5 cards are involved in final ranking, and in this case it's the last card that matters (5 > 4), as the pair and 2/3 high cards were equal (suit doesn't matter in this example).
Loading more items...