• When my solution timed out - I started to focus on a mathematical solution.
    A great excercise. I (re)learned a lot. Thanks!

  • nice code, clean :)

  • But then where in buffer will the char be put? Either buffer must be increased, or you need an index variable.

    Edit: oh wait, you're saying in addition to.

  • The null character '\0' is represented by the byte 0. I prefer to be explicit by using a char literal, but using a plain 0 is fine as well.

  • Very elegant !! Nice, etc...

  • I highly agree with you man. This also tripped me off. I just posted a suggestion regarding this.

  • Although we can figure out the input and output from the examples, it'll be much better if you also describe it verbosely. This gets worse when there is an inconsistency between the fixed test and the random test.

    In the fixed test case, the input are always an array with 2 items, as if the first item represents the X player and the second item represents the Y player. But in the random test, the array are bigger than 2 items. This won't be a problem if you have mentioned it beforehand.

  • I was pleasantly surprised to see that the solution I thought would be considered an inefficient "naive" approach seems to be a pretty popular one, since I seem to be unfamiliar with advanced string manipulation/creation in C++.
    Mine is pretty much the same, just with some minor formatting differences

  • I had the same idea using stringstream, operator+ will allocate and is usually a no-no when working with large strings.
    The compiler can optimize string literals but this doesn't extend to dynamically allocated strings.

    Unfortunately stringstream suffers from the same problem. Since memory must be allocated every operator<< (might even be slower).
    Therefore i don't think it matters (mutch) performance wise.

  • Good kata, but i think difficulty level higher than 6kyu :)

  • For a performance kata the input size should be specified. What is the length of the input?

  • I never said it didn't. But I also stated the truth.

  • I am a beginner in C but as much as my knowledge goes '\0'(known as a null character) is used to terminate a string.

  • Loading more items...