Skip to content

Commit

Permalink
#12 23.10.26 > 푸드파이트 문제 다시풀기
Browse files Browse the repository at this point in the history
  • Loading branch information
beurmuz committed Oct 26, 2023
1 parent ca24ca9 commit d0691fa
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/programmers/Lv_1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
Expand Down
15 changes: 7 additions & 8 deletions src/programmers/Lv_1/replay/coke.js
Original file line number Diff line number Diff line change
@@ -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));
11 changes: 6 additions & 5 deletions src/programmers/Lv_1/replay/food.js
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit d0691fa

Please sign in to comment.