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.
This comment is hidden because it contains spoiler information about the solution
This was fun, thank you!
Thanks! I like to write in functional style when possible and
next
in Python is very useful for that. However, after 2 years it took me a moment to understand what thataccumulate
does.Agreed on moving the 4 into
cycle
, it saves a lot of multiplications (thoughs
was meant to represent the sign, expressed with +1 or -1).I prefer to use
math.isclose
instead ofabs
to check if the floating point numbers are close because I can quickly recognize what that code is doing, but your mileage may vary.My solution in Python reaches the "rectangles have only common faces (version 2)" random test then times out. Ported to Javascript, it passes in approx. 9 seconds.
Nice kata despite the clunky description. I did not even try to brute-force the solution because I thought it would time out (my bad). I ended up writing a solution that works for more general cases.
This was fun, thank you! I am particularly happy with the way I achieved numerical stability in Python.
That's clever! It confirms that 55-character limit and return type integer could both be enforced.
This comment is hidden because it contains spoiler information about the solution
I asked myself the same question, this is not an easy kata to rank. I would say 5-kyu or 4-kyu if the number of islands in the test was choosen so that all brute-force solutions fail, but any "textbook" implementation of the correct algorithm succeeds, regardless of language-dependant optimizations.
If the implementation must be optimized (i.e. choosing the right data structure) in consideration of the high "density" of the bridges, then definitely 4-kyu, but it is not clear to me if that's what you required.
A performance edition could be created (2-kyu maybe) where the number of bridges is so high that some upfront reduction is necessary (see my other comment hidden as spoiler) leveraging the 2D nature of the points representing the islands.
...and that's how you disregard PEP8 with flair 😀
Thanks for this kata. I have a couple of suggestions:
Finally made it, barely beating the clock! Thanks for this super kata.
I tested a few solutions provided by others and they all seem to be in the same order of magnitude as mine. I guess for the 5000 islands case even small optimizations matter.
This comment is hidden because it contains spoiler information about the solution
Tried two or three modifications of that already, but not the right ones apparently! On the upside I'm learning more about computational geometry.
Thanks for getting back to me. I wanted to use numpy for matrix multiplication in one of my first attempts. I've tried several approaches that solve the problem but are too slow on 5000 islands, unless I use scipy. I wonder if I should replicate "that algorithm" in scipy (not saying more to avoid spoliers), but it looks a bit too challenging for a 4-kyu kata. I must be missing something obvious here 🙂
Loading more items...