diff --git "a/5\354\243\274\354\260\250/12914/12914_\352\271\200\355\230\225\354\244\200.js" "b/5\354\243\274\354\260\250/12914/12914_\352\271\200\355\230\225\354\244\200.js" new file mode 100644 index 0000000..59d3e1b --- /dev/null +++ "b/5\354\243\274\354\260\250/12914/12914_\352\271\200\355\230\225\354\244\200.js" @@ -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; +} \ No newline at end of file diff --git "a/5\354\243\274\354\260\250/131127/131127_\352\271\200\355\230\225\354\244\200.js" "b/5\354\243\274\354\260\250/131127/131127_\352\271\200\355\230\225\354\244\200.js" new file mode 100644 index 0000000..afb90b7 --- /dev/null +++ "b/5\354\243\274\354\260\250/131127/131127_\352\271\200\355\230\225\354\244\200.js" @@ -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; +} \ No newline at end of file diff --git "a/5\354\243\274\354\260\250/17680/17680_\352\271\200\355\230\225\354\244\200.js" "b/5\354\243\274\354\260\250/17680/17680_\352\271\200\355\230\225\354\244\200.js" new file mode 100644 index 0000000..94ec308 --- /dev/null +++ "b/5\354\243\274\354\260\250/17680/17680_\352\271\200\355\230\225\354\244\200.js" @@ -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; +} \ No newline at end of file