donnemartin / interactive-coding-challenges

120+ interactive Python coding interview challenges (algorithms and data structures). Includes Anki flashcards.
Other
29.44k stars 4.45k forks source link

compress_challenge test case wrong? #201

Closed SS-JIA closed 7 years ago

SS-JIA commented 7 years ago

In compress_challenge, the problem is specified as:

Problem: Compress a string such that 'AAABCCDDDD' becomes 'A3BC2D4'. Only compress the string if it saves space.

However, the last three test cases test for:

assert_equal(func('AAABCCDDDDE'), 'A3BC2D4E') assert_equal(func('BAAACCDDDD'), 'BA3C2D4') assert_equal(func('AAABAACCDDDD'), 'A3BA2C2D4')

shouldn't they be:

assert_equal(func('AAABCCDDDDE'), 'A3BCCD4E') assert_equal(func('BAAACCDDDD'), 'BA3CCD4') assert_equal(func('AAABAACCDDDD'), 'A3BAACCD4')

since compressing 2 repeated characters doesn't save space?

donnemartin commented 7 years ago

Hi @SS-JIA, interesting question, I can see how this can be interpreted either way--it's helpful to clarify these things up front before diving into a solution.

I think I'd prefer to keep the current set of test cases as-is for this problem's interpretation of the constraints. Thanks!