<div class="gmail_quote">2009/10/22 Michele <span dir="ltr"><<a href="mailto:michele@nectarine.it">michele@nectarine.it</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">2009/10/19 Marco Beri <<a href="mailto:marcoberi@gmail.com">marcoberi@gmail.com</a>>:<br>
</div><div class="im">> Questa versione non inserisce l'ultimo intervallo spurio da 0 eventi attivi:<br>
><br>
<br>
</div>Ancora due domande:<br>
- volendo calcolare s1 or s2, come potrei fare?<br></blockquote><div><br>Non ho capito la domanda, s1 e s2 non sono forse i dati di input?<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
- inoltre: supponiamo che io ho un istante di termine per entrambi<br>
s1ev e s2ev e lo chiamo END.<br>
Quindi, nella conta degli eventi, devo inserire anche l'istante<br>
dall'ultimo evento fino a END. Come lo posso fare?<br></blockquote><div><br><div style="margin-left: 40px;"><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;">END = 99999999</span><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, END]]</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;"> actives[actives_count].append([x, END])</span><br>
</div><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Grazie<br>
</blockquote></div><br>Prego.<br><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>