Ad
  • Custom User Avatar
  • Custom User Avatar
  • Default User Avatar
  • Default User Avatar

    python fork to address poor quality test cases (which affects ALL languages, but I'm fixing python at least)

    for example, as I post this, the two latest solutions are both wrong: a, b - it's kind of silly how the tests are failing to catch very common problems, and it lets down solvers that are genuinely solving it themselves instead of trivializing it with built-in functionality

    my fork generates reasonably exhaustive tests (instead of randint) for lengths 4 and 5 which will catch close to all unintentionally incorrect solutions.

  • Default User Avatar

    Yeah, I had a look at python solutions and if I ignore the solutions that trivialize the kata with builtins, incorrect solutions are common.

    It's a beginner kata, it should catch beginner mistakes, and this task makes it easy to create a slightly wrong solution that naive random tests don't catch.

    I suggest adding these 75 exhaustive size-4 fixed tests to all languages (gotta love how each language has its own code):

    import itertools
    
    def rename(xs):
        # my implementation is probably smooth-brained
        keys = itertools.count(1)
        known = {}
        out = []
        for x, i in sorted((x, i) for i, x in enumerate(xs)):
            if x not in known:
                known[x] = next(keys)
            out.append((known[x], i))
        return tuple(x for (x, i) in sorted(out, key=lambda xi: xi[1]))
    
    size = 4
    xs = list(map(list, set(itertools.chain(*map(itertools.permutations, set(map(rename, itertools.combinations_with_replacement(range(1, size+1), size))))))))
    print(xs)
    print(len(xs))
    
    [[1, 1, 1, 1], [1, 1, 1, 2], [1, 1, 2, 1], [1, 1, 2, 2],
     [1, 1, 2, 3], [1, 1, 3, 2], [1, 2, 1, 1], [1, 2, 1, 2],
     [1, 2, 1, 3], [1, 2, 2, 1], [1, 2, 2, 2], [1, 2, 2, 3],
     [1, 2, 3, 1], [1, 2, 3, 2], [1, 2, 3, 3], [1, 2, 3, 4],
     [1, 2, 4, 3], [1, 3, 1, 2], [1, 3, 2, 1], [1, 3, 2, 2],
     [1, 3, 2, 3], [1, 3, 2, 4], [1, 3, 3, 2], [1, 3, 4, 2],
     [1, 4, 2, 3], [1, 4, 3, 2], [2, 1, 1, 1], [2, 1, 1, 2],
     [2, 1, 1, 3], [2, 1, 2, 1], [2, 1, 2, 2], [2, 1, 2, 3],
     [2, 1, 3, 1], [2, 1, 3, 2], [2, 1, 3, 3], [2, 1, 3, 4],
     [2, 1, 4, 3], [2, 2, 1, 1], [2, 2, 1, 2], [2, 2, 1, 3],
     [2, 2, 2, 1], [2, 2, 3, 1], [2, 3, 1, 1], [2, 3, 1, 2],
     [2, 3, 1, 3], [2, 3, 1, 4], [2, 3, 2, 1], [2, 3, 3, 1],
     [2, 3, 4, 1], [2, 4, 1, 3], [2, 4, 3, 1], [3, 1, 1, 2],
     [3, 1, 2, 1], [3, 1, 2, 2], [3, 1, 2, 3], [3, 1, 2, 4],
     [3, 1, 3, 2], [3, 1, 4, 2], [3, 2, 1, 1], [3, 2, 1, 2],
     [3, 2, 1, 3], [3, 2, 1, 4], [3, 2, 2, 1], [3, 2, 3, 1],
     [3, 2, 4, 1], [3, 3, 1, 2], [3, 3, 2, 1], [3, 4, 1, 2],
     [3, 4, 2, 1], [4, 1, 2, 3], [4, 1, 3, 2], [4, 2, 1, 3],
     [4, 2, 3, 1], [4, 3, 1, 2], [4, 3, 2, 1]]
    

    (maybe they need to be renamed again so the answer isn't always either 2 or 3)

    size-5 lists might have some limited value too, there are 541 of those though.

  • Default User Avatar

    This test was really well done. Gave me a good mental workout and really made me have to think about how to get the logic to work.

  • Custom User Avatar

    lol, i really struggled to understand the instructions (my bad, im dumb) which made this a lot harder than it should have. learned some new things too! I like.

  • Default User Avatar

    Less padding in the description please. It's nice to know, but maybe after the question.

  • Custom User Avatar

    Approved by Johan

  • Custom User Avatar

    calling the parameter "sperm" 🤣🤣

  • Custom User Avatar

    Use the numbers stated in the kata's description. Where did you get that 0.354 factor? Not a kata issue.

  • Custom User Avatar

    Doesn't work for random values in Python.
    For example, for mpg 8540, my solution gives 3023.16. It fails saying the right answer should be 3023.21.
    Why this is failing?

  • Custom User Avatar
  • Default User Avatar
    • you have an extraneous end at the end of your program which makes it ill-formed
    • you need to return the function that you wrote and which solves the kata at the end of your program. currently, you are returning an empty table solution that you created, hence why the tests cannot run properly
  • Custom User Avatar

    Poorly written- the way it is worded and calling the parameter "sperm" suggests the argument is going to be "X" or "Y". It should be rewritten to make it clear that we are evaluating the chromosome pairs

  • Loading more items...