Ad
  • Custom User Avatar

    Sorry, I have mistaken the direction of rot and call my procedure 4rot wrongly. It should be named 4rdown, which is exactly what the R down key does in HP 4-level RPN calculators.

  • Custom User Avatar

    Because set is quicker. However, even this code is not fully optimised.

  • Custom User Avatar

    I have seen your updated description. In this description, it still seems that you mean to correspond 1 <--> 00, 2 <--> 01, 3 <--> 10, 4 <--> 11. Then how am I supposed to add 0, 0, and 0? If the bits are parts in your 2-bit code, the summation is pointless (because the 2-bit code is not defined in a usual way, and you must also define the rules of addition again).

    I guess that there are at least two possible interpretations:

    1. The corresponding rules are mis-written. They should be 0 <--> 00, 1 <--> 01, 2 <--> 10, 3 <--> 11. That is how the common binary numbers are defined. If you mean this, could you please consider to change '1, 2, 3, 4' to '0, 1, 2, 3' in your kata description?

    2. Otherwise, probably the bits are added in the common way. Since the sum lies in 1..3, the sum is encoded in your current version of corresponding rules. However, in your test case, the sum 0 <--> expected result [0, 0]; this interpretation is not OK in the current state.

  • Custom User Avatar

    Sorry for the inconvenience for all the C trainees.

    I have fixed it according to your suggestion by adding an extra piece of information.

    Since cr_assert does not accept char[] as argument (only string literal), it takes me some time to fix the tests up.

  • Custom User Avatar

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

  • Custom User Avatar

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

  • Custom User Avatar

    Well, I have proven my guess for a simple solution. The proof is easy enough to be understood by a pupil in his/her fifth or sixth grade.

    If you also discover it, please discuss it in the discourse, but do not forget to set 'spoiler content' here.

    ============================================

    Well, since the solution is proven, I use it in the judgement in the C version.

  • Custom User Avatar

    Although in the description, the 'lowest possible value' for z s.t. z % 13 == 10 is 25 (so that the answer will be 7), it is not the case.

    The lowest possible value do not exist if you just restrict z, x, y being integers. The integer z could be negative, and as small as possible [if the definition of the remainder r being a = bq + r where 0 <= r < abs(q) is applied; I know sometimes the operator % behaves differently when negative integers are involved] -- so do not forget to add positive in the kata description.

    Even z is restricted to be positive, its 'lowest value' is still not 25 in the example. It has to be 10, because 10 % 13 == 10 and any number in 1..9 does not rest 10 if divided by 13. So please do not forget to restrict again z > x.

  • Custom User Avatar

    Sorry, but mistyped ...59230 as 95230. I recite pi as tones, so there are sometimes confusions...

  • Custom User Avatar

    This solution imitates how a child learns new things.

    He / she learns 1 first.
    If necessary, he / she then learns 3. Then 5. And so on.

  • Custom User Avatar

    I am sorry, but your test cases failed to count the factors in the way as in the kata description. Please consider to revise them so that at least they agree.

    For example, in your case of 297, the factors that you want to count is

    3 9 11 27 33
    99 
    

    There is still 1 and 297, but they are not expected to be counted, as you said

    (not considering 1 and the integer 23400 itself)

    Thence the second item of the answer should be 6, instead of your given 7.

    UPDATE

    I found your definition of 'total divisors' (= prime + compound) agree with the test cases. All you need to change is the list in the example of 23400 in your kata description.

  • Custom User Avatar

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

  • Custom User Avatar

    Perhaps the author could consider to state the rules of splitting the message as follows.

    1. If len(message) is divisible by 5, just equally divide the message into 5 pieces. Otherwise, apply the following rules.
    2. Part 1 to 4 (both incl.) must be of the same length.
    3. Part 5 must be not longer than other parts.
    4. Part 5 must be the longest provided the split does not break Rules 2 and 3.

    All the confusions appear because in the kata description, Rule 2 is vague, implicit and confusing, not written out explicitly.

    A trivial algorithm to the solution might be ... allocate Part 1 to 5 with n // 5, and add all the leftovers to Part 5. If Part 5 is longer, do Operation One: reduce 4 from Part 5 and add each of them to each of Part 1 to 4. If still longer, continue Operation One. [Here I am only talking about the length of each part, not referring to the characters themselves. ]

    If at least one solution exists, the algorithm will not break all the rules.

    However, the rules are contradicting each other if n is a certain value.

    Since Part 5 initally contains n // 5 + n % 5 chars, if (n % 5 is not 0) and (n // 5 + n % 5 < 4), the rules will crash.

    That means n should not be 1, 2, 3, 6, 7, and 11.

  • Custom User Avatar

    But, thence, 16 would be [4, 3, 3, 3, 3] instead of the given [4, 4, 4, 4, 0].

    Also, I cannot derive the split [4, 4, 4, 4, 0] given the rules. It breaks the rule 'the fifth part has the longest length'.

  • Custom User Avatar

    Thanks for the kata, where I just learned the colour of number 7 is violet, not purple.

  • Loading more items...