# -*- coding: utf-8 -*-
# The Computer Language Benchmarks Game
# http://shootout.alioth.debian.org/
# Contributed by Sebastien Loisel
# Fixed by Isaac Gouy
# Sped up by Josh Goldfoot
# Dirtily sped up by Simon Descarpentries
# Concurrency by Jason Stitt

from math            import sqrt
from itertools       import izip
import time
import util
import itertools
import optparse

def eval_A (i, j):
    return 1.0 / ((i + j) * (i + j + 1) / 2 + i + 1)

def eval_A_times_u (u):
    args = ((i,u) for i in range(len(u)))
    return map(part_A_times_u, args)

def eval_At_times_u (u):
    args = ((i,u) for i in range(len(u)))
    return map(part_At_times_u, args)

def eval_AtA_times_u (u):
    return eval_At_times_u (eval_A_times_u (u))

def part_A_times_u((i,u)):
    partial_sum = 0
    for j, u_j in enumerate(u):
        partial_sum += eval_A (i, j) * u_j
    return partial_sum

def part_At_times_u((i,u)):
    partial_sum = 0
    for j, u_j in enumerate(u):
        partial_sum += eval_A (j, i) * u_j
    return partial_sum

DEFAULT_N = 130

def main(n):
    times = []
    for i in range(n):
        t0 = time.time()
        u = [1] * DEFAULT_N

        for dummy in range(10):
            v = eval_AtA_times_u (u)
            u = eval_AtA_times_u (v)

        vBv = vv = 0

        for ue, ve in izip (u, v):
            vBv += ue * ve
            vv  += ve * ve
        tk = time.time()
        times.append(tk - t0)
    return times

main(10)

@@ -67,38 +67,65 @@
 http
+s
 ://s
-hootout.alioth.debian.org/
+alsa.debian.org/benchmarksgame-team/benchmarksgame/%0A
 %0A# C
@@ -275,16 +275,56 @@
 n Stitt%0A
+# 2to3%0A%0Afrom multiprocessing import Pool
 %0Afrom ma
@@ -353,97 +353,41 @@
 qrt%0A
+%0A
 from 
-itertools       import izip%0Aimport time%0Aimport util%0Aimport itertools%0Aimport optparse
+sys             import argv
 %0A%0Ade
@@ -390,25 +390,24 @@
 %0A%0Adef eval_A
- 
 (i, j):%0A    
@@ -466,33 +466,32 @@
 f eval_A_times_u
- 
 (u):%0A    args = 
@@ -524,32 +524,37 @@
 u)))%0A    return 
+pool.
 map(part_A_times
@@ -575,33 +575,32 @@
  eval_At_times_u
- 
 (u):%0A    args = 
@@ -641,16 +641,21 @@
  return 
+pool.
 map(part
@@ -694,17 +694,16 @@
 _times_u
- 
 (u):%0A   
@@ -759,39 +759,61 @@
  part_A_times_u(
-(i,u)):
+i_and_u):%0A    (i,u) = i_and_u
 %0A    partial_sum
@@ -940,15 +940,37 @@
 s_u(
-(i,u)):
+i_and_u):%0A    (i,u) = i_and_u
 %0A   
@@ -1089,25 +1089,8 @@
 um%0A%0A
-DEFAULT_N = 130%0A%0A
 def 
@@ -1098,79 +1098,32 @@
 ain(
-n
 ):%0A    
-times = %5B%5D%0A    for i in range(n):%0A        t0 = time.time()%0A    
+n = int(argv%5B1%5D)%0A
     
@@ -1136,23 +1136,11 @@
 %5D * 
-DEFAULT_N
+n
 %0A%0A
-    
     
@@ -1157,16 +1157,17 @@
 in range
+ 
 (10):%0A  
@@ -1172,20 +1172,16 @@
         
-   
- 
 v = eval
@@ -1197,20 +1197,16 @@
 s_u (u)%0A
-    
         
@@ -1231,28 +1231,24 @@
 _u (v)%0A%0A    
-  
-  
 vBv = vv = 0
@@ -1253,20 +1253,16 @@
  0%0A%0A    
-  
-  
 for ue, 
@@ -1267,17 +1267,16 @@
 , ve in 
-i
 zip (u, 
@@ -1287,20 +1287,16 @@
         
-    
 vBv += u
@@ -1310,20 +1310,16 @@
         
-   
- 
 vv  += v
@@ -1329,86 +1329,109 @@
  ve%0A
-        tk = time.time()%0A        times.append(tk - t0)%0A    return times%0A%0A
+%0A    print(%22%250.9f%22 %25 (sqrt(vBv/vv)))%0A%0Aif __name__ == '__main__':%0A    pool = Pool(processes=4)%0A    
 main(
-10
 )%0A

Fix Python 3 syntax error in function calls