figbertmath

[RADIOACTIVE] miscellaneous math programs in website form
git clone git://git.figbert.com/figbertmath.git
Log | Files | Refs | README

commit 65e534d99c7f92d15be067c2cb79f541123dee88
parent e817fb1cdf15e264c98309e9c99a43f7c889e6cb
Author: therealFIGBERT <naomi@Naomis-MacBook-Air.local>
Date:   Wed, 12 Jun 2019 11:55:23 -0700

Adding consecNum program

Diffstat:
AconsecutiveNum/consecutiveNum.js | 122+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AconsecutiveNum/index.html | 56++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AconsecutiveNum/main.css | 78++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mindex.html | 12++++++++----
Mmain.css | 10++++++++--
Mmatrix/index.html | 6+++---
Mmatrix/matrix.js | 34+++++++++++++++++-----------------
Dsources/hamburgerIcon.png | 0
8 files changed, 292 insertions(+), 26 deletions(-)

diff --git a/consecutiveNum/consecutiveNum.js b/consecutiveNum/consecutiveNum.js @@ -0,0 +1,121 @@ +function getSum(total, num) { + "use strict"; + return total + num; +} + +//STOPPED AT K +function solveConsec(amount, sum, type) { + "use strict"; + var + numAmount = parseInt(amount, 10), + numSum = parseInt(sum, 10), + smallestNum = 0, + allNums = []; + switch (type) { + case "odd": + if (numSum > 0) { + smallestNum = 1; + var a = 0; + for (var b = 0; b < numAmount; b++) { + allNums.push(smallestNum + a); + a += 2; + } + while (allNums.reduce(getSum) !== numSum && allNums.reduce(getSum) < numSum) { + for (var c = 0; c < allNums.length; c++) { + allNums[c] += 2; + } + } + if (allNums.reduce(getSum) > numSum) { + document.getElementById("out").innerHTML = "Unfortunately, the combination entered does not have an answer. Try again with another set of values." + } else { + document.getElementById("out").innerHTML = "Success! The " + numAmount + " consecutive numbers that equal " + numSum + " are " + allNums + "."; + } + } else if (numSum < 0) { + smallestNum = -1; + var d = 0; + for (var e = 0; e < numAmount; e++) { + allNums.push(smallestNum + d); + d -= 2; + } + while (allNums.reduce(getSum) !== numSum && allNums.reduce(getSum) > numSum) { + for (var f = 0; f < allNums.length; f++) { + allNums[f] -= 2; + } + } + if (allNums.reduce(getSum) > numSum) { + document.getElementById("out").innerHTML = "Unfortunately, the combination entered does not have an answer. Try again with another set of values." + } else { + document.getElementById("out").innerHTML = "Success! The " + numAmount + " consecutive numbers that equal " + numSum + " are " + allNums + "."; + } + } + break; + case "even": + if (numSum > 0) { + var a = 0; + for (var b = 0; b < numAmount; b++) { + allNums.push(smallestNum + a); + a += 2; + } + while (allNums.reduce(getSum) !== numSum && allNums.reduce(getSum) < numSum) { + for (var c = 0; c < allNums.length; c++) { + allNums[c] += 2; + } + } + if (allNums.reduce(getSum) > numSum) { + document.getElementById("out").innerHTML = "Unfortunately, the combination entered does not have an answer. Try again with another set of values." + } else { + document.getElementById("out").innerHTML = "Success! The " + numAmount + " consecutive numbers that equal " + numSum + " are " + allNums + "."; + } + } else if (numSum < 0) { + var d = 0; + for (var e = 0; e < numAmount; e++) { + allNums.push(smallestNum + d); + d -= 2; + } + while (allNums.reduce(getSum) !== numSum && allNums.reduce(getSum) > numSum) { + for (var f = 0; f < allNums.length; f++) { + allNums[f] -= 2; + } + } + if (allNums.reduce(getSum) > numSum) { + document.getElementById("out").innerHTML = "Unfortunately, the combination entered does not have an answer. Try again with another set of values." + } else { + document.getElementById("out").innerHTML = "Success! The " + numAmount + " consecutive numbers that equal " + numSum + " are " + allNums + "."; + } + } + break; + case "mixed": + if (numSum > 0) { + for (var g = 0; g < numAmount; g++) { + allNums.push(smallestNum + g); + } + while (allNums.reduce(getSum) !== numSum && allNums.reduce(getSum) < numSum) { + for (var h = 0; h < allNums.length; h++) { + allNums[h]++; + } + } + if (allNums.reduce(getSum) > numSum) { + document.getElementById("out").innerHTML = "Unfortunately, the combination entered does not have an answer. Try again with another set of values." + } else { + document.getElementById("out").innerHTML = "Success! The " + numAmount + " consecutive numbers that equal " + numSum + " are " + allNums + "."; + } + } else if (numSum < 0) { + var i = 0; + for (var j = 0; j < numAmount; j++) { + allNums.push(smallestNum + i); + i--; + } + while (allNums.reduce(getSum) !== numSum && allNums.reduce(getSum) > numSum) { + for (var k = 0; k < allNums.length; k++) { + allNums[k]--; + } + } + if (allNums.reduce(getSum) > numSum) { + document.getElementById("out").innerHTML = "Unfortunately, the combination entered does not have an answer. Try again with another set of values." + } else { + document.getElementById("out").innerHTML = "Success! The " + numAmount + " consecutive numbers that equal " + numSum + " are " + allNums + "."; + } + } + break; + } +} +\ No newline at end of file diff --git a/consecutiveNum/index.html b/consecutiveNum/index.html @@ -0,0 +1,55 @@ +<!DOCTYPE html> + +<html> + <head> + <title>FIGBERT Math - C.N.F.</title> + <meta charset="utf-8"> + <link href="main.css" rel="stylesheet"> + </head> + <body> + <header> + <h1>Consecutive Number Solver</h1> + <h2>by FIGBERT</h2> + </header> + <main> + <form> + <fieldset> + <legend id="bigBox">Configure the number set</legend> + <fieldset> + <legend>Set the amount of numbers</legend> + <label for="numSet">There are <input type="number" step="1" min="2" id="numSet" class="numSet"> numbers</label> + </fieldset> + <fieldset> + <legend>Set the sum of the numbers</legend> + <label for="sumSet">The sum of the numbers is <input type="number" step="1" id="sumSet" class="numSet"></label> + </fieldset> + <fieldset> + <legend>Set the type of the numbers</legend> + <label for="odd"><input type="radio" id="odd" name="numType" value="odd"> Odd</label> + <label for="even"><input type="radio" id="even" name="numType" value="even"> Even</label> + <label for="mixed"><input type="radio" id="mixed" name="numType" value="mixed"> Mixed</label> + </fieldset> + <input type="button" value="Solve" onclick="solveConsec(numSet.value, sumSet.value, numType.value)" id="setButton"> + </fieldset> + <h3>Output:</h3> + <p id="out"></p> + </form> + </main> + <footer> + <a href="/index.html" class="footer-text">Home</a> + <div class="dot"></div> + <a href="about/" class="footer-text">About</a> + <div class="dot"></div> + <a href="requests/" class="footer-text">Request New Program</a> + <div class="dot"></div> + <a href="submit/" class="footer-text">Submit Code</a> + </footer> + </body> +</html> +<script src="consecutiveNum.js"></script> + +<!-- QUESTIONS: + +How many numbers? +Sum of the numbers? +Odd/Even/Both? +\ No newline at end of file diff --git a/consecutiveNum/main.css b/consecutiveNum/main.css @@ -0,0 +1,77 @@ +* { + font-family: sans-serif, monospace; + margin: 0px; +} + +body { + background-color: #1A181C; +} + +header { + background-color: #643181; + text-align: center; + width: 100%; +} + +h1 { + padding: 5px 0px 5px 0px; + font-size: 30px; + color: #B494C7; +} + +header h2 { + color: #B494C7; + padding-bottom: 10px; + font-size: 15px; +} + +main { + margin-top: 10px; + color: #ACA0B2; + border-color: #ACA0B2; +} + +.numSet { + width: 3%; +} + +footer { + display: flex; + flex-direction: row; + justify-content: flex-start; + align-items: center; + position: fixed; + bottom: 0; + width: 100%; +} + +.footer-text { + color: #ACA0B2; + font-size: 10px; + margin: 10px; +} + +.dot { + background-color: #ACA0B2; + width: 4px; + height: 4px; + border-radius: 50px; +} + +input { + background-color: #8E60A7; + color: #ACA0B2; + border-color: #ACA0B2; +} + +#bigBox { + font-weight: 900; +} + +#setButton { + margin-top: 9px; +} + +h3 { + margin: 10px 0px 10px 0px; +} +\ No newline at end of file diff --git a/index.html b/index.html @@ -5,17 +5,21 @@ PURPLE: http://paletton.com/#uid=14H0u0k4U5c3wyY8GFFemvpl3of --> -<head> - <title>FIGBERT Math</title> - <link rel="stylesheet" type="text/css" href="main.css"> -</head> <html> + <head> + <title>FIGBERT Math</title> + <link rel="stylesheet" type="text/css" href="main.css"> + </head> <body> <header> <h1>FIGBERT Math</h1> <h2>Custom Math Programs for Everyday Use</h2> </header> <div id="programs"> + <ul> + <li><a href="matrix/" class="programList">Subsequent Equation Solver</a></li> + <li><a href="consecutiveNum/" class="programList">Consecutive Number Solver</a></li> + </ul> </div> <footer> <a href="about/" class="footer-text">About</a> diff --git a/main.css b/main.css @@ -11,8 +11,6 @@ header { background-color: #643181; text-align: center; width: 100%; - position: fixed; - top: 0; } h1 { @@ -52,4 +50,12 @@ footer { position: fixed; bottom: 0; width: 100%; +} + +ul { + color: #ACA0B2; +} + +.programList { + color: #ACA0B2; } \ No newline at end of file diff --git a/matrix/index.html b/matrix/index.html @@ -2,7 +2,7 @@ <html> <head> - <title>Matrix</title> + <title>FIGBERT Math - S.E.S.</title> <meta charset="utf-8"> <link href="matrix.css" rel="stylesheet"> </head> @@ -18,7 +18,7 @@ <label for="two"><input id="two" type="radio" name="eqSet" value="2">Two equations, two variables</label><br> <label for="three"><input id="three" type="radio" name="eqSet" value="3">Three equations, three variables</label><br> <label for="four"><input id="four" type="radio" name="eqSet" value="4">Four equations, four variables</label><br> - <input type="button" value="Set" onclick="setUp(eqSet.value)"> + <input type="button" value="Set" onclick="setUpMatrix(eqSet.value)"> </fieldset> <fieldset id="equations"> <legend>Set the equation values</legend> @@ -50,7 +50,7 @@ <label for="zFour" class="z"><input id="zFour" type="number" name="setFour" class="numSet z a" step="0.01">z</label> <label for="equalsFour">=<input id="equalsFour" type="number" name="setFour" class="numSet a" step="0.01"></label> </div> - <input type="button" value="Solve" onclick="solve(eqSet.value)"> + <input type="button" value="Solve" onclick="solveMatrix(eqSet.value)"> </fieldset> </form> <div id="out"> diff --git a/matrix/matrix.js b/matrix/matrix.js @@ -42,7 +42,7 @@ function show(elements) { } //setUp() will determine the number of equations and variables and adjust the html accordingly. -function setUp(num) { +function setUpMatrix(num) { "use strict"; var allW = document.getElementsByClassName("w"), @@ -102,8 +102,8 @@ function answerFour(one, two, three, four) { return [w, x, y, z]; } -//solveTwo() accepts two equations as input and simplifies the second -function solveTwo(one, two) { +//solveTwoMatrix() accepts two equations as input and simplifies the second +function solveTwoMatrix(one, two) { "use strict"; var multOne = lcm(one[0], two[0]) / one[0], @@ -122,12 +122,12 @@ function solveTwo(one, two) { return two; } -//solveThree() accepts three equations as input and outputs the simplified second and third -function solveThree(one, two, three) { +//solveThreeMatrix() accepts three equations as input and outputs the simplified second and third +function solveThreeMatrix(one, two, three) { "use strict"; var - simpleTwo = solveTwo(one, two), - simpleThree = solveTwo(one, three), + simpleTwo = solveTwoMatrix(one, two), + simpleThree = solveTwoMatrix(one, three), multTwo = lcm(simpleTwo[1], simpleThree[1]) / simpleTwo[1], multThree = lcm(simpleTwo[1], simpleThree[1]) / simpleThree[1], changingTwo = simpleTwo.slice(); @@ -144,12 +144,12 @@ function solveThree(one, two, three) { return [simpleTwo, simpleThree]; } -//solveFour() accepts four equations as input and outputs the simplified second, third, and fourth -function solveFour(one, two, three, four) { +//solveFourMatrix() accepts four equations as input and outputs the simplified second, third, and fourth +function solveFourMatrix(one, two, three, four) { "use strict"; var - simpleTwoThree = solveThree(one, two, three), - simpleFour = solveTwo(one, four), + simpleTwoThree = solveThreeMatrix(one, two, three), + simpleFour = solveTwoMatrix(one, four), changingTwo = simpleTwoThree[0], changingThree = simpleTwoThree[1], multTwo = lcm(changingTwo[1], simpleFour[1]) / changingTwo[1], @@ -180,14 +180,14 @@ function solveFour(one, two, three, four) { return [simpleTwoThree[0], simpleTwoThree[1], simpleFour]; } -//solve() uses a combination of other functions to simplify the matrix -function solve(dimension) { +//solveMatrix() uses a combination of other functions to simplify the matrix +function solveMatrix(dimension) { "use strict"; if (dimension == 2) { var firstXY = [parseInt(document.getElementById("xOne").value), parseInt(document.getElementById("yOne").value), parseInt(document.getElementById("equalsOne").value)], secondXY = [parseInt(document.getElementById("xTwo").value), parseInt(document.getElementById("yTwo").value), parseInt(document.getElementById("equalsTwo").value)], - answerXY = solveTwo(firstXY, secondXY), + answerXY = solveTwoMatrix(firstXY, secondXY), valuesXY = answerTwo(firstXY, answerXY); show([document.getElementById("out")]); hide([document.getElementById("titleThree"), document.getElementById("outThree"), document.getElementById("titleFour"), document.getElementById("outFour"), document.getElementById("wValue"), document.getElementById("zValue")]); @@ -200,7 +200,7 @@ function solve(dimension) { firstXYZ = [parseInt(document.getElementById("xOne").value), parseInt(document.getElementById("yOne").value), parseInt(document.getElementById("zOne").value), parseInt(document.getElementById("equalsOne").value)], secondXYZ = [parseInt(document.getElementById("xTwo").value), parseInt(document.getElementById("yTwo").value), parseInt(document.getElementById("zTwo").value), parseInt(document.getElementById("equalsTwo").value)], thirdXYZ = [parseInt(document.getElementById("xThree").value), parseInt(document.getElementById("yThree").value), parseInt(document.getElementById("zThree").value), parseInt(document.getElementById("equalsThree").value)], - answerXYZ = solveThree(firstXYZ, secondXYZ, thirdXYZ), + answerXYZ = solveThreeMatrix(firstXYZ, secondXYZ, thirdXYZ), valuesXYZ = answerThree(firstXYZ, answerXYZ[0], answerXYZ[1]); show([document.getElementById("out"), document.getElementById("titleThree")]); document.getElementById("outThree").style.display = "block"; @@ -217,7 +217,7 @@ function solve(dimension) { secondWXYZ = [parseInt(document.getElementById("wTwo").value), parseInt(document.getElementById("xTwo").value), parseInt(document.getElementById("yTwo").value), parseInt(document.getElementById("zTwo").value), parseInt(document.getElementById("equalsTwo").value)], thirdWXYZ = [parseInt(document.getElementById("wThree").value), parseInt(document.getElementById("xThree").value), parseInt(document.getElementById("yThree").value), parseInt(document.getElementById("zThree").value), parseInt(document.getElementById("equalsThree").value)], fourthWXYZ = [parseInt(document.getElementById("wFour").value), parseInt(document.getElementById("xFour").value), parseInt(document.getElementById("yFour").value), parseInt(document.getElementById("zFour").value), parseInt(document.getElementById("equalsFour").value)], - answerWXYZ = solveFour(firstWXYZ, secondWXYZ, thirdWXYZ, fourthWXYZ), + answerWXYZ = solveFourMatrix(firstWXYZ, secondWXYZ, thirdWXYZ, fourthWXYZ), valuesWXYZ = answerFour(firstWXYZ, answerWXYZ[0], answerWXYZ[1], answerWXYZ[2]); show([document.getElementById("out")]); document.getElementById("outOne").innerHTML = "[" + firstWXYZ[0] + ", " + firstWXYZ[1] + ", " + firstWXYZ[2] + ", " + firstWXYZ[3] + ", " + firstWXYZ[4] + "]"; @@ -233,6 +233,6 @@ function solve(dimension) { /* FOR EXPANDABLE ALGORITHM -Some form of repeating solveTwo() with a variable that detects the location of the last zero (in: [0,0,0,4,5] out: 2) and then finds the multiple and adds +Some form of repeating solveTwoMatrix() with a variable that detects the location of the last zero (in: [0,0,0,4,5] out: 2) and then finds the multiple and adds */ \ No newline at end of file diff --git a/sources/hamburgerIcon.png b/sources/hamburgerIcon.png Binary files differ.