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.
Thanks. Now I realize that I have just forgot to strip trailing spaces (or other white characters) when processing a line.
I get the following failing result (for Java solution):
expected:<a[
b
c]> but was:<a[
b
c ]>
Description of this kata says: "Any whitespace at the end of the line should also be stripped out".
However, I assume that 'c ]>' is the whole line, and the ']' and '>' are not comment symbols in this case. Is it true?
If so, I see no reason why the space after the 'c' character should be trimmed.
Could somebody explain this problem?
Ok, thanks for information. Now I know that the output array must be extended so that the living cells are not lost by going out of initial array's bounds.
I receive quite strange output results (C#, Visual Studio Community 2019):
TestGliders:
011
100
001
Number of generations = 0
Number of generations = 1
Number of generations = 2
Test Failed
Output doesn't match expected
Expected and actual are both <System.Int32[3,3]>
Values differ at index [0,0]
Expected: 0
But was: 1
TestTwoGliders
00011101
01111110
10111000
Test Failed
Output doesn't match expected
Expected is <System.Int32[3,8]>, actual is <System.Int32[11,16]>
Values differ at expected index [0,2], actual index [0,2]
Expected: 0
But was: 1
Completed in 0.8650ms
Actually, when I write the output array out on my computer:
I get:
Glider - 0 generations:
011
100
001
Glider - 1 generation:
010
001
000
Glider - 2 generations:
000
000
000
Two gliders - 0 generations:
00011101
01111110
10111000
Two gliders - 1 generation:
00000000
01000010
00000000
Two gliders - 2 generations:
00000000
00000000
00000000
Everything is correct in terms of Conway's Game of Life.
I have no idea what's wrong with my code, especially where that <System.Int32[11,16]> came from.
My solution (C#, Visual Studio 2019) passes all test cases except the final one.
Now I fear that I will need to do a lot of guessing and experimenting (by changing coefficients, boundary values and other variables) by trial and error until I discover what exactly the final test could have. For now - no idea.
Nice and very challenging kata, where I used some statistical computations, finding out gaps between lengths of substrings, computing optimal word, or character length in message and adding a lot of manual safeguards for various types of short messages.
But let us see whether I manage to solve the final test or just become exhausted and forced to give up...
EDIT: Yeah, after some experiments I have managed to solve this exciting kata :-)
My solution fails on codewars.com in 5 cases, but on my computer they work correctly:
Case 7:
System.FormatException: Input string was not in a correct format.
Result on my computer (C#/Visual Studio 2019 Enterprise): 1
Case 14:
Test Failed:
Expected: 21.25d
But was: 1432.0d
Result on my computer: 21,25
Case 17:
Test Failed:
Expected: 7.7320000000000002d
But was: 0.17380000000000001d
Result on my computer: 7,732
Case 18:
Test Failed:
Expected: 7.4562499999999998d
But was: 3.2562506d
Result on my computer: 7,45625
Case 19:
System.FormatException: Input string was not in correct format
Result on my computer: -12042,760875
I agree with predecessors. This solution is not very good in terms of performance for some nastily chosen input data.
Consider n = 10999999999 and try to see how long your 'for' loop would take to reach 19099999999.