We're a place where coders share, stay up-to-date and grow their careers.
My solution in Python below for part 1. The hardest part for my was to figure out that the starting point is one further to the right then I expected...
file = open('d3-input.txt') input_file = file.readlines() input_file = [line.replace('\n','') for line in input_file] right_counter = 3 count_trees = 0 for index, line in enumerate(input_file): if index > 0: if list(line)[right_counter] == '#': count_trees+=1 right_counter+=3 if right_counter >= len(line): right_counter = right_counter-len(line) print(count_trees)
My solution in Python below for part 1. The hardest part for my was to figure out that the starting point is one further to the right then I expected...