Ad
  • Custom User Avatar

    Thanks. Now I realize that I have just forgot to strip trailing spaces (or other white characters) when processing a line.

  • Custom User Avatar

    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?

  • Custom User Avatar

    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.

  • Custom User Avatar

    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:

            int[,] tab = GetGeneration(new int[,] { { 0, 0, 0, 1, 1, 1, 0, 1 }, { 0, 1, 1, 1, 1, 1, 1, 0 }, { 1, 0, 1, 1, 1, 0, 0, 0 } }, 2);
                                                     // the input array for initial game state                                      // number of generations to process
    
            for (int i = 0; i < m; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    Console.Write(tab[i, j]);
                }
                Console.WriteLine();
            }
            Console.ReadLine();
    

    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.

  • Custom User Avatar

    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 :-)

  • Custom User Avatar

    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

  • Custom User Avatar

    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.