Hi Harry.
Here are my input and output routines for Python for Dancing with the Googlers.
Includes a time keeping function.
if __name__ == '__main__':
# load input file
starttime = time.time()
inputfile = file("input.txt")
outputfile = file("output.txt", "w+")
num_of_testcases = int(inputfile.readline())
print num_of_testcases
pool = multiprocessing.Pool()
inputs = []
for testcase in range(1,num_of_testcases+1):
print "Load testcase: %s" % testcase
in_str = inputfile.readline()
result = re.split("\W+", in_str)
N = int(result[0])
S = int(result[1])
p = int(result[2])
ti = map(int, result[3:3+N])
inputs.append((testcase, N,S, p, ti))
print "%s: %s %s %s %s" % (testcase, N,S, p, ti)
results = pool.map(count_func, inputs)
for result in results:
outstring = "Case #%s: %s\n" % result
print outstring
outputfile.write(outstring)
outputfile.close()
inputfile.close()
endtime = time.time()
print "time used %s:%s (%s)" % (int((endtime-starttime) / 60),
int((endtime-starttime) % 60), endtime-starttime)
Jesper Jurcenoks
On Sat, Apr 14, 2012 at 1:22 AM, harry <[email protected]> wrote:
> Hi....
> How to use .in file as input in python?and is there any code to
> produce output file in python?
> If yes what it is?
> I already used open function to read the input file.and I also created
> the output file.But the problem was when I submit my output it shows
> like "the file must be start with "Case #1:""
> How can I overcome this problem?
> anyone plz send me the solution....
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Code Jam" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/google-code?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"Google Code Jam" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-code?hl=en.