<div class="gmail_quote">Questa versione non inserisce l'ultimo intervallo spurio da 0 eventi attivi:<br><br><div style="margin-left: 40px;"><span style="font-family: courier new,monospace;">s1ev = [(1723, 18550), (100000, 101000)]</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">s2ev = [(9154, 9307), (9340, 10442), (87361, 98214)]</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">starts = sorted(s[0] for s in s1ev + s2ev)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">ends = sorted(s[1] for s in s1ev + s2ev)</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">actives = [[] for x in range(3)]</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">actives[0] = [[0, 0]]</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">actives_count = 0</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">while ends:</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> if starts and starts[0] < ends[0]:</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> x = starts.pop(0)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> inc = 1</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> else:</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> x = ends.pop(0)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> inc = -1</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> actives[actives_count][-1][1] = x</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> actives_count += inc</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> if ends:</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> actives[actives_count].append([x, 0])</span><br></div><br></div><br>-- <br><a href="http://thinkcode.tv">http://thinkcode.tv</a> - Prossimamente su questi schermi<br>
<a href="http://beri.it">http://beri.it</a> - Blog di una testina di vitello<br><a href="http://stacktrace.it">http://stacktrace.it</a> - Aperiodico di resistenza informatica<br><br>