|
|
@@ -1,21 +1,17 @@
|
|
|
file = open('input.txt','r')
|
|
|
|
|
|
-map = []
|
|
|
-
|
|
|
-#for l in file:
|
|
|
-# map.append(l)
|
|
|
+map = file.readlines()
|
|
|
|
|
|
trees = 0
|
|
|
right = 0
|
|
|
+rstep = 1
|
|
|
+dstep = 2
|
|
|
|
|
|
-#for s in map:
|
|
|
-for s in file:
|
|
|
+i = 0
|
|
|
+while i < len(map):
|
|
|
+ s = map[i]
|
|
|
pos = (right % (len(s)-1))
|
|
|
temp = s[:pos]+'O'+s[pos+1:]
|
|
|
- #print(s[pos])
|
|
|
- #print(temp)
|
|
|
- #print(pos)
|
|
|
- #print(right)
|
|
|
if s[pos] == '#':
|
|
|
temp = s[:pos]+'X'+s[pos+1:]
|
|
|
trees += 1
|
|
|
@@ -23,5 +19,6 @@ for s in file:
|
|
|
temp = s[:pos]+'O'+s[pos+1:]
|
|
|
print(temp)
|
|
|
|
|
|
- right += 3
|
|
|
+ right += rstep
|
|
|
+ i += dstep
|
|
|
print(str(trees)+ ' trees')
|