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.
( JS ) Update available
Example 3 implies start_board and end_board might have different pieces, but out of all the test cases that's the only one where that's true. Maybe add some tests where there are different numbers of knights at the start and end?
This comment is hidden because it contains spoiler information about the solution
I for the love me can't understand how this one ain't the most upvoted both as clever and best practices
hats off for avoiding regex altogether, I tried the same and had 10x the numer of locs
+1 for not having regular expressions
This comment is hidden because it contains spoiler information about the solution
Really clever solution! I like how it avoids regular expressions.
Amazing!
Very nice
except it's faster to build and extend with a tuple than a list
I compared 100,000 iterations of extending a list with [1]*100 vs (1,)*100 and the tuple approach took about 80% of the time the list approach did.
(eventual list length of 10,000,000)
Tuples are immutables. When you entend a tuple, it actually builds a whole new tuple, so it iterates on elements you already visit.
What if you make the extended section a tuple like l.extend((1,)*(i-z)) insted of a list? since tuples are faster to build. it won't save much because of the list iterations taking most of the time but it would be ever so slightly faster
Fixed the test cases as well as sample test case. (sample test case might get broken in the future)
Thanks a lot for your report. I will fix test cases.
yep that's pretty fast
I'm not very familiar with modules beyond a few of the more common like collections or heapq
I guess if this were compiled with a custom c code it'd smoke other solutions but I'd have to learn c to do that. since I'm using python as an introduction.
I guess you could also use numpy's fill with ones thing or numpy arrays
I see you're using += instead of extend any reason?
ok I tested numpy arrays
turns out they dislike extention so much so that I almost timed out despite trying three different options extended arrays seem to require redeclaring the array tried, resize, pad and concatenate
plus itertools compress had a problem with them
is it possible to standardise the test so that all face the same array? the random assignment makes any benchmarks meaningless
Loading more items...