Add lists while keeping the length of the longer list

sound merge script pic (1)
sound merge script pic

How do I keep the length of the longer one? (The shorter one shouldn't repeat, so it would go 2, 4, 6, 4, 5, 6, 7, 8, 9, 10) I tried using MAP, but it's slow with large lists.

I'd split the larger list into two parts (the first the size of the smaller list, and the second containing the rest of the larger list.)

Have you tried compiling the map block? It goes very fast for me if I compile it, and I can't imagine a reason you'd need to work with lists > 100,000 items. If you are, maybe try streams?

Another approach:


Oh yeah. I'll test out how long a list my :zap:MAP solution would work for (reasonably) in a bit.

also costumes

Time updates for compiled map using a duration block (reset timer, run code, report timer)

100,000 item lists: 0.4 sec
500,000 item lists: 1.5 sec
1,000,000 item lists: 2.7 sec
5,000,000 item lists: 14.9 sec
1,000,000,000 item lists: 34.5 sec

This takes exponential time to work, and probably can be used for lists up to a million (1e6) items within a reasonable time.

That's not exponential time! If it were, you'd die of old age long before you got an answer for a billion-item list. It's linear time, but doesn't look like it because there is a constant cost to get started regardless of the list length, and that has a bigger effect on smaller lists, compared to the total run time. So let's imagine that 100,000 items took 0.3 sec, and round off your numbers a bit:

100,000: 0.3 sec
500,000: 1.5 sec = 5 × 0.3
1,000,000: ≈3 sec = 10 × 0.3
5,000,000: ≈15 sec = 50 × 0.3
10,000,000: ≈30 sec = 100 × 0.3

(I'm guessing that the last line of your table should really be 10,000,000 rather than 1,000,000,000 items; 34.5 sec is way too fast otherwise! I'd expect more like 3,000 seconds ≈ an hour.)

Oh, oops, yeah. I meant 10,000,000.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.