Skip to content

Instantly share code, notes, and snippets.

@youngdo212
Created July 16, 2018 08:19
Show Gist options
  • Save youngdo212/1a286999fb982acee396f20fffc7ee1e to your computer and use it in GitHub Desktop.
Save youngdo212/1a286999fb982acee396f20fffc7ee1e to your computer and use it in GitHub Desktop.
function solution(n) {
let result = [];
result = result.concat(move(n, 1, 3));
return result
}
function move(depth, source, target){
if(depth === 1) return [[source, target]];
let result = [];
let other = 6 - source - target;
result = result.concat(move(depth-1, source, other));
result = result.concat([[source,target]]);
result = result.concat(move(depth-1, other, target));
return result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment