#!/opt/local/bin/python import random, collections, string, copy probname = "videogames" tcount = {} total_secret = 0 # bounds like MAXN here MAXN = 100 NAMES = ["alice", "bob", "charlie"] GAMES = ["fishing", "golf", "hockey"] def gen(l, intype = probname): global total_secret assert type(l) == list and len(l) in range(1, MAXN+1) for t in l: assert type(t) == tuple and t[0] in NAMES and t[1] in GAMES path = "../data" if intype not in tcount: tcount[intype] = 0 tcount[intype] += 1 if intype == "sample": filename = "{0}/sample/{1}.in".format(path, tcount[intype]) else: filename = "{0}/secret/{3:02}-{1}-{2}.in".format(path, intype, tcount[intype], total_secret) total_secret += 1 print("Generating:", filename) out = open(filename, "w") # print the test case here, remember to print to file=out print(len(l), file=out) for t in l: print(t[0], "wants to play", t[1], file=out) out.close() # E, N, K def gensample(): gen([(NAMES[0], GAMES[1]), (NAMES[1], GAMES[1]), (NAMES[2], GAMES[2]), (NAMES[2], GAMES[0])], "sample") def gencorner(): for i in range(3): gen([(NAMES[i], GAMES[i])], "corner") gen([(NAMES[i], GAMES[i]) for i in range(3)], "corner") gen([(NAMES[i%3], GAMES[j%3]) for i in range(4) for j in range(4)], "corner") gen([(NAMES[1], GAMES[1])]*(MAXN-1)+[(NAMES[2], GAMES[1])], "corner") def genrand(N): gen([(random.choice(NAMES), random.choice(GAMES)) for _ in range(N)], "random") if __name__ == "__main__": random.seed(0) gensample() gencorner() genrand(10) genrand(MAXN)