someone said i needed to push this

This commit is contained in:
dan-schneider42 2022-12-09 21:59:43 +01:00
parent 96f7cc5a57
commit 3f03c38957

View File

@ -2,8 +2,9 @@ let output = document.getElementById("output");
let errorOutput = document.getElementById("error"); let errorOutput = document.getElementById("error");
let input; let input;
let linesArr; let linesArr;
let parsedArr = []; let parsedArr = [[], [], [], [], [], [], [], [], []];
let cmdArr = []; let cmdArr = [];
let copy9001 = [];
function readFile(input) { function readFile(input) {
let file = input.files[0]; let file = input.files[0];
@ -38,16 +39,25 @@ start.addEventListener("click", () => {
errorOutput.innerHTML = "senk ju~ *UwU~"; errorOutput.innerHTML = "senk ju~ *UwU~";
} }
parseCmd(); parseCmd();
copy9001 = [].concat(parsedArr);
console.log("🚀 ~ file: script.js:44 ~ start.addEventListener ~ copy9001", copy9001)
for(let i=0; i<cmdArr.length; i++) { for(let i=0; i<cmdArr.length; i++) {
move(cmdArr[i][0], cmdArr[i][1], cmdArr[i][2]); move(cmdArr[i][0], cmdArr[i][1], cmdArr[i][2]);
//move9001(cmdArr[i][0], cmdArr[i][1], cmdArr[i][2]);
} }
let answer = ""; let answer = "";
for(let i=0; i<parsedArr.length; i++) { for(let i=0; i<parsedArr.length; i++) {
answer += parsedArr[i][getTopPos(i)]; answer += parsedArr[i][parsedArr[i].length - 1];
}
let answer2 = "";
for(let i=0; i<copy9001.length; i++) {
answer2 += copy9001[i][copy9001[i].length - 1];
} }
console.log("parsedArr after move()", parsedArr); console.log("parsedArr after move()", parsedArr);
console.log("ANSWER UwU", answer); console.log("ANSWER UwU", answer, answer2);
output.innerHTML += " " + answer + " &nbsp;&nbsp;&nbsp; ╭∩╮UwU╭∩╮"; output.innerHTML += " " + answer + ", " + answer2 + " &nbsp;&nbsp;&nbsp; ╭∩╮UwU╭∩╮";
}); });
function parseArr() { //parsing is hard function parseArr() { //parsing is hard
@ -81,35 +91,32 @@ function parseArr() { //parsing is hard
console.log("cleanArr", cleanArr); console.log("cleanArr", cleanArr);
for(let i=0; i<cleanArr.length; i++) { for(let i=0; i<cleanArr.length; i++) {
tmpLine = []; let c=8;
let c=7;
for(let j=0; j<8; j++) { for(let j=0; j<8; j++) {
if(cleanArr[j][i] != undefined/* || cleanArr[j][i] != null || typeof(cleanArr[j][i]) != "NaN"*/) { if(cleanArr[j][i] != undefined) {
tmpLine[c] = cleanArr[j][i]; parsedArr[i][c] = cleanArr[j][i];
console.log(tmpLine, cleanArr[j][i]);
} }
c--; c--;
} }
parsedArr[i] = tmpLine; parsedArr[i].splice(0,1);
} }
console.log("parsedArr", parsedArr); console.log("parsedArr", parsedArr);
} }
function move(a, s, d) { function move(a, s, d) {
for(let i=0; i<a; i++) { for(let i=0; i<a; i++) {
parsedArr[d-1][getTopPos(d-1)] = parsedArr[s-1][getTopPos(s-1)]; parsedArr[d-1].push(parsedArr[s-1].pop());
} }
} }
function getTopPos(s) { function move9001(a, s, d) {
let o=0; let tmpArr = [];
for(let i=0; i<parsedArr[s].length; i++) { for(let i=0; i<a; i++) {
if(parsedArr[s][i]==undefined) { tmpArr[i] = copy9001[s-1].pop();
o=i-1; }
break; for(let i=a-1; i>=0; i--) {
} copy9001[d-1].push(tmpArr[i]);
} }
return o;
} }
function parseCmd() { function parseCmd() {
@ -129,4 +136,4 @@ function parseCmd() {
cmdArr[i-10] = tmpLine; cmdArr[i-10] = tmpLine;
} }
console.log("cmdArr", cmdArr); console.log("cmdArr", cmdArr);
} }