• can somebody explain math behind it? how did you even came up with this solution?

  • It's a difficult question. What you need to learn depends on challenges you will face during the trial, your background in computer science, and programming skills. I don't know anything about that.

    It would be fine to address this question to the supervisor/manager/administrator/etc. of your preliminary trial. If it isn't possible, you may read any short guide about the C language, data structures and algorithms, for example: http://www.cs.yale.edu/homes/aspnes/classes/223/notes.html, chapters 4, 5, may be 3 (if you use Linux).

    But again, it's very difficult to give an advice without any knowledge about the trial, your background and skills.

  • Well thanks a lot !

    I have a 3 weeks preliminary trial in august, all in C, I won't be allowed to used library, only hand made code, so I'm trying my best to learn the best practice starting now. I went until the linked list and doing a makefile, would you have any other thing to recommand me to learn beforehand ?

    (sorry for any english error, I'm not a native speaker)

  • Hi,

    Your description of the solution is correct.

    Feel free to ask any questions, and good luck with learning the C language.

  • Hey, I'm a beginner in C, and I'm trying to understand your solution, can you tell me if I'm wrong somewhere ?

    You create an empty char, in which you put digits first char, then digits++ makes it so it's points to digits next char if there's one. It's your loop end condition, c being unable of changing value because digits doesn't have a next value.
    Then ternary condition to store the wanted value in buffer, that I get. It then advance buffer by one.
    The buffer = c part is only usefull in the last turn of the loop, to effectively put the \0 in buffer. For the previous turns of the loop, it puts digits value so 1-9, which then get erased by it's binary value (or \0)

    I have to say (beginner words), it's a great use of ++ after variables and pointers instead of before variables ! It confused me at first, but it's very logical in your code.

  • Yes, I've added one new test case (medved test) only. It's the only difference.

    And I've changed my own solution, of course.


  • Issue is resolved

  • The description of this kata doesn't specify the function call precedence. On the other hand, there aren't tests that depend on it. All tests can be successfully passed in both cases.

    So, you can choose any of these options (or implement two versions of the interpreter :) )

  • C translation has been published.

    Could anyone review and approve it, please?

  • C translation has been published.

    Could anyone review and approve it, please?

  • Please, correct me if i'm wrong: the C random tests always use the first test case only.

    In the cpp random tests i made it test all 7 test cases.

    Hope it's al'right.

    These 7 test cases have different levels of complexity so a time consumption of different tests varies widely (depends on an algorithm).

    In C translation is used only one test case as the basis of random tests to obtain a more stable total time consumption. This is important for 10 random tests.

    Of course, for a large number of tests, the total time consumption doesn't depend on the level of complexity of individual tests.

  • Thank you very much.

  • Approved, thank you.

    Keep in mind that if somebody has a slower solution, those differences will be magnified. If your solution takes double the amount of time for hardest vs simplest, theirs probably also will. So it does matter if you're running approx ten seconds. It might be the difference between ten and twenty.

    The difficulty of a rotated puzzle is different from the unrotated puzzle BTW. It's not intuitive, but order of hints apparently matters. The same puzzle takes me 218ms, 572ms, 103ms and 389ms without or with various rotations. Almost a factor 6! This can add up if you're unlucky.

  • Loading more items...