equal
deleted
inserted
replaced
|
1 import random |
|
2 |
|
3 def gcd(a, b): |
|
4 while b != 0: |
|
5 a, b = b, a % b |
|
6 return a |
|
7 |
|
8 a = random.sample(xrange(100), 10) |
|
9 b = random.sample(xrange(1000), 10) |
|
10 c = random.sample(xrange(10000), 10) |
|
11 c = random.sample(xrange(10000), 10) |
|
12 d = random.sample(xrange(100000), 10) |
|
13 e = random.sample(xrange(1000000), 10) |
|
14 f = a + b + c + d + e |
|
15 f.sort() |
|
16 a = random.sample(xrange(100), 10) |
|
17 b = random.sample(xrange(1000), 10) |
|
18 c = random.sample(xrange(10000), 10) |
|
19 d = random.sample(xrange(100000), 10) |
|
20 e = random.sample(xrange(1000000), 10) |
|
21 g = a + b + c + d + e |
|
22 |
|
23 testcases = [] |
|
24 for item in f: |
|
25 a = f[random.randrange(0, len(f))] |
|
26 b = g[random.randrange(0, len(g))] |
|
27 gc = gcd(a, b) |
|
28 testcases.append([a, b, gc]) |
|
29 |
|
30 sortedcases = sorted(testcases, key=lambda case: case[0]) |
|
31 |
|
32 fil = open('/home/madhu/Desktop/gcdtest.dat', 'w') |
|
33 for case in sortedcases: |
|
34 fil.write('%d, %d, %d\n' % (case[0], case[1], case[2])) |
|
35 |
|
36 fil.close() |