Ad
  • Custom User Avatar

    i got the same error my friend, i didn't face any problem when i wrote the same algorithm in javascript

  • Custom User Avatar

    Ah, good idea - I'll give it a shot - thanks again for taking the time to respond, much appreciated :)

  • Custom User Avatar

    Ah, you're right, sorry! I just ran the whole code.
    You can try different approaches to improve the performance. Maybe something like building the entire field and then replacing only the right indexes of each row with the other symbol.
    Or use only one for loop to build the different lines :)

  • Custom User Avatar

    Hey Zruf - thanks for the resposne
    Without giving too much away - How can I make this more efficient then?
    I would have thought a nested for loop wouldn't be that impactful and on a similar Kata a nested for loop worked fine.
    Also the code above shouldn't be printing two times? The System.Console.writeline is commented out so it only ever "returns" - not sure why it would be printing twice

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    I may be misunderstanding the question - but you do know the contents of the array, as this is passed into the function you are making.

    Arrays can be accessed in most languages like so - assumeing I have an array called "MyArray"

    MyArray[0] - this would grab the first value of the array, MyArray[2] would grab the 3rd and so on.
    You can find the length of the array in - for example C#, by using MyArray.Length

    So with this in mind, you should be able to loop through an array and find the max sum

    I agree with the poster above me - it would help to draw an array on a piece of paper, and figure out how you would do this manually.