repl.it
@thechalkface2/

Ritangle2017_Q4

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
ant1x = 1
ant1y = 0

r = 0.9
for i in range(100):
  ant1y += r # go north
  r *= 0.9 # multiply r by 0.9
  ant1x -= r # go west
  r *= 0.9
  ant1y -= r # go south
  r *= 0.9
  ant1x += r # go east
  r *= 0.9

print(ant1x, ant1y)

ant2x = 1
ant2y = 0

r = 0.8
for i in range(100):
  ant2y -= r # go south
  r *= 0.8
  ant2x -= r # go west
  r *= 0.8
  ant2y += r # go north
  r *= 0.8
  ant2x += r # go east
  r *= 0.8

print(ant2x, ant2y)

gradient = (ant2y - ant1y) / (ant2x - ant1x)
print(gradient)