Created
September 21, 2013 16:50
-
-
Save anonymous/6652173 to your computer and use it in GitHub Desktop.
Repulsion-Force
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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