def play_one_step(self): N = 5 piece_type, previous_board, board = readInput(N) go = GO(N) go.set_board(piece_type, previous_board, board) action = self.get_input(go, piece_type) writeOutput(action)
def main(): n = int(stdin.readline()) g = graphy.Graph(n) text = read.readInput(n) limit = int(stdin.readline()) g = read.diff(text, limit, g) vertices = read.inputHeap(n, limit) bh = binheap.binheap(n) bh.binheap_make(n, vertices) min = prim.prim(g, bh) for i in min: stdout.write(str(i[0]) + ' ' + str(i[1]) + '\n')
def judge(self, n_move, verbose): N = 5 piece_type, previous_board, board = readInput(N) go = GO(N) go.verbose = verbose go.set_board(piece_type, previous_board, board) go.n_move = n_move try: action, x, y = readOutput() except: cond_print(verbose, "output.txt not found or invalid format") return (3 - piece_type) if action == "MOVE": if not go.place_chess(x, y, piece_type): cond_print(verbose, 'Game end.') cond_print( verbose, 'The winner is {}'.format('X' if 3 - piece_type == 1 else 'O')) return (3 - piece_type) go.died_pieces = go.remove_died_pieces(3 - piece_type) if go.game_end(piece_type, action): result = go.judge_winner() if verbose: cond_print(verbose, 'Game end.') if result == 0: cond_print(verbose, 'The game is a tie.') else: cond_print( verbose, 'The winner is {}'.format('X' if result == 1 else 'O')) return (result) piece_type = 2 if piece_type == 1 else 1 if action == "PASS": go.previous_board = go.board writeNextInput(piece_type, go.previous_board, go.board) return (0)
line = f.read(2) f.close() win = int(line[0]) side = int(line[1]) if win == 0: result = 1 elif win == side: result = 2 else: result = 0 player = QLearner(side=side) player.read() player.update(result) player.save(1) else: """ Get current state and piece_type. Move (action) """ N = 5 piece_type, previous_board, board = readInput(N) go = GO(N) go.set_board(piece_type, previous_board, board) curr_state = ''.join( [str(board[i][j]) for i in range(N) for j in range(N)]) player = QLearner(side=piece_type) player.read() action = player.get_input(go, curr_state) writeOutput(action) player.save(0)
ws.cell('%s%s' % ('C', 1)).value = "Employee Count" ws.cell('%s%s' % ('D', 1)).value = "Location" ws.cell('%s%s' % ('E', 1)).value = "Functional Area" ws.cell('%s%s' % ('F', 1)).value = "Funding" # Creating a list to be used for refenrencing the cells pos = ['A', 'B', 'C', 'D', 'E'] for i, result in enumerate(output): for j, value in enumerate(result): ws.cell('%s%s' % (pos[i], j + 2)).value = result[j].strip('/n') r = 2 for one_company in funding: text = "" for value in one_company: text = text + value.strip('\n') + "," #print text[:-1] ws.cell('%s%s' % ('F', r)).value = text[:-1] r = r + 1 wb.save('result.xlsx') # Finally saving the file if __name__ == "__main__": sys.setrecursionlimit(5000) url = read.readInput('newfile.yml') print url scrapeInfo(url) writeToExcel()
from pprint import pprint from LL1 import LL1 from read import readGrammer, readInput myLL1 = LL1(*readGrammer('grammer1.txt')) codes = myLL1.getThreeAddressCode(readInput('input.txt')) #print("wdwad", codes) print("\n\n\n") for code in codes: print(code)
ws.cell('%s%s'%('B', 1)).value = "Company URL" ws.cell('%s%s'%('C', 1)).value = "Employee Count" ws.cell('%s%s'%('D', 1)).value = "Location" ws.cell('%s%s'%('E', 1)).value = "Functional Area" ws.cell('%s%s'%('F', 1)).value = "Funding" # Creating a list to be used for refenrencing the cells pos = ['A','B','C','D','E'] for i,result in enumerate(output): for j,value in enumerate(result): ws.cell('%s%s'%(pos[i], j+2)).value = result[j].strip('/n') r = 2 for one_company in funding: text="" for value in one_company: text = text + value.strip('\n') + "," #print text[:-1] ws.cell('%s%s'%('F', r)).value = text[:-1] r = r + 1 wb.save('result.xlsx') # Finally saving the file if __name__ == "__main__": sys.setrecursionlimit(5000) url = read.readInput('newfile.yml') print url scrapeInfo(url) writeToExcel()