Skip to content

Instantly share code, notes, and snippets.

Created September 21, 2013 16:50
Show Gist options
  • Save anonymous/6652173 to your computer and use it in GitHub Desktop.
Save anonymous/6652173 to your computer and use it in GitHub Desktop.
Repulsion-Force
import math
with open('input2.txt', 'r') as f:
content = f.readlines()
particle1 = content[0].split()
particle2 = content[1].split()
deltaX = float(particle1[1]) - float(particle2[1])
deltaY = float(particle1[2]) - float(particle2[2])
distance = math.sqrt(deltaX * deltaX + deltaY * deltaY)
force = (float(particle1[0]) * float(particle2[0])) / math.pow(distance, 2)
print(round(force, 4))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment