5 kyu

Multisize Nonogram Encoder

Description
Loading description...
Games
Algorithms
  • Please sign in or sign up to leave a comment.
  • Yushi.py Avatar

    Why are we using tuple instead of list? Also, wouldn't it be better for the input to be a 2D array of bool instead of int?

    • hobovsky Avatar

      Some argue that tuples are Python way to have immutable lists. I am not sure I agree, but again, I am not a Python person.

    • Yushi.py Avatar

      Personally, i always saw tuples mainly as fixed size lists rather than immutable ones. I like using them for "return a pair" or to represent coordinates in a grid.

      But still, why does it matter if the input or output are immutable? What makes this kata any different from other katas that have sequences as input? Pretty much all other katas use lists as input and output, even though those values are just as immutable as this kata's.

    • o2001 Avatar

      If they're immutable, they're also fixed size. I think this is a case where there's no right answer and it's up to preference. Since the types of the inner elements are heterogeneous (for the clues), and that the sequences themselves represent finite sets of data that will never change since the input they're based on will never change, this ticks both major boxes to justify using a tuple. The only gains you get by returning a list of lists is that the function's user will be allowed to modify the returned lists afterwards, but again, those are very subjective API design choices. Again, since the answer is obvious even before runtime, to me it semantically reads like named_tuple('clues', 'clue1, clue2, clue3, ..., clueN')

  • lechevalier Avatar

    Not a 5 kyu. 7 or 6kyu would have been more appropriate.

  • dfhwze Avatar

    Nice kata. Approved at kyu 5.