@Olegkovtun - Wow, that one is great. Very clever, efficient, readable, and understandable. I am super impressed with yours.
The chosen answer above is clever in that it uses very few lines but it fails in the other 3 categories so I am not sure why some people voted it as a best practice.
I submitted my solution for Java and the moreRandomTests failed. I manually checked and my code is correct, it is the expected solution that is wrong. This one expects false -
There is way too much code for this simple problem. The first function is completely pointless. I can understand the train of thought of creating the final function for readability, but the actual implementation falls short because of poor naming. Boolean functions should be in question form, aka isEven(int number)
Very nice, compact solution. Can you please explain the first collect operation? I am not following the logic of the groupingsBy with the identity and counting.
He is using a filter operation. If he was using the map then you would be correct, the ' would be replaced with nothing and his test would fail. But the filter only checks the condition, it does not modify the input.
Barely readable but very clever
Where does this one validate the 3x3 squares?
@Olegkovtun - Wow, that one is great. Very clever, efficient, readable, and understandable. I am super impressed with yours.
The chosen answer above is clever in that it uses very few lines but it fails in the other 3 categories so I am not sure why some people voted it as a best practice.
This comment is hidden because it contains spoiler information about the solution
I guess the test is done randomly because after testing it again, I fail on a different array each time that incorrectly expects false -
4 5 9 3 7 2 8 6 1
2 3 7 1 5 9 6 4 8
9 1 5 8 3 7 4 2 6
3 4 8 2 6 1 7 5 9
1 2 6 9 4 8 5 3 7
5 6 1 4 8 3 9 7 2
8 9 4 7 2 6 3 1 5
7 8 3 6 1 5 2 9 4
6 7 2 5 9 4 1 8 3
and
3 8 7 1 4 9 2 5 6
6 2 1 4 7 3 5 8 9
9 5 4 7 1 6 8 2 3
5 1 9 3 6 2 4 7 8
2 7 6 9 3 8 1 4 5
4 9 8 2 5 1 3 6 7
7 3 2 5 8 4 6 9 1
1 6 5 8 2 7 9 3 4
8 4 3 6 9 5 7 1 2
I submitted my solution for Java and the moreRandomTests failed. I manually checked and my code is correct, it is the expected solution that is wrong. This one expects false -
4 5 6 8 9 7 1 2 3
7 8 9 2 3 1 4 5 6
1 2 3 5 6 4 7 8 9
8 9 1 3 4 2 5 6 7
2 3 4 6 7 5 8 9 1
5 6 7 9 1 8 2 3 4
6 7 8 1 2 9 3 4 5
9 1 2 4 5 3 6 7 8
3 4 5 7 8 6 9 1 2
There is way too much code for this simple problem. The first function is completely pointless. I can understand the train of thought of creating the final function for readability, but the actual implementation falls short because of poor naming. Boolean functions should be in question form, aka isEven(int number)
This comment is hidden because it contains spoiler information about the solution
Very nice, compact solution. Can you please explain the first collect operation? I am not following the logic of the groupingsBy with the identity and counting.
He is using a filter operation. If he was using the map then you would be correct, the ' would be replaced with nothing and his test would fail. But the filter only checks the condition, it does not modify the input.
Wow, so much less code than my solution lol. Very nice!
This comment is hidden because it contains spoiler information about the solution