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)
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
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...