Skip to content

Commit

Permalink
Merge pull request #23 from AlgoLeadMe/5-honggukang0623
Browse files Browse the repository at this point in the history
5-honggukang0623
  • Loading branch information
tgyuuAn authored Jun 27, 2024
2 parents df543fa + 3e10285 commit f85a3f1
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
3 changes: 2 additions & 1 deletion honggukang0623/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
|:----:|:---------:|:----:|:-----:|:----:|
| 1μ°¨μ‹œ | 2024.03.26 | 사칙연산 |[λΆ„μˆ˜μ˜λ§μ…ˆ]https://school.programmers.co.kr/learn/courses/30/lessons/120808 | [#5]https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/5 |
| 2μ°¨μ‹œ | 2024.03.29 | λ°°μ—΄ |[λ°°μ—΄λ‘λ°°λ§Œλ“€κΈ°]https://school.programmers.co.kr/learn/courses/30/lessons/120809 | [#7]https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/7 |
| 3μ°¨μ‹œ | 2024.04.05 | λ°°μ—΄ |[μ€‘μ•™κ°’κ΅¬ν•˜κΈ°]https://school.programmers.co.kr/learn/courses/30/lessons/120811# | [#13]https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/13 |
| 3μ°¨μ‹œ | 2024.04.05 | λ°°μ—΄ |[μ€‘μ•™κ°’κ΅¬ν•˜κΈ°]https://school.programmers.co.kr/learn/courses/30/lessons/120811# | [#13]https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/13 |
| 4μ°¨μ‹œ | 2024.04.09 | 좜λ ₯ |[μ§κ°μ‚Όκ°ν˜•μΆœλ ₯ν•˜κΈ°]https://school.programmers.co.kr/learn/courses/30/lessons/120823 | [#17]https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/17/commits|
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
function solution(polynomial) {
const values = polynomial.split(' + ');
console.log("values : ", values);
let x = 0;
let c = 0;
for(let i=0;i<values.length;i++) {
const item = values[i];
if(item[item.length-1] !== 'x') {
c += Number(item);
}
else {
// xμΌλ•Œ
const num = item.split('x')[0];
if(num === '') {
x += 1;
} else {
x += Number(num)
}
}
}
let answer = '';
if(x === 1) {
answer += 'x';
}
if(x > 1) {
answer += `${x}x`;
}

if(x === 0 && c > 0) {
answer += c;
}
else if(c > 0) {
answer += ` + ${c}`;
}
return answer;
}

0 comments on commit f85a3f1

Please sign in to comment.