Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
if it overflows the flower will have many petals, an overflower if you will
there is no such thing as an empty array in C, it's forbidden by the standard
.. 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. )
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.
build
versions are better names indeedAs 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
map
is concatenation of 2 functions:create_tree
andconvert_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, ifu
is true.t
istree
,q
isqueue
,k
iskey
,u
isunmap
(reverse the map),o
isoutput
.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
or1
, 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++ stylefor(setup;condition;iteration)
loops are replaced with consistent and readable rangesfor i in [start..end]
, most of JS syntatic garbage is removed or made optional:a?b:c
replaced by human readableif a then b else c
{...}
for blocks are removed, because all blocks are indentation based, like in Python(...)
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".
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.
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.
Fixed
@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."
Gah! Right you are! I'm too used to workaround priorities before actually reading orginal grammar :)
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.)
Not sure that is so surprising, there certainly are others ^^
You do isoEU wrong. I had updated the test. You can probably figure out what's wrong.
Note: remember not just anypair is ISO
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...