Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[김형준] 5주차 과제 제출 #58

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions 5주차/12914/12914_김형준.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function solution(n) {
let answer = 0;
let sol1 = 0;
let sol2 = 1;
for(let i = 2 ; i <= n + 1 ; i++) {
answer = sol1 + sol2 % 1234567;
sol1 = sol2;
sol2 = answer;
}
return answer % 1234567;
}
21 changes: 21 additions & 0 deletions 5주차/131127/131127_김형준.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
function solution(want, number, discount) {
let cnt = 0;
let cntArr = new Array(number.length).fill(0);

const equals = (a, b) => JSON.stringify(a) === JSON.stringify(b);

for (let i = 0; i < discount.length; i++) {
let thing = discount[i];

if (want.includes(thing)) {
cntArr[want.indexOf(thing)]++;
}

if (i >= 9) {
if (want.includes(discount[i - 10]))
cntArr[want.indexOf(discount[i - 10])]--;
if (equals(number, cntArr)) cnt++;
}
}
return cnt;
}
27 changes: 27 additions & 0 deletions 5주차/17680/17680_김형준.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
function solution(cacheSize, cities) {
const cache = [];
let time = 0;

if (!cacheSize) return cities.length * 5;

for (let city of cities) {
let upperCase = city.toUpperCase();
if (cache.includes(upperCase)) {
time += 1;
cache.splice(cache.indexOf(upperCase), 1);
cache.push(upperCase);
continue;
}

if (cache.length === cacheSize) {
cache.shift();
cache.push(upperCase);
time += 5;
continue;
}

cache.push(upperCase);
time += 5;
}
return time;
}