Skip to content

Instantly share code, notes, and snippets.

@tobidope
Created December 3, 2020 10:08
Show Gist options
  • Select an option

  • Save tobidope/c30e5e0c1b4ed7a41344e62f12415752 to your computer and use it in GitHub Desktop.

Select an option

Save tobidope/c30e5e0c1b4ed7a41344e62f12415752 to your computer and use it in GitHub Desktop.
map = """\
......#...........#...#........
.#.....#...##.......#.....##...
......#.#....#.................
..............#.#.......#......
.....#.#...##...#.#..#..#..#..#
.......##...#..#...........#...
.......#.##.#...#.#.........#..
..#...##............##......#.#
.......#.......##......##.##.#.
...#...#........#....#........#
#............###.#......#.....#
..#........#....#..#..........#
..#..##....#......#..#......#..
........#......#......#..#..#..
..#...#....#..##.......#.#.....
.....#.#......#..#....#.##.#..#
......###.....#..#..........#..
.#................#.#..........
.........#..#...#......##......
##...#....#...#.#...#.##..#....
...##...#....#.........###.....
.#.#....#.........##...........
....#.#..#..#...........#......
..#..#.#....#....#...#.........
..........##.....#.##..........
..#.#....#..##......#.#.....##.
..#...#.##......#..........#...
......#....#..#.....#.....#...#
#.#...##.#.##.........#..#.....
...#.#.#.........#.....#.#.#...
..#.........#...............#..
#..##.....#.........#....#.....
...#....##..##...........##..#.
......##.................#.#...
##.......#....#.#.#.....#......
....#.#...#.................##.
#...#.........##.....#.........
#....#.###..#.....##.#....#....
#..#....#...#....#.#.#.........
.......#...........#....#.....#
#...#.............#........#...
.......#.....#...#..#.........#
.##.....##.....##.......#......
....##...##.......#..#.#.....#.
.##.........#......#........##.
.......#...#...###.#..#........
..#..###......##..##...........
.#..#......##..#.#.........#...
...#.......#........#...#.#....
...#....#..#....#.....##.......
............#......#..........#
.#.......#......#.#....#..#.#..
##.........#.#.#..........#....
....##.....#...................
.......#..#........#...........
....##.#..#......###.......#...
....#....#...#.#......#...#...#
.......#.....##..#....#...#....
#...#........#.........#..##...
...........##.........#.#...#..
....................#....#.##..
.#..#..#.........#....#..#..##.
......................#........
..###....#.......#.....###.##..
......#......#.......#.....#..#
.....#...#.##...#......#....#..
.....#.....##.............#....
....#......##..#....#.......#..
.##....#..##......###....#..#..
...###.#.............##...#.#..
.....#.....#.....#...#..#.#....
..#.#.....###......#.......#...
..........#.##......#.........#
..##..#.......................#
........#......#............#..
#..#..#..#.#......#..#....#....
...##......#.............#....#
...........#..#..##.......#....
.....#.........#.#..#..........
##...#.......#.#....#..#..#....
#.#.#...........#.##.#.#..###..
#..#...........#.........##....
............#.#..............#.
.#....#....##.#...........#..#.
....#...#..#...#....#....#.....
....#....#...#..#......#.......
.#.#.........#.......#.##......
.#..##...#........#...........#
##...#..#...#...#.....#...#....
....###.#..#.......##.#..#...#.
...##.......####...##.#........
#....#....#.#............#..#..
#.#.#...#...................##.
##......#...........#..........
#..#..#....#.#...#......#......
.##...#.....#...#........#.....
..#............#..............#
###........#..#....#...#......#
###..##......#.##...........#..
........#......#..#.....#......
...#..........#..#...........#.
....#..#..#....#........#....#.
.#.................#####..##..#
.....#...##..#..........#.##...
..#..............#...####......
.....#.##..................#.#.
...#.#..#..#........#..........
...........#....#.#..#.........
.....##.......#......#..#.#.#..
...#.............##...#........
...............#.......##.##.##
.....#........#........#.#..#..
...#..#.........#...##...###...
...#.#.............###.#.....#.
.#..........#......###.#.#.....
....##..##.............###.....
..#..#.#...##...#.......##.....
..........###........#.....#.#.
#.#....#..#..#......#...#...#..
.........#......##.......#.#..#
...#.....#.........##..#..#....
.....##.#..##.##..##...........
...#.#.##....#..#..#......#..#.
#....#....#.............#...##.
#......#..#.####.#.##.#....##..
##.#.#....##..................#
.....##......#.......##.......#
..#......#.#..#...##......##...
..#....##....#.........#..##...
.###.....#....##...........#...
.........#......#.#........#...
...#...#..#.#....######.#..#...
###......#.#.#.........##.#....
.....#...#.........#...#.......
....#.............#.#.........#
..##...#...#.......#......#....
.....#...#.#...#...#..#........
.#......#......................
...###..#..#....#...##.#.......
.#.#.....##...#...#.....#...##.
.....###..###....##............
.....##....#..#.....#.##.......
#........#.........#...#..#....
...#.#.........#..#.......#.#..
....#.#....##.....#..........#.
.#..#....#..#.#..#..#.........#
#...#....#..............#......
.........#.....#.##...##...###.
.....#....##............#..#...
.....#.#...........#..#....#...
.#..........#...#......#.....#.
.#...........#.....#..#........
..............#......##...#..#.
...#.........#..#....#..##...##
..##...#..................#....
#.....#.................#......
...#......#..#..........#.#....
......#..#.....#.....##...#..#.
......#........#..........#....
...##.##....#..##.#..........#.
..........#..#.#.##............
..##........................#..
.....#.#.#......#....#....##...
#....#.........#........#......
.##.......#...#...#........##..
....##......#....#.#..........#
..#.......#..............#.....
.....#......#.#...#..#.#.#....#
.....#..#........#.##.##.......
##........#..........#.........
.....#..##....#.#......###..##.
#.#...##.........#.#.....#..#..
#....#.#...#........#.....#..#.
........................#......
....###......#............#...#
...#..##......#..##.........#..
.............#...#......#..#..#
....#......#....#...........#..
..#.#.####.#.....##........#..#
#..#...#..#..#.......#.#..#....
..#..#..#....#.#.........##..#.
.......#......#.#............#.
...#.............#.#.....#.....
...#.#.........##...#.#.......#
........#...#...........##...#.
..........#....#......#....##..
..........#...........#........
...#..#...#..........#......#..
......#......#....#.....#..#.#.
........##.................#..#
.#........#.#...........#......
#...#........#.#.#.....#.#.#...
.........#........#..#..#....#.
##........#..........#....#..#.
.#.##...........#..#.#..##....#
.......#.#....#..#......#......
..#.....#........##..#......###
..#...#..................#....#
......#...#..#.##.......#......
........#...#.#................
.........#............#........
..#.....##....#.#..##..........
#.....#..........#....#........
....#.#...#...##....#.....##...
..#.#.......#.............#...#
...##..............#......#....
#......#...#................##.
.#.#...#.#..#..................
...##.......#...........#.#.#..
#......#.#.#........#.##...####
.......#..#.#.........#.#.##..#
..............#....#.........#.
...........#.#..#....##......#.
#.............#...##..#.......#
.........#............#...#.##.
.......#.........#.#.....#..#..
........................#.#.##.
#......#.#......#.........#....
...#.......#.......#.....#.....
#..#....#................#...#.
........#.#..##......#.........
#..#...##....##....##.........#
.......#...#...###.............
#.#..#........#.#.#............
#.....#........##.........#.#..
.#..........#....#.#....###....
.#.....#...#.#........#..#.##..
...#.##......#..#.............#
..##..#.#...................#..
.....#....#...#.#...#...#......
.....#..#.#....#.#.............
#.#....#.#.##..###..........#..
........#.#.............#..#...
.........#.......#.............
.##.#............##...#........
......#................#.......
...............#..#...........#
...#.......#...#.##.....#....#.
##..##..#..........#...........
.##.#.......#...#..#...#...#...
....#..#...........#....#.##...
.#........#........#....#......
.......#...#.##.#..#.#..#......
.#..#......#....#...##....#.#..
......#...##.#.....##.###.....#
.#....#..#......#...#.#.....#..
#............#....##...##.##...
#...#.#....#...#.......##...##.
#...........#.##..#....#.....#.
...#..#...#.........#.......#..
.#....#.....#............#.#..#
.#.....#.#...#.#....##......###
..#..#.#.#...#..#.............#
...#...#..#....#........#...##.
.......#.....#...##...........#
#.##.................#...##...#
..............##........#.....#
............#...#..#.......#.#.
#.#.....#.........#...#......#.
#.###..#......#..#..#...#.....#
.....#.......#.................
........#..#......#.#...#......
#.......#..#........#...#..#...
..#...#.......##.............#.
#.......#.......##...#.........
.........#....#.#..##.....#...#
..#.....#.#.......#....#.......
...#.......#.....#..##.#..#....
....#.......#.#.#..............
.#..#......#........#.#..##..##
....#...#.##.#...#....##...#...
#..##..#.....#.......#.........
....#..#..#.#............#.....
#.......##...##..##............
...............................
....#.......#.##...#.....#.#...
...#........#....#.#..#..#.....
##.......#.....##.#.#....#....#
#.............#...........#.##.
#...........#.#..........#.....
#..#....#....#.#.........#.#...
......#.#.#..#.#.#.............
...#.....#........##....#......
..#...#...#.#.......#......#...
.##........#...#..#..........#.
..#...........#..##.....##.....
............#..#.#...#.....#...
..........#....##.......#......
....#....#.................#..#
....#...............#.........#
..#.#...#......#..........##...
.....#...........#.........#..#
.......#.....##.....#.#........
.#.#..........#....#...........
.#..##....#........#....#......
....#.#..#.......#..#.........#
..#....#.....#......#..#.......
......#........#.......#...#.#.
.......#.......#....#.....##...
....##........#..#...#.#..#...#
.#......#...........##....#....
##....##......#.......#.......#
.##....#.##......#.......##..#.
...#..#.#.#.......#..#.###.....
..........##....#..#.##........
...#........###.#..#........#..
.....#....#..##....#.....#....#
#..........#..........#.#....#.
..#....#.....#..............#..
#..................#......#.##.
.#...#.#.....#.........##......
...#...........#.....#......#..
......#.....#.#..##......##....
...#....###..#.....#..#..##..##
......#.......##..#..#.........
#..#.#....#.#..#..........##.#.
..#..#..##..#.#.#.#.....#......
..#.#...#..#.....###.#.........
##.#.#......#........#.####....
.............#..#..#....#......
...##..........#.......#.#....#
..#.....................#......
..#..#...##...#.##........#....
""".split()
TREE = "#"
def tree_count(map, right, down):
x = 0
y = 0
rows = len(map)
columns = len(map[0])
tree_counter = 0
while True:
x += down
y = (y+right) % columns
if map[x][y] == TREE:
tree_counter += 1
if x == rows -1:
break
return tree_counter
movements =[
[1,1],
[3,1],
[5,1],
[7,1],
[1,2],
]
result = 1
for m in movements:
t =tree_count(map, m[0], m[1])
print(f"Found trees {t}")
result *= t
print(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment