From 6e70bd1d53d56bcc6af79820d36b9e59efd3f163 Mon Sep 17 00:00:00 2001 From: callmejeje Date: Sat, 19 Nov 2022 22:28:00 +0900 Subject: [PATCH 1/4] =?UTF-8?q?[PGS]=20=EC=BD=9C=EB=9D=BC=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=20/=201=EB=8B=A8=EA=B3=84=20/=20=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\354\275\234\353\235\274_\353\254\270\354\240\234.js" | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 "\354\243\274\354\244\2218B/jueun/week04/\354\275\234\353\235\274_\353\254\270\354\240\234.js" diff --git "a/\354\243\274\354\244\2218B/jueun/week04/\354\275\234\353\235\274_\353\254\270\354\240\234.js" "b/\354\243\274\354\244\2218B/jueun/week04/\354\275\234\353\235\274_\353\254\270\354\240\234.js" new file mode 100644 index 00000000..9b094091 --- /dev/null +++ "b/\354\243\274\354\244\2218B/jueun/week04/\354\275\234\353\235\274_\353\254\270\354\240\234.js" @@ -0,0 +1,7 @@ +function solution(a, b, n, answer = 0) { + if (n < a) return answer; + let quotient = parseInt(n / a); + let remainder = n % a; + answer += quotient * b; + return solution(a, b, remainder + quotient * b, answer); +} From 636628e9984ef24960e7f3b29778729a8a681c42 Mon Sep 17 00:00:00 2001 From: callmejeje Date: Sat, 19 Nov 2022 22:30:10 +0900 Subject: [PATCH 2/4] =?UTF-8?q?[PGS]=20=EC=B2=B4=EC=9C=A1=EB=B3=B5=20/=201?= =?UTF-8?q?=EB=8B=A8=EA=B3=84=20/=20=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\354\262\264\354\234\241\353\263\265.js" | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 "\354\243\274\354\244\2218B/jueun/week04/\354\262\264\354\234\241\353\263\265.js" diff --git "a/\354\243\274\354\244\2218B/jueun/week04/\354\262\264\354\234\241\353\263\265.js" "b/\354\243\274\354\244\2218B/jueun/week04/\354\262\264\354\234\241\353\263\265.js" new file mode 100644 index 00000000..ae2efb2b --- /dev/null +++ "b/\354\243\274\354\244\2218B/jueun/week04/\354\262\264\354\234\241\353\263\265.js" @@ -0,0 +1,34 @@ +function solution(n, lost, reserve) { + // 바로 앞 or 뒷 번호 학생에게만 빌려줄 수 있다... + let students = new Array(n).fill(0); + + for (let i = 0; i < reserve.length; i++) { + // students 초기화 + students[reserve[i] - 1] = "T"; + } + for (let i = 0; i < lost.length; i++) { + if (students[lost[i] - 1] === "T") students[lost[i] - 1] = 0; + else students[lost[i] - 1] = "L"; + } + + let possible = 0; + + for (let i = 0; i < n; i++) { + if (students[i] !== "L") possible++; + } + + for (let i = 0; i < n; i++) { + // [ 0, 'L', 'T', 'L', 0 ] + if (students[i] === "L") { + for (let j = i - 1; j <= i + 1; j++) { + if (students[j] === "T") { + possible++; + students[j] = 0; + break; + } + } + } + } + + return possible; +} From fcffa052976f5887343166933a25249ad4829cf4 Mon Sep 17 00:00:00 2001 From: callmejeje Date: Sat, 19 Nov 2022 23:07:14 +0900 Subject: [PATCH 3/4] =?UTF-8?q?[PGS]=20=EB=8B=A4=EC=9D=8C=20=ED=81=B0=20?= =?UTF-8?q?=EC=88=AB=EC=9E=90=20/=202=EB=8B=A8=EA=B3=84=20/=20=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...5\214_\355\201\260_\354\210\253\354\236\220.js" | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 "\354\243\274\354\244\2218B/jueun/week04/\353\213\244\354\235\214_\355\201\260_\354\210\253\354\236\220.js" diff --git "a/\354\243\274\354\244\2218B/jueun/week04/\353\213\244\354\235\214_\355\201\260_\354\210\253\354\236\220.js" "b/\354\243\274\354\244\2218B/jueun/week04/\353\213\244\354\235\214_\355\201\260_\354\210\253\354\236\220.js" new file mode 100644 index 00000000..848738ef --- /dev/null +++ "b/\354\243\274\354\244\2218B/jueun/week04/\353\213\244\354\235\214_\355\201\260_\354\210\253\354\236\220.js" @@ -0,0 +1,14 @@ +function solution(n) { + let binary = n.toString(2); + let numOfOnes = binary.split("").filter((el) => el === "1").length; + + while (true) { + binary = (++n).toString(2); + let newNumOfOnes = binary.split("").filter((el) => el === "1").length; + if (numOfOnes === newNumOfOnes) { + return n; + } + } + + return; +} From 5d1d9aa5f61ae310cf941eab39020d53b2b78938 Mon Sep 17 00:00:00 2001 From: callmejeje Date: Sat, 19 Nov 2022 23:14:11 +0900 Subject: [PATCH 4/4] =?UTF-8?q?[PGS]=20=ED=94=BC=EB=B3=B4=EB=82=98?= =?UTF-8?q?=EC=B9=98=20=EC=88=98=20/=202=EB=8B=A8=EA=B3=84=20/=20=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...74\353\263\264\353\202\230\354\271\230_\354\210\230.js" | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 "\354\243\274\354\244\2218B/jueun/week04/\355\224\274\353\263\264\353\202\230\354\271\230_\354\210\230.js" diff --git "a/\354\243\274\354\244\2218B/jueun/week04/\355\224\274\353\263\264\353\202\230\354\271\230_\354\210\230.js" "b/\354\243\274\354\244\2218B/jueun/week04/\355\224\274\353\263\264\353\202\230\354\271\230_\354\210\230.js" new file mode 100644 index 00000000..7a718578 --- /dev/null +++ "b/\354\243\274\354\244\2218B/jueun/week04/\355\224\274\353\263\264\353\202\230\354\271\230_\354\210\230.js" @@ -0,0 +1,7 @@ +function solution(n) { + let fib = [0, 1]; + for (let i = 2; i <= n; i++) { + fib[i] = (fib[i - 1] + fib[i - 2]) % 1234567; + } + return fib[n]; +}