Skip to content

Instantly share code, notes, and snippets.

@aaronjorbin
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaronjorbin/05db01bbbc1d3d85883a to your computer and use it in GitHub Desktop.
Save aaronjorbin/05db01bbbc1d3d85883a to your computer and use it in GitHub Desktop.
var arguments = process.argv.slice(2)
if ( typeof(arguments[0]) === 'undefined'){
console.log( 'please enter a number of coins' )
process.exit(1)
}
function move(n, a, b, c) {
if (n > 0) {
move(n-1, a, c, b)
console.log("Move disk from " + a + " to " + c)
move(n-1, b, a, c)
}
}
move( arguments[0], "A", "B", "C");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment