htdocs/node/maths.py
2024-11-19 17:07:11 +00:00

49 lines
1.3 KiB
Python
Executable File

import sys
import random
import mathgenerator as mg
#print(mg.genList)
#print(sys.argv)
goodArray = [[],[],[],[],[],[],[]];
for x in mg.genList:
if x[4] == "algebra":
goodArray[0].append(x)
elif x[4] == "basic_math":
goodArray[1].append(x)
elif x[4] == "calculus":
goodArray[2].append(x)
elif x[4] == "computer_science":
goodArray[3].append(x)
elif x[4] == "geometry":
goodArray[4].append(x)
elif x[4] == "misc":
goodArray[5].append(x)
elif x[4] == "statistics":
goodArray[6].append(x)
topics = ["any","algebra","basic_math","calculus","computer_science","geometry","misc","statistics"]
rand_num = random.randint(0,len(mg.getGenList())-1)
if sys.argv[2] == "any":
if sys.argv[1] != "0":
while (mg.genList[rand_num][4] != topics[int(sys.argv[1])]):
rand_num = random.randint(0,len(mg.getGenList())-1)
problem, solution = mg.genById(rand_num)
topic = mg.genList[rand_num][4]
subtopic = mg.genList[rand_num][3]
else:
for i in range(len(mg.genList)):
if mg.genList[i][3] == sys.argv[2]:
problem, solution = mg.genById(i)
topic = mg.genList[i][4]
subtopic = mg.genList[i][3]
print(topic)
print(subtopic)
print(problem)
print(solution)