From 2beb75b3c1f66b7460413df98290daaf52c62e02 Mon Sep 17 00:00:00 2001 From: Chris Trevino Date: Tue, 24 Mar 2020 19:41:52 -0500 Subject: [PATCH 1/5] changes --- 01week/helloworld.js | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 01week/helloworld.js diff --git a/01week/helloworld.js b/01week/helloworld.js new file mode 100644 index 000000000..3ae23b3df --- /dev/null +++ b/01week/helloworld.js @@ -0,0 +1,3 @@ +node"use strict" + + console.log("Hello World!"); \ No newline at end of file From 3f482adfbd35066151f2223268150c73b8f13974 Mon Sep 17 00:00:00 2001 From: Chris Trevino Date: Tue, 24 Mar 2020 19:49:19 -0500 Subject: [PATCH 2/5] 1stprogram --- 01week/helloworld.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/01week/helloworld.js b/01week/helloworld.js index 3ae23b3df..8274abb6f 100644 --- a/01week/helloworld.js +++ b/01week/helloworld.js @@ -1,3 +1,3 @@ -node"use strict" +"use strict" console.log("Hello World!"); \ No newline at end of file From 12a264dcf89ab00ec2ccf7837539519cf4579578 Mon Sep 17 00:00:00 2001 From: Chris Trevino Date: Mon, 13 Apr 2020 14:32:40 -0500 Subject: [PATCH 3/5] changes --- 03week/towersOfHanoi.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/03week/towersOfHanoi.js b/03week/towersOfHanoi.js index 3cf6df049..7fa8a5233 100644 --- a/03week/towersOfHanoi.js +++ b/03week/towersOfHanoi.js @@ -19,23 +19,27 @@ function printStacks() { console.log("c: " + stacks.c); } -function movePiece() { +let + +function movePiece(startStack, endStack) { // Your code here + } -function isLegal() { +function isLegal(startStack, endStack) { // Your code here } -function checkForWin() { +function checkForWin(startStack, endStack) { // Your code here } function towersOfHanoi(startStack, endStack) { // Your code here + } From adf7bd9d6bfccc744e9e09e37f5241828c75c4df Mon Sep 17 00:00:00 2001 From: Chris Trevino Date: Tue, 14 Apr 2020 07:57:25 -0500 Subject: [PATCH 4/5] changes --- 03week/towersOfHanoi.js | 53 +++++++++++++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 7 deletions(-) diff --git a/03week/towersOfHanoi.js b/03week/towersOfHanoi.js index 7fa8a5233..b60ef0b4d 100644 --- a/03week/towersOfHanoi.js +++ b/03week/towersOfHanoi.js @@ -19,28 +19,67 @@ function printStacks() { console.log("c: " + stacks.c); } -let function movePiece(startStack, endStack) { - // Your code here - - + // Your code here, gives the move a variable + let currentPiece = stacks[startStack].pop(); + // add current piece to end stack + stacks[endStack].push(currentPiece) } function isLegal(startStack, endStack) { - // Your code here + // need to add something it can check + const legalMove = ["a", "b", "c"]; + + if(legalMove.includes(startStack) == false || legalMove.includes(endStack) == false) + { + return false; + } + + //empty stack means move is legal + if(stacks[endStack].length == 0) + { + return true; + } + + //if piece is larger move is legal + else if(stacks[startStack].slice(-1) < stacks[endStack].slice(-1)) + { + return true; + } + else + { + return false; + } } function checkForWin(startStack, endStack) { - // Your code here + // checking to win + if( stacks.b.length === 4 || stacks.c.length === 4) + { + console.log("You've won!!!!") + return true; + } + else + { + return false; + } } function towersOfHanoi(startStack, endStack) { // Your code here + if(isLegal(startStack, endStack) == true) + { + movePiece(startStack, endStack) + } + else + { + console.log("YOU SHALL NOT PASS!!") + } + checkForWin(); - } function getPrompt() { From e618de8fcf86ebad0a1f346b3d240ffbce9339a9 Mon Sep 17 00:00:00 2001 From: Chris Trevino Date: Tue, 14 Apr 2020 10:12:28 -0500 Subject: [PATCH 5/5] m --- 03week/readme | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 03week/readme diff --git a/03week/readme b/03week/readme new file mode 100644 index 000000000..25caddb38 --- /dev/null +++ b/03week/readme @@ -0,0 +1,61 @@ +function movePiece(startStack, endStack) { + // Your code here, gives the move a variable + let currentPiece = stacks[startStack].pop(); + // add current piece to end stack + stacks[endStack].push(currentPiece) +} + +function isLegal(startStack, endStack) { + // need to add something it can check + const legalMove = ["a", "b", "c"]; + + if(legalMove.includes(startStack) == false || legalMove.includes(endStack) == false) + { + return false; + } + + //empty stack means move is legal + if(stacks[endStack].length == 0) + { + return true; + } + + //if piece is larger move is legal + else if(stacks[startStack].slice(-1) < stacks[endStack].slice(-1)) + { + return true; + } + else + { + return false; + } + +} + +function checkForWin(startStack, endStack) { + // checking to win + if( stacks.b.length === 4 || stacks.c.length === 4) + { + console.log("You've won!!!!") + return true; + } + else + { + return false; + } + +} + +function towersOfHanoi(startStack, endStack) { + // Your code here + if(isLegal(startStack, endStack) == true) + { + movePiece(startStack, endStack) + } + else + { + console.log("YOU SHALL NOT PASS!!") + } + checkForWin(); + +}