Skip to content

Commit

Permalink
Create 모음사전.js
Browse files Browse the repository at this point in the history
  • Loading branch information
1two13 committed May 10, 2023
1 parent 29ac3e3 commit 2c137a7
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions programmers/Lv.2/❌/모음사전.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//! 다른 코드
function solution(word) {
const alphas = ['A', 'E', 'I', 'O', 'U'];
let isFind = false;
let answer = 0;

function recursion(depth, make) {
isFind = make === word;
answer++;

if (depth === 5 || isFind) return;
for (let i = 0; i < 5; i++) {
if (isFind) break;
recursion(depth + 1, make + alphas[i]);
}
}
recursion(0, '');

return answer - 1;
}

0 comments on commit 2c137a7

Please sign in to comment.