🛠 some readme fixup

This commit is contained in:
D-T-666
2020-10-19 23:02:18 +04:00
parent 98df83242e
commit 339e279d0a
2 changed files with 20 additions and 11 deletions

View File

@@ -2,6 +2,17 @@
# NOTE: not anymore. but still leaving this comment in. # NOTE: not anymore. but still leaving this comment in.
from mathgenerator.mathgen import * from mathgenerator.mathgen import *
def array2markdown_table(string):
string = string.replace("[[", "<table><tr><td>")
string = string.replace("[", "<tr><td>")
string = string.replace(", ", "</td><td>")
string = string.replace("]]", "</td></tr></table>")
string = string.replace("]", "</td></tr>")
string = string.replace(" ", "")
string = string.replace("\n", "")
return string
wList = getGenList() wList = getGenList()
lines = [] lines = []
with open('mathgenerator/mathgen.py', 'r') as f: with open('mathgenerator/mathgen.py', 'r') as f:
@@ -17,13 +28,11 @@ for item in wList:
solu = str(solu).rstrip("\n") solu = str(solu).rstrip("\n")
# edge case for matrixMultiplication # edge case for matrixMultiplication
if item[0] == 46: if item[0] == 46:
prob = prob.replace("[[", "<table><tr><td>") prob, solu = myGen(10, 4)
prob = prob.replace("[", "<tr><td>") prob = str(prob).rstrip("\n")
prob = prob.replace(", ", "</td><td>") solu = str(solu).rstrip("\n")
prob = prob.replace("]]\n", "</td></tr></table>") prob = array2markdown_table(prob)
prob = prob.replace("]\n", "</td></tr>") solu = array2markdown_table(solu)
prob = prob.replace(" ", "")
prob = prob.replace("\n", "")
instName = lines[line] instName = lines[line]
func_name = instName[:instName.find('=')].strip() # NOTE: renamed 'def_name' to 'func_name' because it suits it more func_name = instName[:instName.find('=')].strip() # NOTE: renamed 'def_name' to 'func_name' because it suits it more

View File

@@ -1,10 +1,10 @@
from .__init__ import * from .__init__ import *
def matrixMultiplicationFunc(maxVal=100): def matrixMultiplicationFunc(maxVal=100, max_dim=10):
m = random.randint(2, 10) m = random.randint(2, max_dim)
n = random.randint(2, 10) n = random.randint(2, max_dim)
k = random.randint(2, 10) k = random.randint(2, max_dim)
# generate matrices a and b # generate matrices a and b
a = [] a = []