from random import randrange, seed import subprocess def makeSample(s,t,r): return f"[sample.%03d]\ninput = \"\"\"\n{t}\"\"\"\noutput=\"\"\"\n{r}\"\"\"\n" % s def makeLandscapingTask5(): seed(42) maxn = 1000000 best =[4791, 27945, 5043, 49217, 38725, 15447, 24491, 200459, 43065, 1913, 35993, 90901, 110311, 174299, 234071, 61135, 141575, 77809, 157413, 340485, 264933, 364917, 25989, 69581, 8297, 13243, 550539, 3267, 379887, 72547, 1081, 21413, 68827, 55313, 6481, 11883, 28305, 2279, 248245, 148467, 267, 2499, 49019, 114395, 121311, 55303, 1259, 106355, 28569, 3033, 54403, 132603, 75425, 502373, 376145, 13357, 108519, 46339, 189077, 95223, 548139, 12343, 6257, 28689, 25523, 309545, 13731, 4725, 26565, 5931, 51313, 22299, 50753, 331853, 86699, 23903, 339157, 269817, 30013, 70187, 85965, 81667, 144855, 398077, 167327, 21123, 56943, 99811, 60987, 38573, 201107, 227999, 91727, 111255, 17017, 45199, 65979, 95707, 58765, 63903] res = "" for c in range(100): print(f"Generating #{c+1} of 100") t = "1\n" r = "" n = randrange(randrange(maxn-5)+1)+5 offset = randrange(n//2) a = [randrange(min([i*2+10, (n-i)*2+10]))+offset for i in range(n)] t+=f"{n}\n" t+=" ".join(map(str,a))+"\n" # print(f"Calling solver... on {n} entries") # result = subprocess.check_output(["../pyramiden"], input = t, encoding='ascii') # best[c] = int(result.split(":")[1]) r += f"Case #0: {best[c]}\n" # print(r) res += makeSample(c,t,r) # print(repr(best)) return res soifile = makeLandscapingTask5() with open("pyramiden5.soitask", "w") as f: f.write(soifile)