Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 94e38bc

Browse files
Merge pull request codeisneverodd#39 from yongchanson/main
[220421] 풀이추가 2개, 코드 삭제 1개, 주석수정 1개
2 parents 8d4a7df + 61ab0a5 commit 94e38bc

File tree

3 files changed

+29
-15
lines changed

3 files changed

+29
-15
lines changed

‎level-1/x만큼-간격이-있는-n개의-숫자.js

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,7 @@ function solution(x, n) {
2121
return answer;
2222
}
2323

24-
//정답 3 - jaewon1676
25-
function solution(n) {
26-
let str = '';
27-
for (let i=0; i<n; i++){
28-
// 삼항 연산자와 +로 문자열을 붙여주어 추가.
29-
(i % 2 == 0 ? str = str + '수' : str = str + '박')
30-
}
31-
return str;
32-
}
33-
34-
// 정답 4 - prove-ability
24+
// 정답 3 - prove-ability
3525
function solution(x, n) {
3626
var answer = [];
3727
let i = 1;
@@ -42,4 +32,4 @@ function solution(x, n) {
4232
i++;
4333
}
4434
return answer;
45-
}
35+
}

‎level-1/직사각형-별찍기.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,18 @@ process.stdin.on('data', data => {
3737
result += "\n";
3838
}
3939
console.log(result)
40-
});
40+
});
41+
42+
//정답 3 - yongchanson
43+
process.stdin.setEncoding("utf8");
44+
process.stdin.on("data", (data) => {
45+
const n = data.split(" ");
46+
const a = Number(n[0]),
47+
b = Number(n[1]);
48+
console.log(("*".repeat(a) + `\n`).repeat(b));
49+
});
50+
/*
51+
<풀이과정>
52+
repeat() 메서드는 문자열을 주어진 횟수만큼 반복해 붙인 새로운 문자열을 반환한다. ex) str.repeat(count);
53+
'*'.repeat(a) : *를 a만큼 반복한다.
54+
*/

‎level-1/콜라츠-추측.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function solution(num) {
4646
return num == 1 ? answer : -1
4747
}
4848

49-
//정답 3 - prove-ability
49+
//정답 4 - prove-ability
5050
function solution(num) {
5151
let count = 0;
5252

@@ -62,4 +62,14 @@ function solution(num) {
6262
}
6363

6464
return count;
65-
}
65+
}
66+
67+
//정답 5 - yongchanson
68+
function solution(num) {
69+
let count = 0;
70+
while (num !== 1) {
71+
if (count++ === 500) return -1;
72+
num = num % 2 ? num * 3 + 1 : num / 2;
73+
}
74+
return count;
75+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /