Ad
  • Custom User Avatar

    if it overflows the flower will have many petals, an overflower if you will

  • Default User Avatar

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

  • Custom User Avatar

    .. aaaaaaaaaaaaand that edit fscked up the JavaScript version.

    Please approve the fork.

    I am very unconvinced there is any difference between triple-backtick and triple-tilde: both markup code when followed by a language name or nothing; both define language-specific text when followed by "if:languagename" or "if-not:languagename".

    ( Inline, though, their behaviour is different. )

  • Custom User Avatar

    Yes, I'll maintain it as well.

    Huh? Triple-backtick does exactly that; it isn't rendered as code, it's rendered as text. I'm willing to change it, but it won't make any difference as far as I can tell.

  • Custom User Avatar
    • changed list to two fields, got slightly simpler in one case, slightly more complex in another, when decoding (needed to use kind of ternary)
    • yes, forgot to remove print
    • build versions are better names indeed

    As for OOP, it is a hack to work around the fact that the heap module doesn't allow providing your own comparator, so comparisons should be defined on wrapping items and I cannot just put strings and arrays of strings like I did in JS.
    Maybe, there's a better way—I'm not very skilled in Python

  • Custom User Avatar

    map is concatenation of 2 functions: create_tree and convert_tree_to_map. First one creates (sigh) the tree. Second one converts it into flat map object, mapping input (character) to output (binary string), or the opposite: binary to character, if u is true. t is tree, q is queue, k is key, u is unmap (reverse the map), o is output.

    What do you mean by "Why did you use arrays instead of objects?" ? For the tree? Just to keep it simple. Node keys are either 0 or 1, so there's no point to make it an object. So instead of something like {'0':{'0':{...},'1':{...}},'1':{...}} I have equivalent [[[...],[...]],[...]] - tree of tuples (arrays with 2 elements).

    Coffeescript is just a Javascript (that is it's motto: "It's just Javascript"), that is made readable. Stupid C++ style for(setup;condition;iteration) loops are replaced with consistent and readable ranges for i in [start..end], most of JS syntatic garbage is removed or made optional:

    • ternary operator a?b:c replaced by human readable if a then b else c
    • curly braces {...} for blocks are removed, because all blocks are indentation based, like in Python
    • brackets (...) in function calls are made optional.

    The single best practice of Coffeescript is: KISS = "Keep It Simple, Stupid", which I do all the time. The rest is pretty much "just Javascript".

  • Custom User Avatar

    The preloaded code is moved to test cases.
    Tuple is used to return pair of string and int for Encode method.
    Let me know if there is anything else to modify.

  • Custom User Avatar

    Partial tree consists of a very peculiar case.

    Hint: There are things that are not actually a tree node involved. It'll lock you in if you try to do stuff to it, but given the input you shouldn't need to touch it at all.

  • Custom User Avatar
  • Custom User Avatar

    @muesli4, can you elaborate on conditions when you expect problems to happen for this solution?
    https://downloads.haskell.org/~ghc/6.0/docs/html/base/Data.Int.html states "All arithmetic is performed modulo 2^n, where n is the number of bits in the type."

  • Custom User Avatar

    Gah! Right you are! I'm too used to workaround priorities before actually reading orginal grammar :)

  • Custom User Avatar

    I had been working on it for two days actually. The timing was coincidental. :P

    That tests shows the length of the encoding to the user. Didn't want to log that to the output, and didn't want it as a test header. This takes a minimum of screen space. It matches the basic test, so I didn't think it needed any explanation to the user really. (And I was too lazy to include a reference implementation and really check the answer. Though maybe I should.)

  • Custom User Avatar

    Not sure that is so surprising, there certainly are others ^^

  • Custom User Avatar

    You do isoEU wrong. I had updated the test. You can probably figure out what's wrong.
    Note: remember not just anypair is ISO

  • Custom User Avatar

    Indeed, I was originally planning to make part IV about *. Now that I thought about it, you guys are correct, - I'll change the tags on this one now.

  • Loading more items...