6 kyu

Multirange iterator

Description
Loading description...
Iterators
Fundamentals
  • Please sign in or sign up to leave a comment.
  • ahmet_popaj Avatar

    Nice kata, although something should be done to avoid brute-forcing it.

  • saudiGuy Avatar

    python new test framework is required. updated in this fork

  • Blind4Basics Avatar

    python tests are generating a warning:

    STDERR
    tests.py:16: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.10 it will stop working
      test.assert_equals(isinstance(multiiter(0), collections.Iterable), True)
    
  • RNOH Avatar

    very nice kata!, good for building concepts!

  • Awesome A.D. Avatar

    This comment has been hidden.

  • tchar Avatar

    This comment has been hidden.

  • sperry Avatar

    Eugene-katsevman, how about, for instance, (2, 0, 3) test case (theoretically)? Now some solutions return [] for it (for example, my second solution), some - a tuple ('0' is excluded, like in my first solution, it seems doubtful). Don't you think that we need certainty? Which option is more correct in your opinion? How about to add such test? And to my mind, description would be better with clarification on the possible length of the input tuple. Anyway, thanks for nice kata!

    • eugene-katsevman Avatar

      Thanks for the suggestion! I've clarified the task a bit. A generator should be returned, not a list nor tuple. All current solutions still pass, though. I don't know if knowing possible input tuple length be any help when solving this kata. We easely get a combinatorial explosion there and long inputs couldn't be even tested IMHO. You're welcome!

      Suggestion marked resolved by eugene-katsevman 10 years ago
    • sperry Avatar

      Probably, I put it not clear, sorry. I meant not type of returned data, but it's content. In potential test case with (2, 0, 3), should we return something EMPTY (empty list, e.g.) or we should combine the non-zero data ([(0, 0), (0, 1), ...(1, 2)])? Tuple's length was my second suggestion ;) After thinking a bit, I agree with you, it is not necessary.

    • eugene-katsevman Avatar

      If any of params is 0, we have to return an empty iterator. This case is tested in first example

      test.assert_equals(list(multiiter(0)), [])
      

      May be it should have been expressed in some other way.

    • sperry Avatar

      Thanks for clarification! Unfortunately, as a result of an error on codewars server, my wrong solution, with tuple output, was saved as 'completed' in my profile, and it puzzled me.

  • Unnamed Avatar

    It's not a good idea to override a built-in function with your own one with the same name (iter).

  • NaMe613 Avatar

    Problem in the random tests

    NameError: global name 'product' is not defined