<br><br>
<div><span class="gmail_quote">On 11/14/05, <b class="gmail_sendername">Ben Bush</b> <<a href="mailto:pythonnew@gmail.com">pythonnew@gmail.com</a>> wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div><span class="q">
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><br><br>Hijacking Brian's response since my newsserver never god Ben's original<br>request...:<br><br>I would program this at a reasonably high abstraction level, based on 
<br>sets -- since you say order doesn't matter, sets are more appropriate<br>than lists anyway.  For example:<br><br>def two_cont_in_common(x, y):<br>   common = set(x).intersection(y)<br>   return bool(common.intersection
 (z+1 for z in common))<br><br>i.e., given two lists or whatever, first build the set of all elements<br>they have in common, then check if that set contains two continuous<br>elements.  Then, as Brian suggests, you can use this dyadic function on 
<br>a reference list and as many others as you wish:<br><br>def bens_task(reference, others):<br>   return [two_cont_in_common(alist, reference) for alist in others]<br><br>The call bens_task(lisA, lisB, lisC, lisD) will give you essentially 
<br>what you require, except it uses True and False rather than 1 and 0; if<br>you need to fix this last issue, you can add an int(...) call around<br>these booleans in either of the functions in question.<br><br><br>Alex 
</blockquote>
<div> </div></span>
<div>I got invalid syntax error when i run Alex's code. do not know why.</div><br> </div></blockquote></div>
<div>Alex,</div>
<div>I use PythonWin to run:</div>
<div>def two_cont_in_common(x, y):<br>   common = set(x).intersection(y)<br>   return bool(common.intersection(z+1 for z in common))<br>def bens_task(reference, others):<br>   return [two_cont_in_common(alist, reference) for alist in others] 
</div>
<div> </div>
<div>I got invalid syntax error and the mouse's cursor stay on the 'for' in the statement of <br>   return bool(common.intersection(z+1 for z in common))<br clear="all"><br>-- <br>Thanks!<br>Ben Bush<br> </div>