Last active
December 8, 2015 17:10
-
-
Save yumechi/0da642666c35d9caf19b to your computer and use it in GitHub Desktop.
http://yukicoder.me/problems/891 でつかった入力生成器(ガバガバ)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import time | |
import random | |
def createData(num): | |
for i in range(num): | |
randdata = [] | |
for _ in range(3): | |
randdata.append(random.randint(1, 10 ** 4 + 1)) | |
randdata.sort() | |
print(" ".join([str(i) for i in randdata])) | |
def run(): | |
createData(10) | |
if __name__ == "__main__": | |
print("start!") | |
run() | |
print("end!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import time | |
import random | |
def ansfunc(N): | |
count = 0 | |
count += N // 2 + N // 3 + N // 5 | |
count -= N // 6 + N // 10 + N // 15 | |
count += N // 30 | |
return count | |
def writefiles(dirpath, filename, num): | |
filepath = dirpath + "/" + filename | |
filewriter = open(filepath, "w") | |
filewriter.write(str(num) + "\n") | |
filewriter.close() | |
def createData(number): | |
nowtime = int(time.time()) | |
inputdirpath = str(nowtime) + "/input" | |
outputdirpath = str(nowtime) + "/output" | |
os.makedirs(inputdirpath) | |
os.makedirs(outputdirpath) | |
for i in range(1, number+1): | |
questionN = int(random.randint(1, 10 ** 9 + 1) // abs(i - number - 1)) // abs(i - number - 1) | |
answer = ansfunc(questionN if questionN > 1 else 1) | |
inputfilename = "input" + str(i) + ".txt" | |
writefiles(inputdirpath, inputfilename, questionN) | |
outputfilename = "output" + str(i) + ".txt" | |
writefiles(outputdirpath, outputfilename, answer) | |
def run(): | |
createData(10) | |
if __name__ == "__main__": | |
print("start!") | |
run() | |
print("end!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment