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.
I could edit the Python version. Both tests have been added.
I've added those tests.
I'll see if I can edit the Python version. It might be some permissions thing, and I might have a permission you don't.
( After this translation is approved, that is. That'll make me a contributor - right now I can't edit at all. )
It maps
word
to a list of booleans that indicate if its letters are under the right hand ( true if so, false if not ), it then builds a list of comparisons of every letter with the previous letter for inequality, then it takes the logicaland
of that list.So your crude understanding is correct! :]
and [booleans]
reduces a list to a single boolean, andelem
for "element", given a single element and a list, returns a boolean.<*>
is theS
combinator,<$>
is infix formap
, both of which help conciseness and completely kill readability if you don't know Haskell ( most people that do should be able to read this though ).$
is another combinator that obviates the need for parentheses around everything to its right ( same story about concise and unreadable unless you know Haskell ).No, the random tests do not do what you think they do. The actual word generator is
resize 8 $ listOf $ elements (['a'..'z'])
, which generates words of up to 8 characters ( a word is a list of characters, the possible elements are'a'..'z'
, and the length of the list, thus the word, is resized to a maximum of8
);forAll
by default runs100
tests.You're right to be careful and I can't fault you for not being able to read Haskell. :] I promise the translation is OK; I've done quite a few.
Two thing to note: the random generator also generates empty words, for which the reference solution expects
True
. There should really be a fixed tests for that, andTrue
is the correct value mathematically (and [] == True
andor [] == False
the same waysum [] == 0
andproduct [] == 1
). There should also really be a fixed test with every letter on the keyboard, to test for spelling errors and such in user solutions. It wouldn't hurt to add those to the example tests as well.not really, but C is faster than other languages, so it probably takes as much time as 100 random tests in JavaScript or so x) but ok, reducing it to 100