• So what does your code return for encode("")? According to the error message you posted, it returns an index out of range error. Fix that.

  • I know I'm 2 years late, but I saw your comment and noticed you still don't have a solution.

    I found it helps to understand the algorithm if you do some examples by hand.
    If you encode "Mellow Yellow" and "Melllow Yelow" by hand, you should see a difference.

  • Very nice kata. Been using these things for a while and it was a lot of fun / very insightful to see how they're made :)

  • My return is two elements. I am still getting this error. Can you point me in the right direction?

  • Even the test is showing one return element

  • OP solved it, closing

  • added some time ago

  • No more help needed, I found the origin.

  • I am testing Huffman encoding in Python: Passed tests : 2781 but Failed tests: 265

    I don't undestand the following error
    Test Passed
    ERROR restore sorted sequence from frequencies should succeed: [] should equal ['l']

    Can you help me Please

  • This kata's basic tests are incredibly inconsistent

    test.assert_equals( encode( fs, []), '')
    test.assert_equals( encode( [], "" ), None );
    test.assert_equals( encode( [('a', 1)], "" ), None );
    test.assert_equals( encode( [ ("a",4), ("b",1), ("c",2) ], "" ), "" )
    1. Why is it that we are testing enode(fs, []), when according to the hint the second argument should be a string ???

    takes: [ (str, int) ], str; returns: String (with "0" and "1")

    1. Why is encode(fs, "") supposed to return None if len(fs)<2 and else "" ????
  • Other people have mentioned the empty string. I was pulling my hair out trying to optimize my code until I realized the timeout I was getting was because I was't handling it. Perhaps handing this as input could be clearer? Maybe that is just my lack of experience.

  • there is no such thing as an empty array in C, it's forbidden by the standard

  • Currently working my way through this (C#) and noticed a few things that irk me:

    • Sample tests aren't unit tests; for example Foldr requires both Repeat and Take to be implemented. If I'm working my way from top to bottom, then I will not have implemented Take yet, and will receive a slightly confusing NotImplementedError for the Foldr test.
    • Sample tests don't properly test the streams: I successfully passed all sample tests, then got an immediate Stack Overflow when I hit "attempt"; turns out a few of my methods were returning (headS, s) instead of (headS, tailS), i.e. recursively running on the same unmodified stream instead of on the tail of the input stream.
    • The interface of LazyStream is not specified and only discoverable by chance by reading through the sample tests. Otherwise, I could never have known that LazyStream stores the Stream in its .Value property, and I wouldn't be able to implement anything.
  • encode? easy :)
    decode? 0_0, how I get banana back?

    I was getting "SEGV on unknown address" many many times...
    until I figured out that input in decode() can be empty string.
    hope my experience will help someone in future.

    very interesting kata. I should google more about BWT logic, to implement decode()
    however it was cool and exiting. thanks for kata.

  • Exactly, some expected outcomes would be good!

  • Loading more items...