Ad
  • Custom User Avatar

    Updated the test organization, imported codewars_test instead of implicitly (which was deprecated since Python 3.8), and added assertions for only using digits and "()-=/" and 3 operators to the random tests.

  • Custom User Avatar

    Does this apply to translations too? (can I use integers?)
    Right now the open C++ translation uses floats, and the Python random tests use a less-than-epsilon type comparison for supporting float imprecision. If it's really not supposed to use intermediate floats, shouldn't it use the // operator in Python instead of the float / operator?

  • Custom User Avatar

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

  • Custom User Avatar

    There we go, I switched it to give the expected length as an argument so it's as easy as other languages while still allowing bounds checking if you want.

  • Custom User Avatar

    Good point with the static!

    aligned_alloc should allow the memory allocator to choose not to align it on the maximum struct alignment but instead a multiple of the alignment you specify. I had specified 1 because a char* string is made of bytes, but I'm pretty sure an alignment 4 or 8 would be easier for optimized library string handling functions to deal with.

    I removed the preallocation instead.

    A mix of both options would be to pass the expected length as a second parameter, so that the user doesn't need to calculate it themselves.

  • Custom User Avatar

    Looks good to me!

    a minor change might be to switch from mapM_ to forM_ so that the list isn't at the end of the line, and it would also let you avoid those parentheses

  • Custom User Avatar

    QuickCheck is fine, but there are only 10 cases, so exhaustive testing is better than entirely random for this.

    QuickCheck has a shuffle function of its own that you should probably use instead of an Arbitrary instance -- this would allow you to both ensure that all cases are tested and in a random order to prevent order-sensitive code from working.

  • Custom User Avatar

    Fixed it by matching on the character values (like c >= '0' && c <= '9')

  • Custom User Avatar

    it's usual to say both the user's answer and the expected result

    Otherwise it looks good!

  • Custom User Avatar

    why did you use "strin" instead of "str" or "string"?
    i suggest using the whole word 'string' when it's reasonable

    more importantly, why do the tests repeat so much code? you should write a function, macro, or template so it's easier to read and maintain

  • Custom User Avatar

    All I can think of is that sometimes people call 0 "Zed" instead; it's more common outside the US.

  • Custom User Avatar

    Solved with a wrapper function

  • Custom User Avatar

    Random tests added in C, C++, Java, and JavaScript.

  • Custom User Avatar

    the indentation for the normal test cases is inconsistent

    Also, you don't need to change it but can I suggest a solution based on fenwick trees for the random test solution? The code ends up being simpler, but I haven't checked if it's faster

  • Custom User Avatar

    How is this kata possible?

    From what I understand neither 2 nor 0 will work for any integer base...

    0: ""_1, 0_2, 0_3, 0_4, ...

    2: 00_1, 10_2, 2_3, 2_4, ...

  • Loading more items...