Example: the teacher gave the task to find a favorite quote from the Harry Potter book and show it to the whole class.
Solutions without mutation: copy the quote from the book with chalk onto the school board, scan the book page, print the quote from the electronic version of the book and stick it on the board.
Solution with mutation: take scissors, cut out the quote from the book and stick it on the board.
I was also a bit mystified by length = 0 in the random tests.
I imagine if the length of the segemnt to be sorted is 0, then nothing gets sorted.
Instead the tests expect length=0 to result in everything from start to the end being sorted
That aside, thanks for the kata
---- this from test results ----
Testing for [46, -90, -30], 0 and 0
Definetly not, this is the lazy solution that goes against good practice by changing the original list.
Thanks for your input. After reading I went to look into it and learned a lot and better practices. Thank you!
Example: the teacher gave the task to find a favorite quote from the Harry Potter book and show it to the whole class.
Solutions without mutation: copy the quote from the book with chalk onto the school board, scan the book page, print the quote from the electronic version of the book and stick it on the board.
Solution with mutation: take scissors, cut out the quote from the book and stick it on the board.
can you please explain why for the benefit of people who are most likely new and don't realise the implications of this (or what mutating even means)
Mutating an argument is the worst thing you can do.
it's not.
list don't change
Please advise as we all know, we should avoid changes in original array. So how this is the best practice?
Ah, that's what I should have done! Good work.
This comment is hidden because it contains spoiler information about the solution
"You don't necessarily start at the first floor" Exactly! Now I understand what the mistake is :)
In the end, it's quite simple.
Can't believe I've been staring at this thing for hours, over the last couple of months.
thanks for creating this kata
This comment is hidden because it contains spoiler information about the solution
I was also a bit mystified by length = 0 in the random tests.
I imagine if the length of the segemnt to be sorted is 0, then nothing gets sorted.
Instead the tests expect length=0 to result in everything from start to the end being sorted
That aside, thanks for the kata
---- this from test results ----
Testing for [46, -90, -30], 0 and 0
[46, -90, -30] should equal
[-90, -30, 46]
Loading more items...