6 kyu

Seven-segment display: how many switches?

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

    Pretty challenging kata of the series, nice one.

  • Blind4Basics Avatar

    Hi,

    • Missing sample tests: size=1, testing against all sequences of one single number, over the full range of digits. A test suite starting with anything else than this would be considered a bad tests design.
    • there are loads of duplicated code in the tests => all this should be extracted away, using a new function taking the configuration of the batch of tests as parameters.

    Cheers

    • alexc19 Avatar

      Thanks, test cases updated. Had to move the helpers back to higher scope, hope it's ok, otherwise I could further abstract the test configuration.

    • Blind4Basics Avatar

      errrr... the new overall setup looks good, but:

      • the One digit, sequence is just one number batch of tests should also be present in the example tests
      • iirc, you had a lot of random tests. but now, there is one single random tests per batch (except in the last one. Are you sure that's what you wanted to do?

      Note that you still have some duplicated code in there (nothing critical). My idea was more along the line of:

      def run_btach_of_random_tests(title, n_tests, sizes_range, values_range):
          @test.it(title)
          def _():
              for _ in range(n_tests):
                  # logic for one test here...
      

      The same could be done for the ixed tests, but they are good enough already, I guess.

    • alexc19 Avatar
      • I can make also the title a parameter, my thinking was that explicitly mentioning the tile in @test.it makes the test cases source a bit more readable, though less compact.

      • "One digit, sequence is just one number" batch of tests should also be present in the example tests" => isn't that too much help?

      • Total number of random tests has not changed, I have 10x runs for the most complex kind, could run 10x for each kind, I just thought we could save a bit of computational power.

    • Blind4Basics Avatar

      isn't that too much help?

      well, depends. But adding those tests was the very first thing I did to debug my code. I didn't even try to use the actual sample tests. So, yeah, "might be too much", but on the other hand, not having them feels sometwhat like taking the users for fools (as in "yeah, I made a kata, but I won't provide you the actually useful tests). Side note: if the tests are in the full test suite, there is no valid reason to not put them in the example tests, imo. ;)


      you can leave aside the two other points, if you want.

    • alexc19 Avatar

      It's an interesting debate, writing a few tests of your own as a user could be regarded as part of solving the kata, but I see your point.

      I updated the example tests and refactored the random test cases 👍

      Issue marked resolved by alexc19 2 years ago
  • dfhwze Avatar

    It is not clear from the description:

    • how digits are displayed that are shorter than the size parameter (left padding " ")
    • that the final status is the last element of the sequence (could have also been all OFF, since we start with all OFF)
  • rowcased Avatar

    This comment has been hidden.

  • rowcased Avatar

    Super cool kata; enjoyed solving!