Skip to content

Commit e4cadea

Browse files
committed
Solve : 홀짝 칵테일
1 parent 0811f99 commit e4cadea

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

Bronze/BOJ21312.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Solution 1
2+
function solution(nums) {
3+
const oddNums = nums.filter((num) => num % 2 !== 0);
4+
5+
if (oddNums.length > 0) {
6+
return oddNums.reduce((acc, cur) => acc * cur, 1);
7+
}
8+
9+
return nums.reduce((acc, cur) => acc * cur, 1);
10+
}
11+
12+
const fs = require('fs');
13+
const input = fs.readFileSync('/dev/stdin').toString().trim();
14+
const nums = input.split(' ').map((num) => Number(num));
15+
16+
console.log(solution(nums));

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
| 주차 | 난이도 | 문제 | JS 풀이 코드 |
112112
| :--------------------------: | :--------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
113113
| 1주차<br />(05.01. ~ 05.08.) | `Bronze 4`<br />`Bronze 2`<br />`Bronze 3`<br />`Bronze 2` | [윤년](https://www.acmicpc.net/problem/2753)<br />[!밀비 급일](https://www.acmicpc.net/problem/2753)<br />[공약수](https://www.acmicpc.net/problem/5618)<br />[진법 변환](https://www.acmicpc.net/problem/2745) | [JS](https://github.com/JeongHwan-dev/Algorithm-solving-with-js/blob/master/Bronze/BOJ2753.js)<br />[JS](https://github.com/JeongHwan-dev/Algorithm-solving-with-js/blob/master/Bronze/BOJ11365.js)<br />[JS](https://github.com/JeongHwan-dev/Algorithm-solving-with-js/blob/master/Bronze/BOJ5618.js)<br />[JS](https://github.com/JeongHwan-dev/Algorithm-solving-with-js/blob/master/Bronze/BOJ2747.js) |
114-
| 2주차<br />(05.09. ~ 05.15.) | `Bronze 2` | [알파벳 개수](https://www.acmicpc.net/problem/10808) | [JS](https://github.com/JeongHwan-dev/Algorithm-solving-with-js/blob/master/Bronze/BOJ10808.js) |
114+
| 2주차<br />(05.09. ~ 05.15.) | `Bronze 2`<br />`Bronze 3` | [알파벳 개수](https://www.acmicpc.net/problem/10808)<br />[홀짝 칵테일](https://www.acmicpc.net/problem/21312) | [JS](https://github.com/JeongHwan-dev/Algorithm-solving-with-js/blob/master/Bronze/BOJ10808.js)<br />[JS](https://github.com/JeongHwan-dev/Algorithm-solving-with-js/blob/master/Bronze/BOJ21312.js) |
115115
| 3주차<br />(05.16. ~ 05.22.) | - | - | - |
116116
| 4주차<br />(05.23. ~ 05.29.) | - | - | - |
117117
| 5주차<br />(05.30. ~ 05.31.) | - | - | - |

0 commit comments

Comments
 (0)