Created
October 3, 2011 10:25
-
-
Save esehara/1258836 to your computer and use it in GitHub Desktop.
Google Code Jam Skeleton for Python
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 sys | |
class line_manager: | |
def __init__(self): | |
self.first_line = True | |
self.in_data = True | |
self.data_finish_line = 0 | |
self.readline = 0 | |
self.is_one_line = True | |
def go_line(self): | |
self.readline = self.readline + 1 | |
class work_line: | |
def __init__(self): | |
self.case_number = 1 | |
self.init() | |
pass | |
def init(self): | |
self.result = 0 | |
pass | |
def first_read(self): | |
pass | |
def input_data(self,line_data): | |
self.init() | |
pass | |
def do_work(self,line_data): | |
pass | |
def end_work(self): | |
self.result_print() | |
pass | |
def result_print(self): | |
print "Case #%i: %i" % (self.case_number,self.result) | |
self.case_number = self.case_number + 1 | |
def line_split(line): | |
return line.split(" ") | |
def main(): | |
worker = work_line() | |
manage = line_manager() | |
for line in open('testdata.txt','r'): | |
#First Read Line | |
if manage.first_line: | |
worker.first_read() | |
manage.first_line = False | |
continue | |
#Input Data Read | |
if manage.in_data: | |
worker.input_data(line_split(line)) | |
manage.data_finish_line = 1 | |
manage.readline = 0 | |
manage.in_data = False | |
if not manage.is_one_line: continue | |
#Work Data Read | |
if not manage.in_data: | |
manage.go_line() | |
worker.do_work(line_split(line)) | |
#End Input Data | |
if manage.data_finish_line == manage.readline: | |
worker.end_work() | |
manage.in_data = True | |
continue | |
if __name__ == "__main__":main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment