Fine! This runs in about 19s on my Notebook. splice() works in place. filter() generates a copy and is an additional loop. So I thought working out of place with slice() could be better. No way. I didn't even wait for it to end. Your implementation with splice and filter is faster.
Fine! This runs in about 19s on my Notebook. splice() works in place. filter() generates a copy and is an additional loop. So I thought working out of place with slice() could be better. No way. I didn't even wait for it to end. Your implementation with splice and filter is faster.
My goal is to see if I can make a
function*
Generator but I haven't been able to figure out a consistent pattern yet that can drip out numbers..Sorry about deleting my comment, I totally broke my codeSo I changed the
.splice(j-1, 1, 0)
to a direct array access and fixed thej
offset, making it 2x faster