Created
November 10, 2016 14:17
-
-
Save MonsieurV/1be062c0fff839451974b90b8082ff20 to your computer and use it in GitHub Desktop.
My Little Sister Triangle Geometry Problem
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
# The objective was to find all possible triangles | |
# that can have the sum of their three sides sizes equal to 10. | |
# (We consider only integer side sizes). | |
# | |
# I'm not good at Maths, and it was no obvious to | |
# enumarate all solutions, so I just wrote a program | |
# to do it for me. | |
eq_solutions = [] | |
problem_solutions = [] | |
y = 10 | |
for i in range(1,10): | |
for j in range(1,10): | |
for k in range(1,10): | |
if i + j + k == 10: | |
eq_solution = [i, j, k] | |
eq_solution.sort() | |
if not eq_solution in eq_solutions: | |
eq_solutions.append(eq_solution) | |
print(eq_solutions) | |
for eq_solution in eq_solutions: | |
if eq_solution[0] + eq_solution[1] >= eq_solution[2]: | |
print(eq_solution[0], eq_solution[1], eq_solution[2], 'Valid solution') | |
problem_solutions.append(eq_solution) | |
else: | |
print(eq_solution[0], eq_solution[1], eq_solution[2], | |
'Not a valid solutiom: A+B < C ; {0} < {1}'.format( | |
eq_solution[0] + eq_solution[1], | |
eq_solution[2])) | |
print('The solutions are', problem_solutions) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment