You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was just thinking about use of the _ placeholder, and then beginning the start of the algorithm on range(2 rather than range(1. It seems sort of unpythonic and counter-intuitive to me. A very small thing, but I was thinking maybe it should or could be rewritten to not use the _ placeholder, which to my knowledge doesn't do anything here? Or we could rewrite it using something like this:
Ah you were definitely correct! the insertion sort placeholder was unnecessary. And it seems that the standard pseudocode for insertion sort does something similar to what you've written so I'm going to adopt something similar as well! Good catch! After doing some timing tests though I am not sure if it is faster to do the slicing that was in my original algorithm or just do a bunch of swaps like in your algorithm. I'll probably get around to timing it eventually
I was just thinking about use of the _ placeholder, and then beginning the start of the algorithm on
range(2
rather thanrange(1
. It seems sort of unpythonic and counter-intuitive to me. A very small thing, but I was thinking maybe it should or could be rewritten to not use the _ placeholder, which to my knowledge doesn't do anything here? Or we could rewrite it using something like this:etc.
Maybe I'm missing something though, is the "_" used to catch something I'm not seeing?
The text was updated successfully, but these errors were encountered: