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