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 is the exact concept I tried to capture in my solution with (what I think is) more readable but probably way less performant. Awesome solution man!
I'll just say this: I have the building blocks for how this should work. I've accomplished it within 15 minutes in SQL Server and translated most of the syntax over to Postgres.
I have to admit that the way tests are set up for this Kata are profoundly unfriendly compared to other SQL Kata. Getting into the nitty gritty of what we can do vs what we can't in Codewars is difficult.
All of the test cases are NxN, at least in C#. Maybe the cases have changed since you commented, but for anyone else looking at discourse you shouldn't consider jagged or rectangular arrays.
You can use the console temporarily to see what cases are being run, but there is a performance impact you should be aware of when submitting.
This comment is hidden because it contains spoiler information about the solution
.
If n is the number of pieces, yes as i was talking about like two nested for loops, it is either O(n) or O(n * m) where n, m is height and length.
I also don't believe any solutions are O(n^2) if n is the number of pieces. By doing a simple nested loop with
for p in pieces:
twice, it times out.Your solution is much easier to understand! Months later, this is true for me, even though I wrote my code...
This comment is hidden because it contains spoiler information about the solution
first things first: what is
n
exactly?@tony:
here, n being the number of pieces, the best solution is O(n) (for the precise reasons Ryanman is explaning)
This comment is hidden because it contains spoiler information about the solution
I think O(n^2) is the lowest possible time as you need to have a nested loop. Take your solution for example, it has a nested loop, so its O(n^2).
This was a great Kata. Similar to other solver feedback, named Tuples would have been a nice to have (but I think your approach seems very common on code wars). Another minor point of feedback is that I totally missed for an attempt or two the fact that puzzles can be rectangular. In hindsight, it's very obvious, since you have width and height variables, but with the square example I got a bit lost in the sauce. Finally, a very very minor grammatical point: In notes, I would change "Be careful about performances" to "Be careful about performance".
A lot of the solutions I've seen were huge and/or O(n2), I believe this is solvable in O(n).
Thanks for your work!
Love how succinct this code is.
This comment is hidden because it contains spoiler information about the solution
Loading more items...