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'm glad to see the first solve appears. Happy coding
^_^
No news on this side, so closing.
This comment is hidden because it contains spoiler information about the solution
Hi,
Considering the shape you were talking about, your function should return these three:
It matches the description:
If you encounter imbricated pieces, both outer and inner shapes have to be returned.
so I'm not sure I'll add anything to it unless you can precise what is lacking or why (I need enlightenment here). What were the other possibilities you thought where matching, exactly?It seems you began the hard way, yeah. I created it that way and went almost crazy with the
+ => -|
thing too... ;) I believed I had found a 1 dan kata, actually. Until lechevalier came by and show me the right way to solve it (you can take a look at my python solution if you want to see the evil way).More sample tests: that's doable. I'll think about some of them (but not from the random ones).
cheers
The problem with trying to allow functions calling other functions is, we've already decided that functions can't access global variables, and for any given name there can be either a variable or a function, not both (to avoid conflicts).
If I try to define this, it's supposed to give an error, because the variable
y
is not in the argument list:fn sum x => x + y
But if
sum
can call other functions,y
doesn't have to be a variable. It could be another function which doesn't require any arguments. And maybey
isn't defined yet. How is it supposed to know when you definesum
whether it's valid or not?Maybe you've defined a global function named
y
a while ago, but you still meant to define yoursum
function as this:fn sum x y => x + y
Since you forgot to put
y
in the argument list, is it going to use the globaly
function instead of giving you an error?Added links to binomial theorem and pascal's triangle.
Added links to relevant kata.
Yes. There is no seperate variable decleration syntax; variables are always created when they are first assigned.
No. Functions here are akin to mathematical functions. That is, a function operates solely on the specified inputs and produces exactly one output. This behavior is covered both by the kata description and the test cases.
I'm inclined to leave this as undefined behavior. My original solution does not support calling functions inside of another function's body, but I don't see the point in explicitly disallowing it either.
Functions calling other functions isn't part of the spec as discussed above. Not testing parameterless functions was an oversight, and I've added a couple tests to cover them.
If someone really wants to write a switch to cover every test case, they're more than welcome to do so. I'm not really interested in thwarting anyone that determined to ignore the spirit of the kata.
I dislike the unpredictableness of randomized tests. A random test is just as likely to allow a submission to pass as it is to generate a valid corner case. I would prefer to identify specific corner cases and add non-random tests for them. I agree that throwing an error is the correct behavior for the input '1 2', and I have added a test to that effect. I'm happy to add tests for other specific issues that you can come up with as well.