def extract_input(fichier): lines = fileManipulation.read_file_line_by_line(fichier) drawNumbersList = get_draw_numbers_list(lines) grids = extract_grids(lines[2:]) return (drawNumbersList, grids)
def main(fichier): instructions = fileManipulation.read_file_line_by_line(fichier) position = (0, 0, 0) for i in instructions: position = calcul_position(i, position[0], position[1], position[2]) return position[0] * position[1]
def get_vents(filename): lines = fileManipulation.read_file_line_by_line(filename) vents = [] for l in lines: vents.append(string_to_vent(l)) return vents
def test_read_file_line_by_line_fichier_entier_est_lu(): # Given filename = "input.txt" # When resultat = fileManipulation.read_file_line_by_line(filename) # Then assert resultat == ['Ligne 1', 'Ligne 2', 'Ligne 3', 'Ligne 4']
def test_read_file_line_by_line_nombre_de_lignes_est_correct(): # Given filename = "input.txt" # When resultat = fileManipulation.read_file_line_by_line(filename) # Then assert len(resultat) == 4
def test_read_file_line_by_line_ligne_1_est_bien_lue(): # Given filename = "input.txt" # When resultat = fileManipulation.read_file_line_by_line(filename) # Then assert resultat[0].strip() == "Ligne 1"
def main(fichier): lanternFishLine = fileManipulation.read_file_line_by_line(fichier)[0] lanternFishList = [] for l in lanternFishLine.split(','): lanternFishList.append(int(l)) for i in range(0, 80): lanternFishList = update_lanternfish_list(lanternFishList) return len(lanternFishList)
def create_map(fichier): lineFile = fileManipulation.read_file_line_by_line(fichier) outputMap = [] for l in lineFile: currentLine = [] for c in l: currentLine.append(int(c)) outputMap.append(currentLine) return outputMap
def calcul_CO2_scrubber_rating(fichier): lignes = fileManipulation.read_file_line_by_line(fichier) colonneCourante = 0 while len(lignes) > 1: colonnes = line_to_col(lignes) bitCommun = str(abs(int(plus_commun_bit(colonnes[colonneCourante])) -1)) lignes = calcul_filtre_numbers(lignes, bitCommun, colonneCourante) colonneCourante += 1 return lignes[0]
def calcul_oxygen_generator_rating(fichier): lignes = fileManipulation.read_file_line_by_line(fichier) colonneCourante = 0 while len(lignes) > 1: colonnes = line_to_col(lignes) bitCommun = plus_commun_bit(colonnes[colonneCourante]) lignes = calcul_filtre_numbers(lignes, bitCommun, colonneCourante) colonneCourante += 1 return lignes[0]
def main(fichier): crabsListStr = fileManipulation.read_file_line_by_line(fichier)[0].split(',') crabsListInt = [] for i in crabsListStr: crabsListInt.append(int(i)) crabsListPosition = list_crabs(crabsListInt) crabsListBestPosition = find_best_position(crabsListPosition) crabsTotalFuel = compute_total_fuel(crabsListPosition,crabsListBestPosition) return crabsTotalFuel
def main(fichier): lines = fileManipulation.read_file_line_by_line(fichier) total = 0 for l in lines: outputDigits = "" for c in get_output_digits(l): outputDigits += str(c) total += int(outputDigits) return total
def main(fichier): matrix = fileManipulation.read_file_line_by_line(fichier) sumLowest = 0 for x in range(0, len(matrix[0])): for y in range(0, len(matrix)): if is_lowest(matrix, x, y): # print("x=" + str(x) + " y=" + str(y) + " xy=" + str(matrix[y][x])) # print(return_adjacent(matrix, x, y)) sumLowest += (int(matrix[y][x]) + 1) return sumLowest
def main(fichier): lanternFishLine = fileManipulation.read_file_line_by_line(fichier)[0] lanternFishList = [] for l in lanternFishLine.split(','): lanternFishList.append(int(l)) lanternFishList = convert_lantern_fish_list(lanternFishList) for i in range(0, 256): lanternFishList = update_lanternfish_list(lanternFishList) sumOfFish = 0 for i in lanternFishList: sumOfFish += i return sumOfFish
def main(fichier): lines = fileManipulation.read_file_line_by_line(fichier) allSizes = get_all_values_sizes(lines) return allSizes.count(2) + allSizes.count(3) + allSizes.count(4) + allSizes.count(7)