Triangle exists check

This commit is contained in:
ieshaan12
2020-10-15 23:57:19 +05:30
parent 1790e31160
commit 734dd662c5

View File

@@ -216,6 +216,19 @@ def multiplyIntToMatrix22(maxMatrixVal = 10, maxRes = 100):
solution = f"[[{a*constant},{b*constant}],[{c*constant},{d*constant}]]" solution = f"[[{a*constant},{b*constant}],[{c*constant},{d*constant}]]"
return problem, solution return problem, solution
def isTriangleValid(maxSideLength = 50):
sideA = random.randint(1, maxSideLength)
sideB = random.randint(1, maxSideLength)
sideC = random.randint(1, maxSideLength)
sideSums = [sideA + sideB, sideB + sideC, sideC + sideA]
sides = [sideC, sideA, sideB]
exists = True & (sides[0] < sideSums[0]) & (sides[1] < sideSums[1]) & (sides[2] < sideSums[2])
problem = f"Does triangle with sides {sideA}, {sideB} and {sideC} exist?"
if exists:
solution = "Yes"
return problem, solution
solution = "No"
return problem, solution
# || Class Instances # || Class Instances
@@ -239,3 +252,4 @@ decimalToBinary = Generator("Decimal to Binary",14,"Binary of a=","b",DecimalToB
binaryToDecimal = Generator("Binary to Decimal",15,"Decimal of a=","b",BinaryToDecimalFunc) binaryToDecimal = Generator("Binary to Decimal",15,"Decimal of a=","b",BinaryToDecimalFunc)
fractionDivision = Generator("Fraction Division", 16, "(a/b)/(c/d)=", "x/y", divideFractionsFunc) fractionDivision = Generator("Fraction Division", 16, "(a/b)/(c/d)=", "x/y", divideFractionsFunc)
intMatrix22Multiplication = Generator("Integer Multiplication with 2x2 Matrix", 17, "k * [[a,b],[c,d]]=", "[[k*a,k*b],[k*c,k*d]]", multiplyIntToMatrix22) intMatrix22Multiplication = Generator("Integer Multiplication with 2x2 Matrix", 17, "k * [[a,b],[c,d]]=", "[[k*a,k*b],[k*c,k*d]]", multiplyIntToMatrix22)
doesTriangleExist = Generator("Triangle exists check", 18, "Does triangle with sides a, b and c exist?","Yes/No", isTriangleValid)