Ad
  • Custom User Avatar

    awesome! it's been so long since I wrote this I'd completely forgotten about it. thanks for adding Python (one of my favorites)!

  • Custom User Avatar

    The expected result should be 0.2. The affinity, for this exercise, considers both values and their indices.

  • Custom User Avatar

    yonax, you uncovered a nasty bug. I have fixed it and added the test cases discussed above to the kata.

  • Custom User Avatar

    This was due to an issue in my logic for solving the problem. It has been corrected, and the kata has been republished.

    To confirm,

    vector_affinity([None], []) == 0.0 => True
    
  • Custom User Avatar

    I am republishing the kata now, with this issue resolved.

  • Custom User Avatar

    Yes, I will file this as an issue.

    The problem is that the solution is looking for equality in the terms of each vector.
    Comparing None to a non-existent value will equate to True since they are both NoneType.

  • Custom User Avatar

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

  • Custom User Avatar

    no real reason. probably still mentally stuck in if/else syntax from other languages. if I were to write the solution again, I would likely use if

  • Custom User Avatar

    easy enough, but then shouldn't i also add:

    test.assert_equals(vector_affinity([None], [None, None, None, None]), .25)
    test.assert_equals(vector_affinity([None], [None, None, None, None, None]), .5)
    test.assert_equals(vector_affinity([None], [None, None, None, None, None, None, None, None, None, None]), .10)
    

    ?

    To me knowing that:

    vector_affinity([None], [None]) == 1.0
    # and
    vector_affinity([None], []) == 0.0
    

    should be enough to deduce that None is also a value that counts, and that [None]/[None, None] gets a .5 affinity.
    again, it's easy enough to add the test case, but unless that test case addresses a specific flaw in the instructions or problem, i'm hesitant to do so.

  • Custom User Avatar

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

  • Custom User Avatar
  • Custom User Avatar

    had to unpublish, save, then re-publish. the provided tests should be working properly now.

  • Custom User Avatar

    Sorry, I've been trying to update that all day, but every time I try to "re-publish" the kata with the corrected test cases, it never finishes, just sitting at about 99% for as long as I'm willing to let it go.

    I am working on getting that fixed.

  • Custom User Avatar

    I think the ratio/float thing is trivial enough. The point of the kata is to return a float that indicates how similar two vectors are. In practical application, if a ratio were needed, it wouldn't be an issue to remove the float conversion.

  • Custom User Avatar

    mtthw123, after typing that bit a few times, and feeling like it was giving too much away, I ended up adding a couple more example test cases, one in which the vectors were not same-length, then mention that it holds a clue to the correct solution (or a correct solution).

    (= (vector-affinity [6 6 6 6 6 6] [6]) (float (/ 1 6))

    Just since here obviously the second vector is shorter, and the equality to (float (/ 1 6)) illustrates that the larger of the two is used as the denominator.

    What are you thoughts on that?

  • Loading more items...