Ad
  • Custom User Avatar

    Unpublishing due to many old unresolved issues.

  • Custom User Avatar

    This kata is a duplicate of other kata (for example, this one: https://www.codewars.com/kata/5254ca2719453dcc0b00027d) and most probably will not leave beta.

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

    I think itertoools.product could be disabled as well, in order to make it a bit more challenging (and avoiding the recipes that Python's doc gives)

  • Custom User Avatar

    You can't return "ERROR". "ERROR" is potentially valid output - <78d#Z;?> decodes to ERROR.

    Use throw new Error() instead.

  • Custom User Avatar

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

  • 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!

  • Custom 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

  • Custom User Avatar

    It is possible to add another language to a kata in beta (you need 1500 rep... I personally think this is too big, specially when adding a new language). This is not possible for an already implemented kata. It seems that it is a technical problem that the devs are working on.

    For the moment I don't think it is a good idea to publish multiple katas for different languages as it will probably be harder to merge kata than just edit the old ones.

    It is not my role to give a final answer to this question so I removed the issue. I still think you will have to work on a merge with the already existing kata when this will be possible.

  • Custom User Avatar

    Please correct me if I am wrong, but I don't think it is possible for me to add a Python solution to a pre-existing kata. If there were a way to merge this kata with the one referenced above I probably wouldn't be opposed.

    As I write this there are only 13 kata availible in Python. Just trying to expand the Python offerings.

  • Custom User Avatar

    There are differences between languages, like there may be multiple solutions for a given language. But I think that is the point of kata having multiple solutions, not having a kata for each solution.

    I am not convinced this method is fundamentally different.

  • Custom User Avatar

    I think python is far too dynamic for any kind of static analysis to catch this kind of trickery.

    I expect that it is possible to outwit the code above, but if it is wrapped up in a nice API for us to use it should be relatively easy to plug any holes as they are found.

  • Custom User Avatar

    Clever hack :)

    At the risk of playing whack-a-mole I have blocked that workaround:

    import __builtin__
    orig_import = __builtin__.__import__
    orig_reload = __builtin__.reload
    
    def disabled(*args):
      print "itertools.permutations has been disabled for this Kata"
    
    def filter_unwanted_imports(*args, **kwargs):
      if 'permutations' in args[0]:
        return disabled
      if 'imp' == args[0]:  # No legit reason to load this module in this Kata
        return None
      results = orig_import(*args, **kwargs)
      if hasattr(results, 'permutations'):
        results.permutations = disabled
      return results
    
    def filter_unwanted_reloads(*args, **kwargs):
      results = orig_reload(*args, **kwargs)
      if hasattr(results, 'permutations'):
        results.permutations = disabled
      if hasattr(results, 'reload'):
        results.reload = filter_unwanted_reloads
      if hasattr(results, '__import__'):
        results.__import__ = filter_unwanted_imports
      return results
    
    __builtin__.__import__ = filter_unwanted_imports
    __builtin__.reload = filter_unwanted_reloads
    

    It would be nice if there was an easy/standard way for kata authors to block access to certain library functions...

  • Custom User Avatar

    The referenced kata is a Javascript only, and thus not a duplicate of this Python only kata.

    Additionaly this kata is meant to excercise some specific Python features (generators) and pitfalls (lists are passed by reference - be aware of side-efects when modifying them).

  • Loading more items...