You are sick of all of the codegolf challenges. Hence you decide to write a program that will automatically golf some Python code for you. There are 3 test cases:
print quickSort([0,7,3,-1,8,10,57,2]) def quickSort(arr): less =  pivotList =  more =  if len(arr) <= 1: return arr else: pivot = arr for i in arr: if i < pivot: less.append(i) elif i > pivot: more.append(i) else: pivotList.append(i) less = quickSort(less) more = quickSort(more) return less + pivotList + more
for i in xrange(1, 101): if i % 15 == 0: print "FizzBuzz" elif i % 3 == 0: print "Fizz" elif i % 5 == 0: print "Buzz" else: print i
from sys import argv def randomGenerator(seed=1): max_int32 = (1 << 31) - 1 seed = seed & max_int32 while True: seed = (seed * 214013 + 2531011) & max_int32 yield seed >> 16 def deal(seed): nc = 52 cards = range(nc - 1, -1, -1) rnd = randomGenerator(seed) for i, r in zip(range(nc), rnd): j = (nc - 1) - r % (nc - i) cards[i], cards[j] = cards[j], cards[i] return cards def show(cards): l = ["A23456789TJQK"[c / 4] + "CDHS"[c % 4] for c in cards] for i in range(0, len(cards), 8): print " ", " ".join(l[i : i+8]) if __name__ == '__main__': seed = int(argv) if len(argv) == 2 else 11982 print "Hand", seed deck = deal(seed) show(deck)
Your program must not target the code I posted specifically, and should work with any Python 2 code. I reserve the right to change the source code being codegolfed. You may assume that there are no multi-line strings (so you don't have build a full-blown parser), and that locals() is not called.
The output of your program should run in an identical manner as the original source code. (Namely, it must produce the same output. Variable names and language constructs can be changed, as long as the output remains the same)
You may use STDIO or a File to do your input/output of the source code.
Your score will be the sum of the bytes of your program's output.