@@ -0,0 +1,1392 @@
+#!/usr/bin/env python%0A%0A# Google Code Jam%0A# Google Code Jam 2014%0A# Round 2 2014%0A# Problem B. New Lottery Game%0A%0A# Solved small set%0A%0Afrom __future__ import print_function%0Aimport itertools%0A%0Adef count_winning_pairs(a, b, k):%0A    permutations = itertools.product(range(a), range(b))%0A    count = 0%0A    for _ in permutations:%0A        if _%5B0%5D & _%5B1%5D %3C k:%0A            count += 1%0A    return count%0A%0Aif __name__ == '__main__':%0A    import os%0A%0A    samples = %5B%0A        (3,4,2),%0A        (4,5,2),%0A        (7,8,5),%0A        (45,56,35),%0A        (103,143,88)%0A    %5D%0A%0A    for sample in samples:%0A        print(count_winning_pairs(*sample))%0A%0A    data_files = %5B'B-small-practice', 'B-large-practice'%5D%0A    for f in data_files:%0A        with open(os.path.join(os.path.dirname(os.path.realpath(__file__)),%0A                  '%7B0%7D.in'.format(f)), 'r') as input_file:%0A            lines = input_file.readlines()%0A        input_count = int(lines%5B0%5D.replace('%5Cn' ,''))%0A        inputs = %5Bline.replace('%5Cn', '') for line in lines%5B1:%5D%5D%0A%0A        i = 1%0A        with open(os.path.join(os.path.dirname(os.path.realpath(__file__)),%0A                  '%7B0%7D.out'.format(f)), 'w') as output_file:%0A            for in_ in inputs:%0A                a, b, k = tuple(%5Bint(_) for _ in in_.split(' ')%5D)%0A                print(a, b, k)%0A                output_file.write('Case #%7B0%7D: %7B1%7D%5Cn'.format(i, count_winning_pairs(a, b, k)))%0A                i += 1%0A

Add new lottery game