def run2(filename): input_list = AOCH.ril2(filename, '') p1 = list(map(int, input_list[0][1:])) p2 = list(map(int, input_list[1][1:])) bol, winner_list = game(p1, p2) score = 0 for i in range(len(winner_list)): score += winner_list[i] * (len(winner_list) - i) return score
def splitting(filename): input16 = AOCH.ril2(filename, '') for i in range(len(input16[0])): input16[0][i] = input16[0][i].split(': ') input16[0][i][1] = input16[0][i][1].split(' or ') for j in range(len(input16[0][i][1])): input16[0][i][1][j] = list(map(int, input16[0][i][1][j].split('-'))) input16[1][1] = list(map(int, input16[1][1].split(','))) for i in range(1, len(input16[2])): input16[2][i] = list(map(int, input16[2][i].split(','))) return input16
def initialize(filename): input19 = AOCH.ril2(filename, '') temp_set = {} for i in range(len(input19[0])): input19[0][i] = input19[0][i].split(': ') temp_list = input19[0][i][1].split(' | ') if len(temp_list) == 1: if len(temp_list[0].split(' ')) > 1: temp_set[input19[0][i][0]] = [temp_list[0].split(' ')] else: if temp_list[0][0] == '"': temp_set[input19[0][i][0]] = temp_list[0].split('"')[1] else: print('Here', temp_list) temp_set[input19[0][i][0]] = [temp_list] else: for j in range(len(temp_list)): temp_list[j] = temp_list[j].split(' ') temp_set[input19[0][i][0]] = temp_list return [temp_set, input19[1]]
def run(filename): input_list = AOCH.ril2(filename, '') p1 = list(map(int, input_list[0][1:])) p2 = list(map(int, input_list[1][1:])) while len(p1) > 0 and len(p2) > 0: if p1[0] > p2[0]: p1.append(p1[0]) p1.append(p2[0]) else: p2.append(p2[0]) p2.append(p1[0]) p1 = p1[1:] p2 = p2[1:] if len(p1) == 0: count = 0 for i in range(len(p2)): count += p2[i] * (len(p2) - i) return count elif len(p2) == 0: count = 0 for i in range(len(p1)): count += p1[i] * (len(p1) - i) return count
def initialize(filename): input_list = AOCH.ril2(filename, '') input_set = {} for item in input_list: input_set[item[0].split(' ')[1][:-1]] = item[1:] return input_set