Created
July 16, 2018 08:19
-
-
Save youngdo212/1a286999fb982acee396f20fffc7ee1e to your computer and use it in GitHub Desktop.
https://programmers.co.kr/learn/courses/30/lessons/12946/solution_groups?language=javascript&type=my
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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