Advent of code 2015 solutions https://adventofcode.com/2015/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3.py 498B

1234567891011121314151617181920212223
  1. #!/usr/bin/python
  2. with open('3.txt', 'r') as file:
  3. input = file.read()
  4. locations = [[0, 0], [0, 0]]
  5. visited = {'0,0': True}
  6. i = 0
  7. for dir in input:
  8. if dir == '^':
  9. locations[i][1] -= 1
  10. if dir == 'v':
  11. locations[i][1] += 1
  12. if dir == '>':
  13. locations[i][0] += 1
  14. if dir == '<':
  15. locations[i][0] -= 1
  16. visited['%s,%s' % (locations[i][0], locations[i][1])] = True
  17. i = 1 - i # (Remove this line if only Santa is delivering)
  18. print(len(visited))