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.
Updated sample test cases.
actual
andexpected
in assertionsThis has no random tests, so I am rejecting (to make sure no one approves prematurely). You can fork this translation to add random tests.
If the type system will handle it, you can always write your
let rec
expressions in lambda syntax. If I can do it in LC, you can do it in Ocaml.See https://en.wikipedia.org/wiki/Let_expression for how to rewrite
let rec
, and ping me on Discord ( in#lambda-calculus
) for how to do mutual recursion andY*
.Note that I can't help you with the type system, and I know from Haskell recursive types can be a hassle. I might be able to do the type in Haskell, if that will help you do it in Ocaml ( it really helps here that LC is untyped ).
The
let rec
construct has some limitations, for example it is not possible to define the list of naturals like so :The precise explanation of what is or is not acceptable as a right hand side is available in the OCaml manual.
Anyone know if applicative parsers are possible to do in Ocaml? (I know monadic ones can be done). I made an attempt at a translation, but Ocaml complains
when I try to actually use the mutually recursive functions I wrote in my Haskell version (exprP, binP, etc). I'm not sure if I'm doing something wrong or if this is a limitation of the language, I would appreciate it if anyone can take a look at my translation.
My solution passes all the test cases but gives the error:
All of my answers were one line calls to scanl so I'm not sure what it's upset about. It possible to fix this one? It's a pretty fun problem.
The tests are correct.
Note the last few bullet points on the instructions:
In the test case generation 1 has already been populated. Notice that the state of the board just before
populate(generation2)
gets called.Relative to the blob (12 o clock is always up).
"every blob whose size is larger than the smallest blob size value will move to one of the 8 spaces immediately surrounding it in the direction of the nearest target blob with a lower relative size."
👍
Ok, I'll keep working on it. I'm up to 312.
It does seem strange that if the number of tests (and presumably the variables in each) are random that I'd successfully complete the same number most of the time though.
Edit: Nevermind, I figured it out. Good kata!
It looks like your algorithm needs to be optimized for speed. There are 600+ random tests.
EDIT: To be more precise, the number of total random tests will vary with each run. When running the tests a few times, the number of tests fell in the range 650 to 699.
Python 3. I tried changing my board from a dictionary to a list of lists instead but I still get the same result.
@scottmyran : what language is this for?
Loading more items...