#006758

#E07415

#E44461

contains the index into the colorSpectrum (hex code) or pointColors(rgb code) for this product on the gradient.

#008475

#B00020

#C75000

#eeeeee

#8575FF

#5991FF

$\text{START OVER}$

box3

#4D4D4D

$\text{Check}$

$\text{TRY AGAIN}$

No selection allowed for all input boxes

Fix position and allow selection for all text objects

Empty all input boxes

Reset app

\text{The two legs go on the left side. The\
hypotenuse goes on the right side.}

#252525

#757575

#949494

#DA2570

#E66B9E

#3A6ED6

#0F8538

#00a83c

#5145A8

#6557D2

#903D14

#BD6C43

\text{It is a right triangle if and only if the sum of the\squares 
of the legs are equal to the square of the\
hypotenuse.
}

#2E006758

#2EB00020

$\text{NEW NUMBER}$

$\text{CHECK}$

\times

✓ 

\text{Factors tried:}

colorsRGB: {{176 / 255, 0, 32 / 255}, {224 / 255, 116 / 255, 21 / 255}, {0, 132 / 255, 117 / 255}}
highlightRow = 1
allSelections: {}
allSelectedProducts = Sequence((allSelections(A, 1) * allSelections(A, 2)), A, 1, Length[allSelections])
randomIndex = 1170
possibleNumbers = Shuffle(Remove[Sequence[2, 99], {10, 20, 30, 40, 50, 60, 70, 80, 90}])
currentNumbers = Sequence(Element[possibleNumbers, Mod[randomIndex + A, Length[possibleNumbers]] + 1], A, 1, 7)
num7: currentNumbers(7)
num6: currentNumbers(6)
num1: currentNumbers(1)
num2: currentNumbers(2)
num3: currentNumbers(3)
num4: currentNumbers(4)
num5: currentNumbers(5)
allNums: {num1, num2, num3, num4, num5, num6, num7}
possibleProducts = RemoveUndefined(Flatten[Sequence[Sequence[If[i < j, (allNums(i) * allNums(j))], i, 1, 7], j, 1, 7]])
productLowest = Min(possibleProducts)
productHighest = Max(possibleProducts)
avgProduct: round(Min[possibleProducts] + Max[possibleProducts]) / 2
expectedProduct: (round(avgProduct / 10) * 10)
displayRange = Max(expectedProduct - productLowest, productHighest - expectedProduct)
colorIndex = Zip(If[abs((expectedProduct - A) / displayRange) > 0.75, 1, If[abs((expectedProduct - A) / displayRange) > 0.35, 2, 3]], A, allSelectedProducts)
colorSpectrum: {colorRedLight, colorOrangeLight, colorTealLight}
distanceProducts = Zip(abs(expectedProduct - A), A, possibleProducts)
closestProduct = Element(possibleProducts, IndexOf[Min[distanceProducts], distanceProducts])
countQuestion = 484
randomIndex2 = Shuffle(Sequence[1, 7])
index2Tmp = Element(randomIndex2, Mod[countQuestion, Length[randomIndex2]] + 1)
randomIndex1 = Shuffle(Sequence[1, 7])
index1 = Element(randomIndex1, Mod[countQuestion, Length[randomIndex1]] + 1)
index2 = If(index1 ≟ index2Tmp, Mod[index1 + 1, Length[randomIndex2]] + 1, index2Tmp)
expectedFactors: {allNums(index1), allNums(index2)}
allColors = Zip(If[abs((expectedProduct - A) / displayRange) > 0.75, colorSpectrum(1), If[abs((expectedProduct - A) / displayRange) > 0.35, colorSpectrum(2), colorSpectrum(3)]], A, allSelectedProducts)
windowMin: 1
coloredData = Sequence((((((If[highlightRow ≟ A, (("\textcolor{" * colorSpectrum(colorIndex(A))) * "}\fbox"), "\fbox\textcolor{#252525}"] * "{") * allSelections(A, 1)) * "\times") * allSelections(A, 2)) * "}"), A, 1, Length[allSelections])
AnchorLine: (-40, 0)
productRange: productHighest - productLowest
P7 = (19.782733079985626, 23.208003332803102)
P6 = (12.282733079985626, 23.208003332803102)
P5 = (4.782733079985626, 23.208003332803102)
P4 = (-2.7172669200143744, 23.208003332803102)
P3 = (-10.217266920014374, 23.208003332803102)
P2 = (-17.717266920014374, 23.208003332803102)
P1 = (-25.217266920014374, 23.208003332803102)
randomIndices = Shuffle({1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2})
opIndex3 = Element(randomIndices, Mod[countQuestion + 2, Length[randomIndices]] + 1)
opIndex2 = Element(randomIndices, Mod[countQuestion + 1, Length[randomIndices]] + 1)
opIndex1 = Element(randomIndices, Mod[countQuestion, Length[randomIndices]] + 1)
caseNum: Mod[countQuestion, 5] + 1
startIndex: Mod[countQuestion, 9] + 1
scale: 1
boxWidth: 5
boxHeight: boxWidth
Anchor1 = (-7.217266920014373, 16.208003332803102)
Anchor2: Anchor1 + ((boxWidth * 2), 0)
region2 = makeBox(Anchor2 + (((-1.2 * boxWidth)) / 2, boxHeight / 2), (1.2 * boxWidth), boxHeight)
allPoints: {P1, P2, P3, P4, P5, P6, P7}
countRegion2 = Zip(IsInRegion[A, region2], A, allPoints)
region1 = makeBox(Anchor1 + (((-1.2 * boxWidth)) / 2, boxHeight / 2), (1.2 * boxWidth), boxHeight)
countRegion1 = Zip(IsInRegion[A, region1], A, allPoints)
randomDigits5 = Shuffle(Sequence[1, 9])
randomDigits4 = Shuffle(Sequence[1, 9])
randomDigits3 = Shuffle(Sequence[1, 9])
randomDigits2 = Shuffle(Sequence[1, 9])
randomDigits1 = Shuffle(Sequence[1, 9])
allRandom = Zip(Join[{A, A}], A, {randomDigits1, randomDigits2, randomDigits3, randomDigits4, randomDigits5})
currentRandoms = Take(Element[allRandom, randomIndex], startIndex, startIndex + 4)
studentAnswers: {}
box5 = makeBox(P5, boxWidth, boxHeight)
box3 = makeBox(P3, boxWidth, boxHeight)
box2 = makeBox(P2, boxWidth, boxHeight)
box1 = makeBox(P1, boxWidth, boxHeight)
movedBox = 3
objectsMoved = false
showhint = false
showanswer = false
showsolution = false
showbuttons = true
pixelsRight: 16
pixelsLeft: 16
pixelsBottom: 10
pixelsTop: 24
Dims = Corner(5)
speed: 1
boxB = makeBox(Anchor2, boxWidth, boxHeight)
boxA = makeBox(Anchor1, boxWidth, boxHeight)
currentNum: 1
HomeAnchor: Anchor1 + (-18, 7)
LinePos = (-7.992143867225511, 13.757647634480058)
PCenter = Midpoint(Corner[2], Corner[1])
opOffset: 0.4
AnchorOp1: Anchor1 + (If[caseNum ≟ 1, (boxWidth * (1 + 1 / scale)), boxWidth] + opOffset, 0 - opOffset)
AnchorOp2: Anchor1 + (If[caseNum ≥ 3, (3 * boxWidth), (boxWidth * (3 + 1 / scale))] + opOffset, (-opOffset))
AnchorOp3: Anchor1 + ((5 * boxWidth) + opOffset, (-opOffset))
widthSoln = 18.71410019093349
StartSoln: (x(PCenter) - widthSoln / 2, 8)
box7 = makeBox(P7, boxWidth, boxHeight)
countEntries: {Sum[countRegion1], Sum[countRegion2]}
validate = false
digitText = Zip(Text[("" * A), B + (boxHeight / 2 + 0.2, ((-boxWidth)) / 2), true, true, 0, 0], A, {num1, num2, num3, num4, num5, num6, num7}, B, {P1, P2, P3, P4, P5, P6, P7})
homePoints = Sequence(HomeAnchor + (((A * 1.5) * boxWidth), 0), A, 0, 6)
allLocations = Sequence(If[countRegion1(A) ∧ (countEntries(1) ≟ 1 ∨ movedBox ≟ A), Anchor1, If[countRegion2(A) ∧ (countEntries(2) ≟ 1 ∨ movedBox ≟ A), Anchor2, homePoints(A)]], A, 1, 7)
lineLength: 80
AnchorLineEnd: AnchorLine + (lineLength, 0)
numberLine = Segment(AnchorLine, AnchorLineEnd)
minProduct = Min(possibleProducts)
maxProduct = Max(possibleProducts)
selectedFactors: {currentNumbers(IndexOf[true, countRegion1]), currentNumbers(IndexOf[true, countRegion2])}
displayMin: (-displayRange)
PointN: AnchorLine + ((0.5 * lineLength), 0)
displayMax: displayRange
allDisplayPoints = Sequence((((allSelectedProducts(A) - expectedProduct) / displayRange * lineLength / 2), 0), A, 1, Length[allSelectedProducts])
showDuplicate = false
vCorrect = Vector((0, -5), (0, -1))
correct: allSelectedProducts(Length[allSelectedProducts]) ≟ closestProduct
inputCurrent: {selectedFactors(1), selectedFactors(2)}
inputSaved: {}
checks = Sequence(If[allSelectedProducts(A) ≟ closestProduct, (("\textcolor{" * colorTealSuccess) * "}{✓ }"), ""], A, 1, Length[allSelectedProducts])
currentIndex: 1
windowMax: 10
CurrentDisplayPoint: allDisplayPoints(highlightRow)
maxTries: 22
numTries = Length(allSelections)
minMaxProduct: (Min[allNums] * Max[allNums])
textQuestion: "\text{Which two numbers could you multiply to come closest to \(" + (LaTeX[expectedProduct]) + "\)?"
lblExpected = Text(("" * expectedProduct), PointN + (0, -7), false, true, 0, 0)
textCorrect: "\text{✓ The product of these two numbers is closest to " + (LaTeX[expectedProduct]) + "!}"
allDistances = Zip(abs(A - expectedProduct), A, allSelectedProducts)
arrowCurrent = Translate(Vector[(0, 5), (0, 0)], CurrentDisplayPoint + (0, 6))
box4 = makeBox(P4, boxWidth, boxHeight)
box6 = makeBox(P6, boxWidth, boxHeight)
AnswerAnchor = (-50, 40)
cmdMoveToPos1: "SetValue(P" + (IndexOf[allSelections(highlightRow, 1), currentNumbers]) + "," + Anchor1 + ")"
cmdMoveToPos2: "SetValue(P" + (IndexOf[allSelections(highlightRow, 2), currentNumbers]) + "," + Anchor2 + ")"
test: colorsRGB(1, highlightRow)
AnchorFactors = (-45.69474720269209, -15.691069030577703)
allFactorPoints = Flatten(Sequence[Sequence[AnchorFactors + ((i * 11.2), (j * (-5.3))), i, 0, 7], j, 0, 2])
displayData = Zip(Text[("" * A), B, true, true, 1, 0], A, coloredData, B, allFactorPoints)

Tool: PixelsToPoint
PixelsToPoint(Corner1,Corner3,Corner5,PixelCoords)
Input: Corner1, Corner3, Corner5, InputPixels
Output: OutputPoint

InputPixels: (100, 200)
xRight: x(Corner3)
xLeft: x(Corner1)
yTop: y(Corner3)
yBottom: y(Corner1)
yCoord: yTop - (y(InputPixels) / y(Corner5) * (yTop - yBottom))
xCoord: (x(InputPixels) / x(Corner5) * (xRight - xLeft)) + xLeft
OutputPoint: (xCoord, yCoord)

Tool: PixelsToPoint (command PixelsToPoint1)
PixelsToPoint(Corner1,Corner3,Corner5,PixelCoords)
Input: Corner1, Corner3, Corner5, InputPixels
Output: OutputPoint

InputPixels: (100, 200)
xRight: x(Corner3)
xLeft: x(Corner1)
yTop: y(Corner3)
yBottom: y(Corner1)
yCoord: yTop - (y(InputPixels) / y(Corner5) * (yTop - yBottom))
xCoord: (x(InputPixels) / x(Corner5) * (xRight - xLeft)) + xLeft
OutputPoint: (xCoord, yCoord)

Tool: simpRadForm
simpRadForm(num)
Input: n
Output: simplestRadical

n: 35
l1 = PrimeFactors(n)
l2 = Frequency(l1)
l3 = Sequence(Sum[First[l2, i]], i, 1, Length[l2])
l4 = Zip(Mod[a, 2], a, l2)
l5: l2 - l4
before = Zip((l1(a))^(b), a, l3, b, l4)
a = Product(before)
l6 = Zip((l1(a))^(b), a, l3, b, l5)
after: sqrt(Product[l6])
simplestRadical: "" + (LaTeX[If[after > 1 ∨ a ≟ 1, after + "", ""]]) + "" + (LaTeX[If[a > 1, "\sqrt{" + a + "}", ""]]) + ""

Tool: makeBox
makeBox(point, width,height)
Input: PointText1, boxWidth, boxHeight
Output: BoxText1

PointText2: PointText1 + (boxWidth, 0)
PointText3: PointText2 - (0, boxHeight)
PointText4: PointText1 - (0, boxHeight)
BoxText1 = Polygon({PointText1, PointText2, PointText3, PointText4})

Tool: makeBox (command makeBox1)
makeBox(point, width,height)
Input: PointText1, boxWidth, boxHeight
Output: BoxText1

PointText2: PointText1 + (boxWidth, 0)
PointText3: PointText2 - (0, boxHeight)
PointText4: PointText1 - (0, boxHeight)
BoxText1 = Polygon({PointText1, PointText2, PointText3, PointText4})

Tool: getLblCornerPos
getLabelCornerPos(A,B,C) returns corner# of label box for midpoint of each triangle side
Input: A, B, C
Output: allCornerPositions

slopeAB: (y(A) - y(B)) / (x(A) - x(B))
regionAB(x, y) = y > (slopeAB * (x - x(B))) + y(B)
cornerAB = If(IsInRegion[C, regionAB], If[slopeAB < 0, 3, 4], If[slopeAB > 0, 2, 1])
slopeCA: (y(C) - y(A)) / (x(C) - x(A))
regionCA(x, y) = y > (slopeCA * (x - x(A))) + y(A)
cornerCA = If(IsInRegion[B, regionCA], If[slopeCA < 0, 3, 4], If[slopeCA > 0, 2, 1])
slopeBC: (y(B) - y(C)) / (x(B) - x(C))
regionBC(x, y) = y > (slopeBC * (x - x(C))) + y(C)
cornerBC = If(IsInRegion[A, regionBC], If[slopeBC < 0, 3, 4], If[slopeBC > 0, 2, 1])
allCornerPositions: {cornerAB, cornerBC, cornerCA}

Tool: formatWithCommas
formatWithCommas(inputNumber)
Input: myNumber
Output: finalStr

myNumber: -234512.23412
numberParts = Split(("" * myNumber), {"-", "."})
digitStr: numberParts(1)
commaPositions = If(Length[digitStr] > 4, Append[0, Reverse[Sequence[i, i, Length[digitStr], 1, -3]]], {})
splitAtCommas = If(Length[digitStr] > 4, Zip[Take[digitStr, A + 1, B], A, commaPositions, B, Take[commaPositions, 2]], {digitStr})
numSign = If(myNumber < 0, "-", "")
fractionStr = If(Length[numberParts] ≟ 2, numberParts(2), "")
outputWholeTmp = Sum(Zip[(A * ","), A, splitAtCommas])
finalStr: "" + numSign + "" + ((Take[outputWholeTmp, 1, Length[outputWholeTmp] - 1] * If[fractionStr ≠ "", ("." * fractionStr), ""])) + ""