[Tutor] Counting the consistent rankings

Ali Torkamani torkamani at gmail.com
Mon Jul 23 23:19:33 CEST 2012


>
>     S=0;
>     A=0;
>     n=len(L1)
>     for i in range(n):
>         for j in range(i+1,n,1):
>             A+=1;
>             if (L1[i]>L1[j] and L2[i]>L2[j]) or (L1[i]<L1[j] and
> L2[i]<L2[j]) or (L1[i]==L1[j] and L2[i]==L2[j]):
>                 S+=1
>
>     print(100*float(S)/A)
>

In this code, A is equal to (len(L1)*( len(L1)-1)/2), but I had left it
this way for later sanity check.


>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120723/dfc6d2c7/attachment.html>


More information about the Tutor mailing list