From e4538927816c5d468217f982b807204705e224c0 Mon Sep 17 00:00:00 2001 From: Dane Middleton Date: Fri, 4 May 2018 22:11:41 -0500 Subject: [PATCH 01/10] initial commit, start whiteboarding w pop and push details --- 03week/towersOfHanoi.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/03week/towersOfHanoi.js b/03week/towersOfHanoi.js index 3cf6df049..223d74cb2 100644 --- a/03week/towersOfHanoi.js +++ b/03week/towersOfHanoi.js @@ -7,6 +7,9 @@ const rl = readline.createInterface({ output: process.stdout }); +// pop function is mutable changes the original array by removing last item in array and returning last item in array +// push function adds an item (as argument) to an array as the last item in the array + let stacks = { a: [4, 3, 2, 1], b: [], From 47ebf2b60ff51f2a23d7e5da69b2469552b1d909 Mon Sep 17 00:00:00 2001 From: Dane Middleton Date: Fri, 4 May 2018 22:43:03 -0500 Subject: [PATCH 02/10] whiteboard movePiece and isLegal functions --- 03week/towersOfHanoi.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/03week/towersOfHanoi.js b/03week/towersOfHanoi.js index 223d74cb2..04019be8d 100644 --- a/03week/towersOfHanoi.js +++ b/03week/towersOfHanoi.js @@ -8,7 +8,10 @@ const rl = readline.createInterface({ }); // pop function is mutable changes the original array by removing last item in array and returning last item in array -// push function adds an item (as argument) to an array as the last item in the array +// push function is mutable adds an item (argument) to an array as the last item in the original array +//movePiece function uses pop function to remove last item and takes the popped item and pushes it + +//isLegal function checks if the popped item is less than the current last item in the destination array. access the last item with stacks.(array)[array.length - 1]. if the array is empty the popped item can be moved to the empty array. return true if conditions are met. let stacks = { a: [4, 3, 2, 1], From 769118af18c5b0eb3e1714f62dd1d36877d959c8 Mon Sep 17 00:00:00 2001 From: Dane Middleton Date: Fri, 4 May 2018 22:59:54 -0500 Subject: [PATCH 03/10] whiteboard checkForWin function --- 03week/towersOfHanoi.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/03week/towersOfHanoi.js b/03week/towersOfHanoi.js index 04019be8d..75e7bcf5c 100644 --- a/03week/towersOfHanoi.js +++ b/03week/towersOfHanoi.js @@ -11,7 +11,10 @@ const rl = readline.createInterface({ // push function is mutable adds an item (argument) to an array as the last item in the original array //movePiece function uses pop function to remove last item and takes the popped item and pushes it -//isLegal function checks if the popped item is less than the current last item in the destination array. access the last item with stacks.(array)[array.length - 1]. if the array is empty the popped item can be moved to the empty array. return true if conditions are met. +//isLegal function checks if the popped item is less than the current last item in the destination array. access the last item with stacks.(array)[array.length - 1]. if the array is empty the popped item can be moved to the empty array(might already pass). return true if conditions are met. + +// checkForWin function checks if stacks.b === [4, 3, 2, 1] || stacks.c === [4, 3, 2, 1], + let stacks = { a: [4, 3, 2, 1], From 14e15e56754f71abc84f2d3d926821423dd1c93e Mon Sep 17 00:00:00 2001 From: Dane Middleton Date: Fri, 4 May 2018 23:18:47 -0500 Subject: [PATCH 04/10] whiteboard towersOfHanoi function --- 03week/towersOfHanoi.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/03week/towersOfHanoi.js b/03week/towersOfHanoi.js index 75e7bcf5c..d812fe463 100644 --- a/03week/towersOfHanoi.js +++ b/03week/towersOfHanoi.js @@ -11,9 +11,12 @@ const rl = readline.createInterface({ // push function is mutable adds an item (argument) to an array as the last item in the original array //movePiece function uses pop function to remove last item and takes the popped item and pushes it -//isLegal function checks if the popped item is less than the current last item in the destination array. access the last item with stacks.(array)[array.length - 1]. if the array is empty the popped item can be moved to the empty array(might already pass). return true if conditions are met. +//isLegal function checks if the popped item is less than the current last item in the destination array. access the last item with stacks.(array)[array.length - 1]. if the array is empty the popped item can be moved to the empty array(might already pass). return true if conditions are met or console.log an error message. -// checkForWin function checks if stacks.b === [4, 3, 2, 1] || stacks.c === [4, 3, 2, 1], +// checkForWin function checks if stacks.b === [4, 3, 2, 1] || stacks.c === [4, 3, 2, 1], console.log win + +// towersOfHanoi function takes two arguments(startStack,endStack) +// start with movePiece or isLegal function. likely need to start with movePiece so there are items to check in isLegal. end with checkForWin function let stacks = { From f6be396f92d390206cf2367e28d90f00d8098dda Mon Sep 17 00:00:00 2001 From: Dane Middleton Date: Sat, 5 May 2018 20:35:09 -0500 Subject: [PATCH 05/10] working on movePiece function/begin code for other functions --- 03week/towersOfHanoi.js | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/03week/towersOfHanoi.js b/03week/towersOfHanoi.js index d812fe463..ec66b5014 100644 --- a/03week/towersOfHanoi.js +++ b/03week/towersOfHanoi.js @@ -8,10 +8,11 @@ const rl = readline.createInterface({ }); // pop function is mutable changes the original array by removing last item in array and returning last item in array -// push function is mutable adds an item (argument) to an array as the last item in the original array -//movePiece function uses pop function to remove last item and takes the popped item and pushes it +// push function is mutable adds an item (argument) to an array as the last item in the original array returning the new array length -//isLegal function checks if the popped item is less than the current last item in the destination array. access the last item with stacks.(array)[array.length - 1]. if the array is empty the popped item can be moved to the empty array(might already pass). return true if conditions are met or console.log an error message. +// movePiece function uses pop function to remove last item and takes the popped item and pushes it + +// isLegal function checks if the popped item is less than the current last item in the destination array. access the last item with stacks.(array)[array.length - 1]. if the array is empty the popped item can be moved to the empty array(might already pass). return true if conditions are met or console.log an error message. // checkForWin function checks if stacks.b === [4, 3, 2, 1] || stacks.c === [4, 3, 2, 1], console.log win @@ -19,7 +20,7 @@ const rl = readline.createInterface({ // start with movePiece or isLegal function. likely need to start with movePiece so there are items to check in isLegal. end with checkForWin function -let stacks = { +const stacks = { a: [4, 3, 2, 1], b: [], c: [] @@ -32,25 +33,31 @@ function printStacks() { } function movePiece() { - // Your code here - +// .push(.pop()); } function isLegal() { - // Your code here +// if item < array[array.length - 1] +// {return true} +// else {console.log("error, please resubmit"), return false} } function checkForWin() { - // Your code here +// if (stacks = { a: [], b: [4, 3, 2, 1], c: [] } || stacks = { a: [], b: [], c: [4, 3, 2, 1] }) { +// return true +// } else { +// return false +// } } function towersOfHanoi(startStack, endStack) { - // Your code here +// console.log(typeof(startStack)); } + function getPrompt() { printStacks(); rl.question('start stack: ', (startStack) => { From 12fc3d3014eb0fc4894729c6bcb24212b69a7111 Mon Sep 17 00:00:00 2001 From: Dane Middleton Date: Sun, 6 May 2018 08:49:10 -0500 Subject: [PATCH 06/10] movePiece function shortened --- 03week/towersOfHanoi.js | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/03week/towersOfHanoi.js b/03week/towersOfHanoi.js index ec66b5014..e426fb785 100644 --- a/03week/towersOfHanoi.js +++ b/03week/towersOfHanoi.js @@ -32,13 +32,31 @@ function printStacks() { console.log("c: " + stacks.c); } -function movePiece() { -// .push(.pop()); +function movePiece(startStack, endStack) { +// const pop = stacks[startStack] +stacks[endStack].push(stacks[startStack].pop()); + + // if (startStack === 'a' && endStack === 'b') { + // stacks.b.push(stacks.a.pop()) + // } else if (startStack === 'b' && endStack === 'a') { + // stacks.a.push(stacks.b.pop()) + // } else if (startStack === 'a' && endStack === 'c') { + // stacks.c.push(stacks.a.pop()) + // } else if (startStack === 'b' && endStack === 'c') { + // stacks.c.push(stacks.b.pop()) + // } else if (startStack === 'a' && endStack === 'c') { + // stacks.c.push(stacks.a.pop()) + // } else if (startStack === 'c' && endStack === 'a') { + // stacks.a.push(stacks.c.pop()) + // } else if (startStack === 'c' && endStack === 'b') { + // stacks.b.push(stacks.c.pop()) + // } + } -function isLegal() { -// if item < array[array.length - 1] -// {return true} +function isLegal(startStack, endStack) { +// console.log(startStack); + // else {console.log("error, please resubmit"), return false} } @@ -53,11 +71,10 @@ function checkForWin() { } function towersOfHanoi(startStack, endStack) { -// console.log(typeof(startStack)); - +movePiece(startStack, endStack); +// isLegal(startStack, endStack); } - function getPrompt() { printStacks(); rl.question('start stack: ', (startStack) => { From 247eb689a3b0b396fb2dc273abf19d664975f4dd Mon Sep 17 00:00:00 2001 From: Dane Middleton Date: Sun, 6 May 2018 09:50:34 -0500 Subject: [PATCH 07/10] update isLegal function true/false and add to towerOfHanoi function --- 03week/towersOfHanoi.js | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/03week/towersOfHanoi.js b/03week/towersOfHanoi.js index e426fb785..19c9a788a 100644 --- a/03week/towersOfHanoi.js +++ b/03week/towersOfHanoi.js @@ -11,6 +11,7 @@ const rl = readline.createInterface({ // push function is mutable adds an item (argument) to an array as the last item in the original array returning the new array length // movePiece function uses pop function to remove last item and takes the popped item and pushes it +// why doesnt stacks.startStack work? // isLegal function checks if the popped item is less than the current last item in the destination array. access the last item with stacks.(array)[array.length - 1]. if the array is empty the popped item can be moved to the empty array(might already pass). return true if conditions are met or console.log an error message. @@ -33,31 +34,15 @@ function printStacks() { } function movePiece(startStack, endStack) { -// const pop = stacks[startStack] -stacks[endStack].push(stacks[startStack].pop()); - // if (startStack === 'a' && endStack === 'b') { - // stacks.b.push(stacks.a.pop()) - // } else if (startStack === 'b' && endStack === 'a') { - // stacks.a.push(stacks.b.pop()) - // } else if (startStack === 'a' && endStack === 'c') { - // stacks.c.push(stacks.a.pop()) - // } else if (startStack === 'b' && endStack === 'c') { - // stacks.c.push(stacks.b.pop()) - // } else if (startStack === 'a' && endStack === 'c') { - // stacks.c.push(stacks.a.pop()) - // } else if (startStack === 'c' && endStack === 'a') { - // stacks.a.push(stacks.c.pop()) - // } else if (startStack === 'c' && endStack === 'b') { - // stacks.b.push(stacks.c.pop()) - // } +stacks[endStack].push(stacks[startStack].pop()); } function isLegal(startStack, endStack) { -// console.log(startStack); - -// else {console.log("error, please resubmit"), return false} +if (stacks[startStack][stacks[startStack].length - 1] > stacks[endStack][stacks[endStack].length - 1]) {console.log("false")} +else if (stacks[endStack] == 0) {console.log("true")} +else {console.log("true")} } @@ -71,8 +56,9 @@ function checkForWin() { } function towersOfHanoi(startStack, endStack) { -movePiece(startStack, endStack); -// isLegal(startStack, endStack); +if (isLegal(startStack, endStack) == true); +{movePiece(startStack, endStack)}; + } function getPrompt() { From bc3a54d420bd4170816463ccbcc928751213926c Mon Sep 17 00:00:00 2001 From: Dane Middleton Date: Mon, 7 May 2018 14:52:26 -0500 Subject: [PATCH 08/10] passing tests --- 03week/towersOfHanoi.js | 62 ++++++++++++++++++++++++++++------------- 1 file changed, 42 insertions(+), 20 deletions(-) diff --git a/03week/towersOfHanoi.js b/03week/towersOfHanoi.js index 19c9a788a..eb5acec59 100644 --- a/03week/towersOfHanoi.js +++ b/03week/towersOfHanoi.js @@ -11,22 +11,26 @@ const rl = readline.createInterface({ // push function is mutable adds an item (argument) to an array as the last item in the original array returning the new array length // movePiece function uses pop function to remove last item and takes the popped item and pushes it -// why doesnt stacks.startStack work? +// -------why doesnt stacks.startStack work?---------- // isLegal function checks if the popped item is less than the current last item in the destination array. access the last item with stacks.(array)[array.length - 1]. if the array is empty the popped item can be moved to the empty array(might already pass). return true if conditions are met or console.log an error message. -// checkForWin function checks if stacks.b === [4, 3, 2, 1] || stacks.c === [4, 3, 2, 1], console.log win +// checkForWin function checks if stacks.b == [4, 3, 2, 1] || stacks.c == [4, 3, 2, 1], console.log win. +//-----create variable winning array and compare stacks.b and stacks.c with ==,not working------ +// index[3] == 1 worked to pass test // towersOfHanoi function takes two arguments(startStack,endStack) // start with movePiece or isLegal function. likely need to start with movePiece so there are items to check in isLegal. end with checkForWin function +// ----console.log & return throws error, return in checkforwin function and log in towersofhanoi function------ -const stacks = { +let stacks = { a: [4, 3, 2, 1], b: [], c: [] }; + function printStacks() { console.log("a: " + stacks.a); console.log("b: " + stacks.b); @@ -35,30 +39,36 @@ function printStacks() { function movePiece(startStack, endStack) { -stacks[endStack].push(stacks[startStack].pop()); + stacks[endStack].push(stacks[startStack].pop()); } function isLegal(startStack, endStack) { -if (stacks[startStack][stacks[startStack].length - 1] > stacks[endStack][stacks[endStack].length - 1]) {console.log("false")} -else if (stacks[endStack] == 0) {console.log("true")} -else {console.log("true")} + if (stacks[startStack][stacks[startStack].length - 1] > stacks[endStack][stacks[endStack].length - 1]) { + return false + } else if (stacks[endStack] == 0) { + return true; + } else { + return true; + } } function checkForWin() { -// if (stacks = { a: [], b: [4, 3, 2, 1], c: [] } || stacks = { a: [], b: [], c: [4, 3, 2, 1] }) { -// return true -// } else { -// return false -// } - -} + if (stacks.b[3] == 1 || stacks.c[3] == 1) { + return true + } else { + return false + } +}; function towersOfHanoi(startStack, endStack) { -if (isLegal(startStack, endStack) == true); -{movePiece(startStack, endStack)}; - + if (isLegal(startStack, endStack)) { + movePiece(startStack, endStack); + if (checkForWin()) { + console.log('you moved a tower') + }; + } } function getPrompt() { @@ -78,7 +88,11 @@ if (typeof describe === 'function') { describe('#towersOfHanoi()', () => { it('should be able to move a block', () => { towersOfHanoi('a', 'b'); - assert.deepEqual(stacks, { a: [4, 3, 2], b: [1], c: [] }); + assert.deepEqual(stacks, { + a: [4, 3, 2], + b: [1], + c: [] + }); }); }); @@ -102,9 +116,17 @@ if (typeof describe === 'function') { }); describe('#checkForWin()', () => { it('should detect a win', () => { - stacks = { a: [], b: [4, 3, 2, 1], c: [] }; + stacks = { + a: [], + b: [4, 3, 2, 1], + c: [] + }; assert.equal(checkForWin(), true); - stacks = { a: [1], b: [4, 3, 2], c: [] }; + stacks = { + a: [1], + b: [4, 3, 2], + c: [] + }; assert.equal(checkForWin(), false); }); }); From 64a0076ccee853edca678e8ffda6958972251209 Mon Sep 17 00:00:00 2001 From: Dane Middleton Date: Tue, 8 May 2018 17:18:07 -0500 Subject: [PATCH 09/10] create tests, resetGame function, and legalMove function --- 03week/towersOfHanoi.js | 65 +++++++++++++++++++++++++++++++++++------ 1 file changed, 56 insertions(+), 9 deletions(-) diff --git a/03week/towersOfHanoi.js b/03week/towersOfHanoi.js index eb5acec59..ddaf963f6 100644 --- a/03week/towersOfHanoi.js +++ b/03week/towersOfHanoi.js @@ -24,6 +24,10 @@ const rl = readline.createInterface({ // ----console.log & return throws error, return in checkforwin function and log in towersofhanoi function------ +// legalMove function combine isLegal and movePiece into one function + +// resetGame function if checkforWin is true, stacks is reset to have all stacks in a array. entered stacks = to reset + let stacks = { a: [4, 3, 2, 1], b: [], @@ -31,19 +35,19 @@ let stacks = { }; -function printStacks() { +const printStacks = () => { console.log("a: " + stacks.a); console.log("b: " + stacks.b); console.log("c: " + stacks.c); } -function movePiece(startStack, endStack) { +const movePiece = (startStack, endStack) => { stacks[endStack].push(stacks[startStack].pop()); } -function isLegal(startStack, endStack) { +const isLegal = (startStack, endStack) => { if (stacks[startStack][stacks[startStack].length - 1] > stacks[endStack][stacks[endStack].length - 1]) { return false } else if (stacks[endStack] == 0) { @@ -54,7 +58,7 @@ function isLegal(startStack, endStack) { } -function checkForWin() { +const checkForWin = () => { if (stacks.b[3] == 1 || stacks.c[3] == 1) { return true } else { @@ -62,16 +66,34 @@ function checkForWin() { } }; -function towersOfHanoi(startStack, endStack) { +const legalMove = (startStack, endStack) => { if (isLegal(startStack, endStack)) { movePiece(startStack, endStack); - if (checkForWin()) { - console.log('you moved a tower') + } +} + +const resetGame = () => { + if (checkForWin()) { + stacks = { + a: [4, 3, 2, 1], + b: [], + c: [] }; } } -function getPrompt() { +const towersOfHanoi = (startStack, endStack) => { + + legalMove(startStack, endStack); + + if (checkForWin()) { + console.log('you win. now move the tower again') + + }; + resetGame(); +} + +const getPrompt = () => { printStacks(); rl.question('start stack: ', (startStack) => { rl.question('end stack: ', (endStack) => { @@ -95,7 +117,26 @@ if (typeof describe === 'function') { }); }); }); - + describe('#movePiece()', () => { + it('should be able to move a block', () => { + towersOfHanoi('a', 'c'); + assert.deepEqual(stacks, { + a: [4, 3], + b: [1], + c: [2] + }); + }); + }); + describe('#legalMove()', () => { + it('should be able to move a block', () => { + towersOfHanoi('a', 'c'); + assert.deepEqual(stacks, { + a: [4, 3], + b: [1], + c: [2] + }); + }); + }); describe('#isLegal()', () => { it('should not allow an illegal move', () => { stacks = { @@ -122,6 +163,12 @@ if (typeof describe === 'function') { c: [] }; assert.equal(checkForWin(), true); + stacks = { + a: [], + b: [], + c: [4, 3, 2, 1] + }; + assert.equal(checkForWin(), true); stacks = { a: [1], b: [4, 3, 2], From 4dce078350d728b0b43d94d550bc55732406e84f Mon Sep 17 00:00:00 2001 From: Dane Middleton Date: Tue, 15 May 2018 13:33:19 -0500 Subject: [PATCH 10/10] simplified isLegal and checkForWin removing if statements and only returning statement evaluation. legalMove and isLegal performing same function.remove legalMove. update towersOfHanoi organization. reset only when checkForWin. --- 03week/towersOfHanoi.js | 205 +++++++++++++++++++--------------------- 1 file changed, 97 insertions(+), 108 deletions(-) diff --git a/03week/towersOfHanoi.js b/03week/towersOfHanoi.js index ddaf963f6..c29eb9dc7 100644 --- a/03week/towersOfHanoi.js +++ b/03week/towersOfHanoi.js @@ -48,29 +48,18 @@ const movePiece = (startStack, endStack) => { } const isLegal = (startStack, endStack) => { - if (stacks[startStack][stacks[startStack].length - 1] > stacks[endStack][stacks[endStack].length - 1]) { - return false - } else if (stacks[endStack] == 0) { - return true; - } else { - return true; - } - + return (stacks[endStack] == 0 || stacks[startStack][stacks[startStack].length - 1] < stacks[endStack][stacks[endStack].length - 1]) } const checkForWin = () => { - if (stacks.b[3] == 1 || stacks.c[3] == 1) { - return true - } else { - return false - } + return (stacks.b[3] == 1 || stacks.c[3] == 1) }; -const legalMove = (startStack, endStack) => { - if (isLegal(startStack, endStack)) { - movePiece(startStack, endStack); - } -} +// const legalMove = (startStack, endStack) => { +// if (isLegal(startStack, endStack)) { +// movePiece(startStack, endStack); +// } +// const resetGame = () => { if (checkForWin()) { @@ -84,102 +73,102 @@ const resetGame = () => { const towersOfHanoi = (startStack, endStack) => { - legalMove(startStack, endStack); - - if (checkForWin()) { - console.log('you win. now move the tower again') - - }; - resetGame(); + if (isLegal(startStack, endStack)) { + movePiece(startStack, endStack); + } + if (checkForWin()) { + console.log('you win. now move the tower again') + resetGame(); + }; } -const getPrompt = () => { - printStacks(); - rl.question('start stack: ', (startStack) => { - rl.question('end stack: ', (endStack) => { - towersOfHanoi(startStack, endStack); - getPrompt(); - }); - }); -} + const getPrompt = () => { + printStacks(); + rl.question('start stack: ', (startStack) => { + rl.question('end stack: ', (endStack) => { + towersOfHanoi(startStack, endStack); + getPrompt(); + }); + }); + } -// Tests + // Tests -if (typeof describe === 'function') { + if (typeof describe === 'function') { - describe('#towersOfHanoi()', () => { - it('should be able to move a block', () => { - towersOfHanoi('a', 'b'); - assert.deepEqual(stacks, { - a: [4, 3, 2], - b: [1], - c: [] + describe('#towersOfHanoi()', () => { + it('should be able to move a block', () => { + towersOfHanoi('a', 'b'); + assert.deepEqual(stacks, { + a: [4, 3, 2], + b: [1], + c: [] + }); + }); + }); + describe('#movePiece()', () => { + it('should be able to move a block', () => { + towersOfHanoi('a', 'c'); + assert.deepEqual(stacks, { + a: [4, 3], + b: [1], + c: [2] + }); + }); + }); + describe('#legalMove()', () => { + it('should be able to move a block', () => { + towersOfHanoi('a', 'c'); + assert.deepEqual(stacks, { + a: [4, 3], + b: [1], + c: [2] + }); + }); }); - }); - }); - describe('#movePiece()', () => { - it('should be able to move a block', () => { - towersOfHanoi('a', 'c'); - assert.deepEqual(stacks, { - a: [4, 3], - b: [1], - c: [2] + describe('#isLegal()', () => { + it('should not allow an illegal move', () => { + stacks = { + a: [4, 3, 2], + b: [1], + c: [] + }; + assert.equal(isLegal('a', 'b'), false); + }); + it('should allow a legal move', () => { + stacks = { + a: [4, 3, 2, 1], + b: [], + c: [] + }; + assert.equal(isLegal('a', 'c'), true); + }); }); - }); - }); - describe('#legalMove()', () => { - it('should be able to move a block', () => { - towersOfHanoi('a', 'c'); - assert.deepEqual(stacks, { - a: [4, 3], - b: [1], - c: [2] + describe('#checkForWin()', () => { + it('should detect a win', () => { + stacks = { + a: [], + b: [4, 3, 2, 1], + c: [] + }; + assert.equal(checkForWin(), true); + stacks = { + a: [], + b: [], + c: [4, 3, 2, 1] + }; + assert.equal(checkForWin(), true); + stacks = { + a: [1], + b: [4, 3, 2], + c: [] + }; + assert.equal(checkForWin(), false); + }); }); - }); - }); - describe('#isLegal()', () => { - it('should not allow an illegal move', () => { - stacks = { - a: [4, 3, 2], - b: [1], - c: [] - }; - assert.equal(isLegal('a', 'b'), false); - }); - it('should allow a legal move', () => { - stacks = { - a: [4, 3, 2, 1], - b: [], - c: [] - }; - assert.equal(isLegal('a', 'c'), true); - }); - }); - describe('#checkForWin()', () => { - it('should detect a win', () => { - stacks = { - a: [], - b: [4, 3, 2, 1], - c: [] - }; - assert.equal(checkForWin(), true); - stacks = { - a: [], - b: [], - c: [4, 3, 2, 1] - }; - assert.equal(checkForWin(), true); - stacks = { - a: [1], - b: [4, 3, 2], - c: [] - }; - assert.equal(checkForWin(), false); - }); - }); - -} else { - - getPrompt(); -} + } else { + + getPrompt(); + + }