Ad
  • Custom User Avatar
    • Needs random tests
    • Needs to disable reload for obvious reasons ;-)
    • Duplicate!
  • Custom User Avatar

    I had similar problems with the example test cases provided, with an error saying "Unhashable type: list". I agree set(lists) is not the right example test case to provide. Good kata for recursive generator practice, though!

  • Default User Avatar

    I would strongly suggest adding a test case like this:

    results = [tuple(p) for p in permutations([1, 2, 2])]

    expected_results = [(1, 2, 2), (2, 1, 2), (2, 2, 1)])

    Test.assert_equals(sorted(expected_results), sorted(results))

    And please review your reference implementation for passing this test case. It doesn't pass, neither do a lot of successful code submissions.

    A good permutation generator shouldn't rely on some external code which removes duplicate occurences. In your case it's set, it's highly recommended to use sorted(...) instead of set(...), thus you will see duplicates instead of hiding them