From d0691fadb446b529636377c9f1d284fce59366d5 Mon Sep 17 00:00:00 2001 From: beurmuz Date: Thu, 26 Oct 2023 10:20:48 +0900 Subject: [PATCH] =?UTF-8?q?#12=2023.10.26=20>=20=ED=91=B8=EB=93=9C?= =?UTF-8?q?=ED=8C=8C=EC=9D=B4=ED=8A=B8=20=EB=AC=B8=EC=A0=9C=20=EB=8B=A4?= =?UTF-8?q?=EC=8B=9C=ED=92=80=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/programmers/Lv_1/README.md | 4 ++-- src/programmers/Lv_1/replay/coke.js | 15 +++++++-------- src/programmers/Lv_1/replay/food.js | 11 ++++++----- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/programmers/Lv_1/README.md b/src/programmers/Lv_1/README.md index befc0f3a..9e77106e 100644 --- a/src/programmers/Lv_1/README.md +++ b/src/programmers/Lv_1/README.md @@ -59,8 +59,8 @@ | 55 | [1차 다트게임](./dartGame.js) | 22.07.01 | X | 정규표현식....... | | 56 | [카카오 성격 유형 검사하기](./mbti.js) | 22.08.21 | O | | | 57 | [삼총사](./threePeople.js) | 22.12.08 | △ | [23.10.26](./replay/threePeople.js) | -| 58 | [콜라 문제](./coke.js) | 22.12.08 | △ | [22.12.09](./replay/coke.js) | -| 59 | [푸드 파이트 문제](./food.js) | 22.12.11 | △ | [22.12.12](./replay/food.js) | +| 58 | [콜라 문제](./coke.js) | 22.12.08 | △ | [23.10.26](./replay/coke.js) | +| 59 | [푸드 파이트 문제](./food.js) | 22.12.11 | △ | [23.10.26](./replay/food.js) | | 60 | [가장 가까운 같은 글자](./mostNear.js) | 22.12.12 | O | | 61 | [과일 장수](./fruit.js) | 22.12.12 | △ | [22.12.13](./replay/fruit.js) | | 62 | [숫자 짝꿍](./pairOfNum.js) | 22.12.14 | △ | diff --git a/src/programmers/Lv_1/replay/coke.js b/src/programmers/Lv_1/replay/coke.js index 7ea0a9be..e35654d8 100644 --- a/src/programmers/Lv_1/replay/coke.js +++ b/src/programmers/Lv_1/replay/coke.js @@ -1,14 +1,13 @@ -"use strict"; +/** + * [수학문제] + */ function solution(a, b, n) { - let total = 0; + let answer = 0; while (n >= a) { - total += Math.floor(n / a) * b; - n = Math.floor(n / a) * b + (n % a); + answer += Math.floor(n / a) * b; + n = Math.floor(n / a) * b + (n % a); // 받은 병 개수 + 바꾸고 남은 병 개수 } - return total; + return answer; } - -console.log(solution(2, 1, 20)); -console.log(solution(3, 1, 20)); diff --git a/src/programmers/Lv_1/replay/food.js b/src/programmers/Lv_1/replay/food.js index ce749d9a..92e4aedf 100644 --- a/src/programmers/Lv_1/replay/food.js +++ b/src/programmers/Lv_1/replay/food.js @@ -1,13 +1,14 @@ -"use strict"; +/** + * [단순 구현] + */ -// 1. 내가 푼 풀이 function solution(food) { let answer = "0"; for (let i = food.length - 1; i >= 0; i--) { - let calorie = i.toString(); - const repeatedFood = calorie.repeat(parseInt(food[i] / 2)); - answer = repeatedFood + answer + repeatedFood; + let cal = i.toString(); + const repeatFood = cal.repeat(parseInt(food[i] / 2)); + answer = repeatFood + answer + repeatFood; } return answer; }