Skip to content

Commit 380dda1

Browse files
authored
Revert "리뷰 해주신 부분 변수명이 겹쳐서 그 부분만 수정하였습니다 바로 머지하겠습니다"
1 parent b601b63 commit 380dda1

File tree

2 files changed

+12
-14
lines changed
  • codility_training
    • lessons.lesson10.PrimeAndCompositeNumbers.Flags
    • lessons.lesson13.FibonacciNumbers.FibFrog

2 files changed

+12
-14
lines changed

codility_training/lessons.lesson10.PrimeAndCompositeNumbers.Flags/eyabc.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const next_peak = A => {
5252
function solution(A) {
5353
const N = A.length;
5454
const next = next_peak(A);
55-
let i = 1, jumps = 0;
55+
let i = 1, result = 0;
5656
while((i - 1) * i <= N) {
5757
let pos = 0, num = 0;
5858
while (pos < N && num < i) {
@@ -62,10 +62,10 @@ function solution(A) {
6262
num += 1;
6363
pos += i;
6464
}
65-
jumps = Math.max(jumps, num);
65+
result = Math.max(result, num);
6666
i += 1
6767
}
68-
return jumps
68+
return result
6969
}
7070

7171
console.log(

codility_training/lessons.lesson13.FibonacciNumbers.FibFrog/JeongShin.js

+9-11
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,22 @@ function solution(A) {
77
idx++;
88
}
99
const stack = [new frog(-1, 0)];
10-
const jumps = []; // 최소 점프수만 index 별로 저장하는 배열
10+
const count = []; // 최소 점프수만 index 별로 저장하는 배열
1111
A[len] = 1;
1212
while (stack[0] !== undefined) {
13-
const {pos, count} = stack.pop();
13+
const { pos, count } = stack.pop();
1414
for (const jump of fib) {
15-
const next_pos = pos + jump;
16-
if (A[next_pos] === 1) {
17-
const next_count = jumps[next_pos] || Infinity;
15+
const next = pos + jump;
16+
if (A[next] === 1) {
17+
const next_count = count[next] || Infinity;
1818
if (next_count > (count + 1)) {
19-
stack.push(new frog(next_pos, count + 1));
20-
jumps[next_pos] = count + 1;
19+
stack.push(new frog(next, count + 1));
20+
count[next] = count + 1;
2121
}
2222
}
2323
}
2424
}
25-
return jumps[len] || -1;
25+
return count[len] || -1;
2626
}
2727

2828
class frog {
@@ -32,6 +32,4 @@ class frog {
3232
}
3333
}
3434

35-
const r = solution([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
36-
console.log(r)
37-
35+
solution([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])

0 commit comments

Comments
 (0)