The function should return a set, but the test code assumes it is a list.
Another thing I do not understand is: I intentionally discard the original word to trigger this bug. If do not discard it, I have 18 tests passed but 2 failed. This function just calls previously implemented edit_one_letter(), which has passed all unit tests. Is there any bug in my code, or it is also a bug in the unit tests?
# Test your function
w1_unittest.test_edit_two_letters(edit_two_letters)
Wrong output type.
Expected: 2654.
Got: 2653.
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
~/work/w1_unittest.py in test_edit_two_letters(target)
1622 assert sorted(list(result))[:10] == sorted(
-> 1623 test_case["expected"]["expected_head"]
1624 )
AssertionError:
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
<ipython-input-43-3b36c6903fa4> in <module>
1 # Test your function
----> 2 w1_unittest.test_edit_two_letters(edit_two_letters)
~/work/w1_unittest.py in test_edit_two_letters(target)
1629 "name": test_case["name"],
1630 "expected": test_case["expected"]["expected_head"],
-> 1631 "got": result[:10],
1632 }
1633 )
TypeError: 'set' object is not subscriptable
I suspect you hard coded rep_cost value. Please check what happens when your function receives different arguments. If the problem persist, please message me your notebook I will look into it.
Im having the same problem on C11, I don’t have rep_cost hardcoded. Also seems weird that the test expects the row 0 to be [ 0 2 4 6 8 10]; how would this happen? Isn’t it always initialized as [0 1 2 3 4 5]?
No its not. Remember :
row means how many cost you need for deleting words in the source to be similar to the target (the target’s length at row 0 is zero).
col means how many cost you need for inserting words into the source to be similar to the target (the source’s length at col 0 is zero).
Remember :
row means how many cost you need for deleting words in the source to be similar to the target (the target’s length at row 0 is zero).
col means how many cost you need for inserting words into the source to be similar to the target (the source’s length at col 0 is zero).