Skip to content

Commit 9d79a97

Browse files
Merge pull request #562 from dongmin115/main
[임동민] 72차 라이브코테 제출
2 parents 00ef71f + 699f4a8 commit 9d79a97

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

live7/test72/문제2/임동민.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
const input = require('fs')
2+
.readFileSync(process.platform === 'linux' ? '/dev/stdin' : './input.txt')
3+
.toString()
4+
.trim()
5+
.split('\n')
6+
.map(e=>e.split(' ').map(Number));
7+
8+
function solution() {
9+
const testCase = input;
10+
let firstCase = true;
11+
12+
for(let i=0; i<testCase.length-1; i++) {
13+
const k = testCase[i][0];
14+
const arr = testCase[i].slice(1);
15+
const result = [];
16+
const temp = [];
17+
18+
function recursive(depth,start){
19+
if(depth === 6){
20+
result.push(temp.join(' '));
21+
return;
22+
}
23+
24+
for(let i=start; i<k; i++){
25+
const curr = arr[i];
26+
temp.push(curr);
27+
recursive(depth + 1, i + 1);
28+
temp.pop();
29+
}
30+
31+
}
32+
33+
if(!firstCase){
34+
console.log('');
35+
}
36+
firstCase = false;
37+
recursive(0,0);
38+
console.log(result.join('\n'));
39+
40+
}
41+
42+
43+
}
44+
45+
solution();

live7/test72/문제3/임동민.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function solution(food) {
2+
const result = [];
3+
for(let i=1; i<food.length; i++) {
4+
const count = Math.floor(food[i] / 2);
5+
for(let j=0; j<count; j++) {
6+
result.push(i);
7+
}
8+
}
9+
const reverse = [...result].reverse();
10+
11+
return result.join('') + '0' + reverse.join('');
12+
}

0 commit comments

Comments
 (0)