Ad
  • Custom User Avatar

    thats what i thought as well. thats why i dont understand why this solution works ^^

  • Custom User Avatar

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

  • Default User Avatar
  • Custom User Avatar

    I agree with you. I think the most acceptable is to test on shuffled range(1,51).

  • Default User Avatar

    the towers and their representations are dynamically allocated, so there is no stack buffer anywhere. the "random" tests in JS do 1...100 without shuffling, which i did not like because as you said it's not random. so the considerations were 1) not printing gigantic pyramids that will be unreadable and 2) i dont see how a solution could be correct for 1..50 and incorrect for larger n. tell me which scheme you would prefer for the random tests and i will do it

  • Custom User Avatar

    Sorry to bother you again :P

    100 random tests for input inferior or equal to 50, isn't it a bit overwhelming? I see several other languages just test all towers from 1 to 100 (which is not random... but well), I don't know if it's possible to increase the range in C sufficiently to have real-and-not-too-redundant random tests? I understand there may also be a buffer issue... If 50 is actually the max reasonnable for buffer (I think it's enough to check the validity of a solution, it's prolly harder to hardcode 50 towers than to just solve the kata...), maybe just test all numbers shuffled in range 1..50?

  • Default User Avatar
  • Custom User Avatar

    Is the #include <stdlib.h> in setup here for something ? It works fine without it.

  • Default User Avatar

    i removed the nul-terminator. a matrix of chars is not the same thing as an array of strings. i left a comment in the initial code and the subarrays' length should also make it self-evident

  • Default User Avatar

    but since it's a matrix it cannot be displayed without a custom function anyway. and this function has to know the number of rows and columns in advance, so the nul char is not needed

  • Custom User Avatar

    This basically boils down to a question: is a char array in question a string, or is it not? Is it just a byte buffer? Something else?

    I would say that in this kata it's expected to create an ASCII-art type of output, so I think that having null-terminated c-strings conforms to the principle of least surprise.

  • Custom User Avatar

    In my understanding it is pointless, but my understanding is poor so... :D Ping me when you're done.

  • Default User Avatar

    to be honest i'm not sure if it really makes sense either. i guess i'll remove it

  • Custom User Avatar

    Looks good. Another newbie question: why should static char arrays be null terminated?

  • Default User Avatar

    merge conflict + translator gone, forked

  • Loading more items...