<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>raumschiff_.log</title>
        <link>https://velog.io/</link>
        <description>공부하는 벨로그</description>
        <lastBuildDate>Wed, 31 Jan 2024 08:12:55 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <image>
            <title>raumschiff_.log</title>
            <url>https://velog.velcdn.com/images/raumschiff_/profile/66916b80-18f8-4bf7-83f3-b8f23ee38e53/image.png</url>
            <link>https://velog.io/</link>
        </image>
        <copyright>Copyright (C) 2019. raumschiff_.log. All rights reserved.</copyright>
        <atom:link href="https://v2.velog.io/rss/raumschiff_" rel="self" type="application/rss+xml"/>
        <item>
            <title><![CDATA[[프로그래머스] 직사각형 별찍기]]></title>
            <link>https://velog.io/@raumschiff_/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EC%A7%81%EC%82%AC%EA%B0%81%ED%98%95-%EB%B3%84%EC%B0%8D%EA%B8%B0</link>
            <guid>https://velog.io/@raumschiff_/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EC%A7%81%EC%82%AC%EA%B0%81%ED%98%95-%EB%B3%84%EC%B0%8D%EA%B8%B0</guid>
            <pubDate>Wed, 31 Jan 2024 08:12:55 GMT</pubDate>
            <description><![CDATA[<h2 id="🗒️-문제">🗒️ 문제</h2>
<p>이 문제에는 표준 입력으로 두 개의 정수 n과 m이 주어집니다.
별(*) 문자를 이용해 가로의 길이가 n, 세로의 길이가 m인 직사각형 형태를 출력해보세요.</p>
<pre><code class="language-js"></code></pre>
<br>

<h3 id="제한-조건">제한 조건</h3>
<ul>
<li>n과 m은 각각 1000 이하인 자연수입니다.</li>
</ul>
<br>

<h3 id="예시">예시</h3>
<p>입력</p>
<pre><code>5 3</code></pre><h3 id="출력">출력</h3>
<pre><code>*****
*****
*****</code></pre><br>


<h2 id="🖋️-나의-풀이">🖋️ 나의 풀이</h2>
<pre><code class="language-js">process.stdin.setEncoding(&#39;utf8&#39;);
process.stdin.on(&#39;data&#39;, data =&gt; {
    const n = data.split(&quot; &quot;);
    const a = Number(n[0]), b = Number(n[1]);

    for (let i = 0; i &lt; b; i++) {
        let star = &quot;&quot;;
        for (let j = 0; j &lt; a; j++) {
            star += &quot;*&quot;;
        }
        console.log(star);
    }
});</code></pre>
<br>


<h2 id="💡-다른-사람들의-풀이">💡 다른 사람들의 풀이</h2>
<h3 id="-1"># 1</h3>
<pre><code class="language-js">process.stdin.setEncoding(&#39;utf8&#39;);
process.stdin.on(&#39;data&#39;, data =&gt; {
    const n = data.split(&quot; &quot;);
    const a = Number(n[0]), b = Number(n[1]);
    const row = &#39;*&#39;.repeat(a)
    for(let i =0; i &lt; b; i++){
        console.log(row)
    }

});</code></pre>
<h3 id="-2"># 2</h3>
<pre><code class="language-js">process.stdin.setEncoding(&#39;utf8&#39;);
process.stdin.on(&#39;data&#39;, data =&gt; {
    const n = data.split(&quot; &quot;);
    const a = Number(n[0]), b = Number(n[1]);
    const star = `${&#39;*&#39;.repeat(a)}\n`;

    console.log(star.repeat(b));
});</code></pre>
<br>

<hr>
<br>

<h2 id="📝-모르는-내용-찾아보기">📝 모르는 내용 찾아보기</h2>
<h2 id=""></h2>
<h3 id="-3"></h3>
]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스] 행렬의 덧셈]]></title>
            <link>https://velog.io/@raumschiff_/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%ED%96%89%EB%A0%AC%EC%9D%98-%EB%8D%A7%EC%85%88-a3ddm0y6</link>
            <guid>https://velog.io/@raumschiff_/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%ED%96%89%EB%A0%AC%EC%9D%98-%EB%8D%A7%EC%85%88-a3ddm0y6</guid>
            <pubDate>Wed, 31 Jan 2024 07:45:47 GMT</pubDate>
            <description><![CDATA[<h2 id="🗒️-문제">🗒️ 문제</h2>
<p>행렬의 덧셈은 행과 열의 크기가 같은 두 행렬의 같은 행, 같은 열의 값을 서로 더한 결과가 됩니다. 2개의 행렬 arr1과 arr2를 입력받아, 행렬 덧셈의 결과를 반환하는 함수, solution을 완성해주세요.</p>
<pre><code class="language-js"></code></pre>
<br>

<h3 id="제한-조건">제한 조건</h3>
<ul>
<li>행렬 arr1, arr2의 행과 열의 길이는 500을 넘지 않습니다.</li>
</ul>
<br>

<h3 id="입출력-예">입출력 예</h3>
<table>
<thead>
<tr>
<th align="center">arr1</th>
<th align="center">arr2</th>
<th align="center">return</th>
</tr>
</thead>
<tbody><tr>
<td align="center">[[1, 2], [2, 3]]</td>
<td align="center">[[3, 4], [5, 6]]</td>
<td align="center">[[4, 6], [7, 9]]</td>
</tr>
<tr>
<td align="center">[[1], [2]]</td>
<td align="center">[[3], [4]]</td>
<td align="center">[[4], [6]]</td>
</tr>
</tbody></table>
<br>


<h2 id="🖋️-나의-풀이">🖋️ 나의 풀이</h2>
<pre><code class="language-js">function solution(arr1, arr2) {
    let result = [[], []];

    for (let i = 0; i &lt; arr1.length; i++) {
        for (let j = 0; j &lt; arr1[i].length; j++) {
            // result[i].push(arr1[i][j] + arr2[i][j]);
            result[i][j] = arr1[i][j] + arr2[i][j];
        }
    }
    return result;
}</code></pre>
<p>처음에 위처럼 풀었는데 예제는 통과가 됐지만 제출하니까 런타임 에러가 떠서 질문하기를 보고 아래와 같이 답을 고쳤다</p>
<pre><code class="language-js">function solution(arr1, arr2) {
    let result = arr1;

    for (let i = 0; i &lt; arr1.length; i++) {
        for (let j = 0; j &lt; arr1[i].length; j++) {
            // result.push(arr1[i][j] + arr2[i][j]);
            result[i][j] = arr1[i][j] + arr2[i][j];
        }
    }
    return result;
}</code></pre>
<br>


<h2 id="💡-다른-사람들의-풀이">💡 다른 사람들의 풀이</h2>
<h3 id="-1"># 1</h3>
<pre><code class="language-js">// 문제가 개편되었습니다. 이로 인해 함수 구성이나 테스트케이스가 변경되어, 과거의 코드는 동작하지 않을 수 있습니다.
// 새로운 함수 구성을 적용하려면 [코드 초기화] 버튼을 누르세요. 단, [코드 초기화] 버튼을 누르면 작성 중인 코드는 사라집니다.
function sumMatrix(A,B){
    return A.map((arr1, idx1) =&gt; arr1.map((val, idx2) =&gt; val+B[idx1][idx2]));
}

// 아래는 테스트로 출력해 보기 위한 코드입니다.
console.log(sumMatrix([[1,2], [2,3]], [[3,4],[5,6]])) </code></pre>
<h3 id="-2"># 2</h3>
<p>이게 내가 원래 시도하려던 방식인데 이렇게 사용하는 거였군</p>
<pre><code class="language-js">function solution(arr1, arr2) {
    var answer = [[]];
    for (var i=0; i&lt;arr1.length; i++){
        answer[i] =[];
        for(var j=0; j&lt;arr1[i].length; j++){
            answer[i].push(arr1[i][j] + arr2[i][j]);
        }
    }
    return answer;
}</code></pre>
<br>

<hr>
<br>

<h2 id="📝-모르는-내용-찾아보기">📝 모르는 내용 찾아보기</h2>
<h2 id=""></h2>
<h3 id="-3"></h3>
]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스] 문자열 다루기 기본]]></title>
            <link>https://velog.io/@raumschiff_/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EB%AC%B8%EC%9E%90%EC%97%B4-%EB%8B%A4%EB%A3%A8%EA%B8%B0-%EA%B8%B0%EB%B3%B8</link>
            <guid>https://velog.io/@raumschiff_/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EB%AC%B8%EC%9E%90%EC%97%B4-%EB%8B%A4%EB%A3%A8%EA%B8%B0-%EA%B8%B0%EB%B3%B8</guid>
            <pubDate>Wed, 31 Jan 2024 06:12:23 GMT</pubDate>
            <description><![CDATA[<h2 id="🗒️-문제">🗒️ 문제</h2>
<p>문자열 s의 길이가 4 혹은 6이고, 숫자로만 구성돼있는지 확인해주는 함수, solution을 완성하세요. 예를 들어 s가 &quot;a234&quot;이면 False를 리턴하고 &quot;1234&quot;라면 True를 리턴하면 됩니다.</p>
<pre><code class="language-js"></code></pre>
<br>

<h3 id="제한-사항">제한 사항</h3>
<ul>
<li>s는 길이 1 이상, 길이 8 이하인 문자열입니다.</li>
<li>s는 영문 알파벳 대소문자 또는 0부터 9까지 숫자로 이루어져 있습니다.</li>
</ul>
<br>

<h3 id="입출력-예">입출력 예</h3>
<table>
<thead>
<tr>
<th align="center">s</th>
<th align="center">return</th>
</tr>
</thead>
<tbody><tr>
<td align="center">&quot;a234&quot;</td>
<td align="center">false</td>
</tr>
<tr>
<td align="center">&quot;1234&quot;</td>
<td align="center">true</td>
</tr>
</tbody></table>
<br>


<h2 id="🖋️-나의-풀이">🖋️ 나의 풀이</h2>
<p>정규식 사용</p>
<pre><code class="language-js">function solution(s) {
    let regex = /^[0-9]+$/;
    s.split(&quot;&quot;);

    if (regex.test(s) &amp;&amp; (s.length == 4 || s.length == 6)) {
        return true;            
    } else {
        return false;
    }
}</code></pre>
<br>


<h2 id="💡-다른-사람들의-풀이">💡 다른 사람들의 풀이</h2>
<h3 id="-1"># 1</h3>
<pre><code class="language-js">// 문제가 개편되었습니다. 이로 인해 함수 구성이나 테스트케이스가 변경되어, 과거의 코드는 동작하지 않을 수 있습니다.
// 새로운 함수 구성을 적용하려면 [코드 초기화] 버튼을 누르세요. 단, [코드 초기화] 버튼을 누르면 작성 중인 코드는 사라집니다.
function alpha_string46(s){
    var regex = /^\d{6}$|^\d{4}$/;

  return regex.test(s);
}
// 아래는 테스트로 출력해 보기 위한 코드입니다.
console.log( alpha_string46(&quot;a234&quot;) );
</code></pre>
<h3 id="-2"># 2</h3>
<pre><code class="language-js"></code></pre>
<br>

<hr>
<br>

<h2 id="📝-모르는-내용-찾아보기">📝 모르는 내용 찾아보기</h2>
<h2 id=""></h2>
<h3 id="-3"></h3>
]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스] 문자열 내림차순으로 배치하기]]></title>
            <link>https://velog.io/@raumschiff_/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EB%AC%B8%EC%9E%90%EC%97%B4-%EB%82%B4%EB%A6%BC%EC%B0%A8%EC%88%9C%EC%9C%BC%EB%A1%9C-%EB%B0%B0%EC%B9%98%ED%95%98%EA%B8%B0</link>
            <guid>https://velog.io/@raumschiff_/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EB%AC%B8%EC%9E%90%EC%97%B4-%EB%82%B4%EB%A6%BC%EC%B0%A8%EC%88%9C%EC%9C%BC%EB%A1%9C-%EB%B0%B0%EC%B9%98%ED%95%98%EA%B8%B0</guid>
            <pubDate>Sun, 28 Jan 2024 10:44:04 GMT</pubDate>
            <description><![CDATA[<h2 id="🗒️-문제">🗒️ 문제</h2>
<p>문자열 s에 나타나는 문자를 큰것부터 작은 순으로 정렬해 새로운 문자열을 리턴하는 함수, solution을 완성해주세요.
s는 영문 대소문자로만 구성되어 있으며, 대문자는 소문자보다 작은 것으로 간주합니다.</p>
<pre><code class="language-js"></code></pre>
<br>

<h3 id="제한-사항">제한 사항</h3>
<ul>
<li>str은 길이 1 이상인 문자열입니다.</li>
</ul>
<br>

<h3 id="입출력-예">입출력 예</h3>
<table>
<thead>
<tr>
<th align="center">s</th>
<th align="center">return</th>
</tr>
</thead>
<tbody><tr>
<td align="center">&quot;Zbcdefg&quot;</td>
<td align="center">&quot;gfedcbZ&quot;</td>
</tr>
</tbody></table>
<br>


<h2 id="🖋️-나의-풀이">🖋️ 나의 풀이</h2>
<pre><code class="language-js">function solution(s) {
    return s.split(&quot;&quot;).sort().reverse().join(&quot;&quot;);
}</code></pre>
<br>


<h2 id="💡-다른-사람들의-풀이">💡 다른 사람들의 풀이</h2>
<h3 id="-1"># 1</h3>
<pre><code class="language-js">function solution(s) {
  return s
    .split(&quot;&quot;)
    .sort()
    .reverse()
    .join(&quot;&quot;);
}</code></pre>
<h3 id="-2"># 2</h3>
<pre><code class="language-js">function solution(s) {
    return s.split(&#39;&#39;).sort((a, b) =&gt; {
        if (a &gt; b) return -1;
        if (b &gt; a) return 1;
        return 0;
    }).join(&#39;&#39;);
}</code></pre>
<br>

<hr>
<br>

<h2 id="📝-모르는-내용-찾아보기">📝 모르는 내용 찾아보기</h2>
<h2 id=""></h2>
<h3 id="-3"></h3>
]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스] 약수의 개수와 덧셈]]></title>
            <link>https://velog.io/@raumschiff_/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EC%95%BD%EC%88%98%EC%9D%98-%EA%B0%9C%EC%88%98%EC%99%80-%EB%8D%A7%EC%85%88</link>
            <guid>https://velog.io/@raumschiff_/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EC%95%BD%EC%88%98%EC%9D%98-%EA%B0%9C%EC%88%98%EC%99%80-%EB%8D%A7%EC%85%88</guid>
            <pubDate>Sun, 28 Jan 2024 10:37:32 GMT</pubDate>
            <description><![CDATA[<h2 id="🗒️-문제">🗒️ 문제</h2>
<p>두 정수 left와 right가 매개변수로 주어집니다. left부터 right까지의 모든 수들 중에서, 약수의 개수가 짝수인 수는 더하고, 약수의 개수가 홀수인 수는 뺀 수를 return 하도록 solution 함수를 완성해주세요.</p>
<pre><code class="language-js"></code></pre>
<br>

<h3 id="제한-사항">제한 사항</h3>
<ul>
<li>1 ≤ left ≤ right ≤ 1,000</li>
</ul>
<br>

<h3 id="입출력-예">입출력 예</h3>
<table>
<thead>
<tr>
<th align="center">left</th>
<th align="center">right</th>
<th align="center">result</th>
</tr>
</thead>
<tbody><tr>
<td align="center">13</td>
<td align="center">17</td>
<td align="center">43</td>
</tr>
<tr>
<td align="center">24</td>
<td align="center">27</td>
<td align="center">52</td>
</tr>
</tbody></table>
<h3 id="입출력-예-설명">입출력 예 설명</h3>
<h4 id="입출력-예-1">입출력 예 #1</h4>
<ul>
<li>다음 표는 13부터 17까지의 수들의 약수를 모두 나타낸 것입니다.</li>
</ul>
<table>
<thead>
<tr>
<th align="center">수</th>
<th align="center">약수</th>
<th align="center">약수의 개수</th>
</tr>
</thead>
<tbody><tr>
<td align="center">13</td>
<td align="center">1, 13</td>
<td align="center">2</td>
</tr>
<tr>
<td align="center">14</td>
<td align="center">1, 2, 7, 14</td>
<td align="center">4</td>
</tr>
<tr>
<td align="center">15</td>
<td align="center">1, 3, 5, 15</td>
<td align="center">4</td>
</tr>
<tr>
<td align="center">16</td>
<td align="center">1, 2, 4, 8, 16</td>
<td align="center">5</td>
</tr>
<tr>
<td align="center">17</td>
<td align="center">1, 17</td>
<td align="center">2</td>
</tr>
</tbody></table>
<ul>
<li>따라서, 13 + 14 + 15 - 16 + 17 = 43을 return 해야 합니다.</li>
</ul>
<h4 id="입출력-예-2">입출력 예 #2</h4>
<ul>
<li>다음 표는 24부터 27까지의 수들의 약수를 모두 나타낸 것입니다.</li>
</ul>
<table>
<thead>
<tr>
<th align="center">수</th>
<th align="center">약수</th>
<th align="center">약수의 개수</th>
</tr>
</thead>
<tbody><tr>
<td align="center">24</td>
<td align="center">1, 2, 3, 4, 6, 8, 12, 24</td>
<td align="center">8</td>
</tr>
<tr>
<td align="center">25</td>
<td align="center">1, 5, 25</td>
<td align="center">3</td>
</tr>
<tr>
<td align="center">26</td>
<td align="center">1, 2, 13, 26</td>
<td align="center">4</td>
</tr>
<tr>
<td align="center">27</td>
<td align="center">1, 3, 9, 27</td>
<td align="center">4</td>
</tr>
</tbody></table>
<ul>
<li>따라서, 24 - 25 + 26 + 27 = 52를 return 해야 합니다.</li>
</ul>
<br>


<h2 id="🖋️-나의-풀이">🖋️ 나의 풀이</h2>
<pre><code class="language-js">function solution(left, right) {
    // 약수의 개수가 홀수일 때는 제곱근일 때

    let result = 0;

    for (let i = left; i &lt;= right; i++) {
        if (Number.isInteger(Math.sqrt(i)) == true) {
            result -= i;
        } else {
            result += i;
        }
    }

    return result;
}</code></pre>
<br>


<h2 id="💡-다른-사람들의-풀이">💡 다른 사람들의 풀이</h2>
<h3 id="-1"># 1</h3>
<p>약수의 개수가 홀수면 제곱근이라는 것을 사용한 풀이</p>
<pre><code class="language-js">function solution(left, right) {
    var answer = 0;
    for (let i = left; i &lt;= right; i++) {
        if (Number.isInteger(Math.sqrt(i))) {
            answer -= i;
        } else {
            answer += i;
        }
    }
    return answer;
}</code></pre>
<h3 id="-2"># 2</h3>
<p>for문을 이용한 풀이</p>
<pre><code class="language-js">function solution(left, right) {
  let answer = 0;

  for (let i = left; i &lt;= right; i++) {
    let count = 0;
    for (let j = 1; j &lt;= i; j++) {
      if (i % j === 0) count++;
    }
    if (count % 2) answer -= i;
    else answer += i;
  }

  return answer;
}</code></pre>
<br>

<hr>
<br>

<h2 id="📝-모르는-내용-찾아보기">📝 모르는 내용 찾아보기</h2>
<h2 id=""></h2>
<h3 id="-3"></h3>
]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스] 수박수박수박수박수박수?]]></title>
            <link>https://velog.io/@raumschiff_/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EC%88%98%EB%B0%95%EC%88%98%EB%B0%95%EC%88%98%EB%B0%95%EC%88%98%EB%B0%95%EC%88%98%EB%B0%95%EC%88%98</link>
            <guid>https://velog.io/@raumschiff_/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EC%88%98%EB%B0%95%EC%88%98%EB%B0%95%EC%88%98%EB%B0%95%EC%88%98%EB%B0%95%EC%88%98%EB%B0%95%EC%88%98</guid>
            <pubDate>Fri, 19 Jan 2024 09:20:45 GMT</pubDate>
            <description><![CDATA[<h2 id="🗒️-문제">🗒️ 문제</h2>
<p>길이가 n이고, &quot;수박수박수박수....&quot;와 같은 패턴을 유지하는 문자열을 리턴하는 함수, solution을 완성하세요. 예를들어 n이 4이면 &quot;수박수박&quot;을 리턴하고 3이라면 &quot;수박수&quot;를 리턴하면 됩니다.</p>
<pre><code class="language-js"></code></pre>
<br>

<h3 id="제한-사항">제한 사항</h3>
<ul>
<li>n은 길이 10,000이하인 자연수입니다.</li>
</ul>
<br>

<h3 id="입출력-예">입출력 예</h3>
<table>
<thead>
<tr>
<th align="center">n</th>
<th align="center">return</th>
</tr>
</thead>
<tbody><tr>
<td align="center">3</td>
<td align="center">&quot;수박수&quot;</td>
</tr>
<tr>
<td align="center">4</td>
<td align="center">&quot;수박수박&quot;</td>
</tr>
</tbody></table>
<br>


<h2 id="🖋️-나의-풀이">🖋️ 나의 풀이</h2>
<pre><code class="language-js">function solution(n) {
    let result = &quot;&quot;;

    for (let i = 1; i &lt;= n; i++) {
        i % 2 == 1 ? result += &quot;수&quot; : result += &quot;박&quot;;
    }

    return result;
}</code></pre>
<br>


<h2 id="💡-다른-사람들의-풀이">💡 다른 사람들의 풀이</h2>
<h3 id="-1"># 1</h3>
<pre><code class="language-js">// 문제가 개편되었습니다. 이로 인해 함수 구성이나 테스트케이스가 변경되어, 과거의 코드는 동작하지 않을 수 있습니다.
// 새로운 함수 구성을 적용하려면 [코드 초기화] 버튼을 누르세요. 단, [코드 초기화] 버튼을 누르면 작성 중인 코드는 사라집니다.
var waterMelon = n =&gt;&#39;수박&#39;.repeat(n/2) + (n%2 === 1 ? &#39;수&#39; : &#39;&#39;);


// 실행을 위한 테스트코드입니다.
console.log(&quot;n이 3인 경우: &quot;+ waterMelon(3))
console.log(&quot;n이 4인 경우: &quot;+ waterMelon(4))</code></pre>
<h3 id="-2"># 2</h3>
<pre><code class="language-js">// 문제가 개편되었습니다. 이로 인해 함수 구성이나 테스트케이스가 변경되어, 과거의 코드는 동작하지 않을 수 있습니다.
// 새로운 함수 구성을 적용하려면 [코드 초기화] 버튼을 누르세요. 단, [코드 초기화] 버튼을 누르면 작성 중인 코드는 사라집니다.
const waterMelon = n =&gt; &quot;수박&quot;.repeat(n).slice(0,n);

console.log(&quot;n이 3인 경우: &quot;+ waterMelon(3))
console.log(&quot;n이 4인 경우: &quot;+ waterMelon(4))</code></pre>
<br>

<hr>
<br>

<h2 id="📝-모르는-내용-찾아보기">📝 모르는 내용 찾아보기</h2>
<h2 id=""></h2>
<h3 id="-3"></h3>
]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스] 가운데 글자 가져오기]]></title>
            <link>https://velog.io/@raumschiff_/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EA%B0%80%EC%9A%B4%EB%8D%B0-%EA%B8%80%EC%9E%90-%EA%B0%80%EC%A0%B8%EC%98%A4%EA%B8%B0</link>
            <guid>https://velog.io/@raumschiff_/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EA%B0%80%EC%9A%B4%EB%8D%B0-%EA%B8%80%EC%9E%90-%EA%B0%80%EC%A0%B8%EC%98%A4%EA%B8%B0</guid>
            <pubDate>Fri, 19 Jan 2024 09:18:12 GMT</pubDate>
            <description><![CDATA[<h2 id="🗒️-문제">🗒️ 문제</h2>
<p>단어 s의 가운데 글자를 반환하는 함수, solution을 만들어 보세요. 단어의 길이가 짝수라면 가운데 두글자를 반환하면 됩니다.</p>
<pre><code class="language-js"></code></pre>
<br>

<h3 id="제한-사항">제한 사항</h3>
<ul>
<li>s는 길이가 1 이상, 100이하인 스트링입니다.</li>
</ul>
<br>

<h3 id="입출력-예">입출력 예</h3>
<table>
<thead>
<tr>
<th align="center">s</th>
<th align="center">return</th>
</tr>
</thead>
<tbody><tr>
<td align="center">&quot;abcde&quot;</td>
<td align="center">&quot;c&quot;</td>
</tr>
<tr>
<td align="center">&quot;qwer&quot;</td>
<td align="center">&quot;we&quot;</td>
</tr>
</tbody></table>
<br>


<h2 id="🖋️-나의-풀이">🖋️ 나의 풀이</h2>
<pre><code class="language-js">function solution(s) {
    let arr = s.split(&quot;&quot;);
    let middle = Math.floor(arr.length / 2 - 1);

    return arr.length % 2 == 1 ? s.substr(middle + 1, 1) : s.substr(middle, 2);
}</code></pre>
<br>


<h2 id="💡-다른-사람들의-풀이">💡 다른 사람들의 풀이</h2>
<h3 id="-1"># 1</h3>
<pre><code class="language-js">function solution(s) {
    return s.substr(Math.ceil(s.length / 2) - 1, s.length % 2 === 0 ? 2 : 1);
}</code></pre>
<h3 id="-2"># 2</h3>
<pre><code class="language-js">function solution(s) {
    const mid = Math.floor(s.length/2);
    return s.length %2 === 1 ? s[mid] : s[mid-1]+s[mid];
}</code></pre>
<br>

<hr>
<br>

<h2 id="📝-모르는-내용-찾아보기">📝 모르는 내용 찾아보기</h2>
<h2 id=""></h2>
<h3 id="-3"></h3>
]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스] 내적]]></title>
            <link>https://velog.io/@raumschiff_/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EB%82%B4%EC%A0%81</link>
            <guid>https://velog.io/@raumschiff_/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EB%82%B4%EC%A0%81</guid>
            <pubDate>Fri, 19 Jan 2024 08:06:42 GMT</pubDate>
            <description><![CDATA[<h2 id="🗒️-문제">🗒️ 문제</h2>
<p>길이가 같은 두 1차원 정수 배열 a, b가 매개변수로 주어집니다. a와 b의 내적을 return 하도록 solution 함수를 완성해주세요.</p>
<p>이때, a와 b의 내적은 a[0]<em>b[0] + a[1]</em>b[1] + ... + a[n-1]*b[n-1] 입니다. (n은 a, b의 길이)</p>
<pre><code class="language-js"></code></pre>
<br>

<h3 id="제한-사항">제한 사항</h3>
<ul>
<li>a, b의 길이는 1 이상 1,000 이하입니다.</li>
<li>a, b의 모든 수는 -1,000 이상 1,000 이하입니다.</li>
</ul>
<br>

<h3 id="입출력-예">입출력 예</h3>
<table>
<thead>
<tr>
<th align="center">a</th>
<th align="center">b</th>
<th align="center">result</th>
</tr>
</thead>
<tbody><tr>
<td align="center">[1, 2, 3, 4]</td>
<td align="center">[-3, -1, 0, 2]</td>
<td align="center">3</td>
</tr>
<tr>
<td align="center">[-1, 0, -]</td>
<td align="center">[1, 0, -1]</td>
<td align="center">-2</td>
</tr>
</tbody></table>
<h3 id="입출력-예-설명">입출력 예 설명</h3>
<h4 id="입출력-예-1">입출력 예 #1</h4>
<ul>
<li>a와 b의 내적은 1<em>(-3) + 2</em>(-1) + 3<em>0 + 4</em>2 = 3 입니다.</li>
</ul>
<h4 id="입출력-예-2">입출력 예 #2</h4>
<ul>
<li>a와 b의 내적은 (-1)<em>1 + 0*0 + 1</em>(-1) = -2 입니다.</li>
</ul>
<br>


<h2 id="🖋️-나의-풀이">🖋️ 나의 풀이</h2>
<pre><code class="language-js">function solution(a, b) {
    let result = 0;

    for (let i = 0; i &lt; a.length; i++) {
        result += a[i] * b[i];
    }

    return result;
}</code></pre>
<br>


<h2 id="💡-다른-사람들의-풀이">💡 다른 사람들의 풀이</h2>
<h3 id="-1"># 1</h3>
<p><code>reduce()</code>를 쓸 때 사용하지 않는 인자는 &quot;_&quot; 로 작성할 수 있음</p>
<pre><code class="language-js">function solution(a, b) {
    return a.reduce((acc, _, i) =&gt; acc += a[i] * b[i], 0);
}</code></pre>
<h3 id="-2"># 2</h3>
<pre><code class="language-js"></code></pre>
<br>

<hr>
<br>

<h2 id="📝-모르는-내용-찾아보기">📝 모르는 내용 찾아보기</h2>
<h2 id=""></h2>
<h3 id="-3"></h3>
]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스] 제일 작은 수 제거하기]]></title>
            <link>https://velog.io/@raumschiff_/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EC%A0%9C%EC%9D%BC-%EC%9E%91%EC%9D%80-%EC%88%98-%EC%A0%9C%EA%B1%B0%ED%95%98%EA%B8%B0</link>
            <guid>https://velog.io/@raumschiff_/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EC%A0%9C%EC%9D%BC-%EC%9E%91%EC%9D%80-%EC%88%98-%EC%A0%9C%EA%B1%B0%ED%95%98%EA%B8%B0</guid>
            <pubDate>Fri, 19 Jan 2024 07:56:01 GMT</pubDate>
            <description><![CDATA[<h2 id="🗒️-문제">🗒️ 문제</h2>
<p>정수를 저장한 배열, arr 에서 가장 작은 수를 제거한 배열을 리턴하는 함수, solution을 완성해주세요. 단, 리턴하려는 배열이 빈 배열인 경우엔 배열에 -1을 채워 리턴하세요. 예를들어 arr이 [4,3,2,1]인 경우는 [4,3,2]를 리턴 하고, [10]면 [-1]을 리턴 합니다.</p>
<pre><code class="language-js"></code></pre>
<br>

<h3 id="제한-사항">제한 사항</h3>
<ul>
<li>arr은 길이 1 이상인 배열입니다.</li>
<li>인덱스 i, j에 대해 i ≠ j이면 arr[i] ≠ arr[j] 입니다.</li>
</ul>
<br>

<h3 id="입출력-예">입출력 예</h3>
<table>
<thead>
<tr>
<th align="center">arr</th>
<th align="center">return</th>
</tr>
</thead>
<tbody><tr>
<td align="center">[4, 3, 2, 1]</td>
<td align="center">[4, 3, 2]</td>
</tr>
<tr>
<td align="center">[10]</td>
<td align="center">[-1]</td>
</tr>
</tbody></table>
<br>


<h2 id="🖋️-나의-풀이">🖋️ 나의 풀이</h2>
<pre><code class="language-js">function solution(arr) {
    let minArr = Math.min(...arr); // 최소값 찾기
    let index = arr.indexOf(minArr); // 최소값 인덱스 찾기
    arr.splice(index, 1);

    return arr.length ? arr : [-1];
}</code></pre>
<br>


<h2 id="💡-다른-사람들의-풀이">💡 다른 사람들의 풀이</h2>
<h3 id="-1"># 1</h3>
<pre><code class="language-js">function solution(arr) {
    arr.splice(arr.indexOf(Math.min(...arr)),1);
    if(arr.length&lt;1)return[-1];
    return arr;
}</code></pre>
<h3 id="-2"># 2</h3>
<pre><code class="language-js">function solution(arr) {
    const min = Math.min(...arr);
    return arr.length !== 1 ? arr.filter(i =&gt; i !== min) : [-1]
}</code></pre>
<br>

<hr>
<br>

<h2 id="📝-모르는-내용-찾아보기">📝 모르는 내용 찾아보기</h2>
<h2 id=""></h2>
<h3 id="-3"></h3>
]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스] 핸드폰 번호 가리기]]></title>
            <link>https://velog.io/@raumschiff_/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%ED%95%B8%EB%93%9C%ED%8F%B0-%EB%B2%88%ED%98%B8-%EA%B0%80%EB%A6%AC%EA%B8%B0</link>
            <guid>https://velog.io/@raumschiff_/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%ED%95%B8%EB%93%9C%ED%8F%B0-%EB%B2%88%ED%98%B8-%EA%B0%80%EB%A6%AC%EA%B8%B0</guid>
            <pubDate>Wed, 17 Jan 2024 06:44:07 GMT</pubDate>
            <description><![CDATA[<h2 id="🗒️-문제">🗒️ 문제</h2>
<p>프로그래머스 모바일은 개인정보 보호를 위해 고지서를 보낼 때 고객들의 전화번호의 일부를 가립니다.
전화번호가 문자열 phone_number로 주어졌을 때, 전화번호의 뒷 4자리를 제외한 나머지 숫자를 전부 *으로 가린 문자열을 리턴하는 함수, solution을 완성해주세요.</p>
<pre><code class="language-js"></code></pre>
<br>

<h3 id="제한-조건">제한 조건</h3>
<ul>
<li>phone_number는 길이 4 이상, 20이하인 문자열입니다.</li>
</ul>
<br>

<h3 id="입출력-예">입출력 예</h3>
<table>
<thead>
<tr>
<th align="center">phone_number</th>
<th align="center">return</th>
</tr>
</thead>
<tbody><tr>
<td align="center">&quot;01033334444&quot;</td>
<td align="center">&quot;&#42;&#42;&#42;&#42;&#42;&#42;&#42;4444&quot;</td>
</tr>
<tr>
<td align="center">&quot;027778888&quot;</td>
<td align="center">&quot;&#42;&#42;&#42;&#42;&#42;8888&quot;</td>
</tr>
</tbody></table>
<br>


<h2 id="🖋️-나의-풀이">🖋️ 나의 풀이</h2>
<pre><code class="language-js">function solution(phone_number) {
    let arr = phone_number.split(&quot;&quot;).fill(&quot;*&quot;, 0, phone_number.length - 4);
    return arr.join(&quot;&quot;);
}</code></pre>
<br>


<h2 id="💡-다른-사람들의-풀이">💡 다른 사람들의 풀이</h2>
<h3 id="-1"># 1</h3>
<pre><code class="language-js">// 문제가 개편되었습니다. 이로 인해 함수 구성이나 테스트케이스가 변경되어, 과거의 코드는 동작하지 않을 수 있습니다.
// 새로운 함수 구성을 적용하려면 [코드 초기화] 버튼을 누르세요. 단, [코드 초기화] 버튼을 누르면 작성 중인 코드는 사라집니다.
function hide_numbers(s){
  return s.replace(/\d(?=\d{4})/g, &quot;*&quot;);
}

// 아래는 테스트로 출력해 보기 위한 코드입니다.
console.log(&quot;결과 : &quot; + hide_numbers(&#39;01033334444&#39;));</code></pre>
<h3 id="-2"># 2</h3>
<pre><code class="language-js">const solution = n =&gt; [...n].fill(&quot;*&quot;,0,n.length-4).join(&quot;&quot;)</code></pre>
<br>

<hr>
<br>

<h2 id="📝-모르는-내용-찾아보기">📝 모르는 내용 찾아보기</h2>
<h2 id=""></h2>
<h3 id="-3"></h3>
]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스] 없는 숫자 더하기]]></title>
            <link>https://velog.io/@raumschiff_/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EC%97%86%EB%8A%94-%EC%88%AB%EC%9E%90-%EB%8D%94%ED%95%98%EA%B8%B0</link>
            <guid>https://velog.io/@raumschiff_/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EC%97%86%EB%8A%94-%EC%88%AB%EC%9E%90-%EB%8D%94%ED%95%98%EA%B8%B0</guid>
            <pubDate>Wed, 17 Jan 2024 06:23:05 GMT</pubDate>
            <description><![CDATA[<h2 id="🗒️-문제">🗒️ 문제</h2>
<p>0부터 9까지의 숫자 중 일부가 들어있는 정수 배열 numbers가 매개변수로 주어집니다. numbers에서 찾을 수 없는 0부터 9까지의 숫자를 모두 찾아 더한 수를 return 하도록 solution 함수를 완성해주세요.</p>
<pre><code class="language-js"></code></pre>
<br>

<h3 id="제한-사항">제한 사항</h3>
<ul>
<li>1 ≤ numbers의 길이 ≤ 9<ul>
<li>0 ≤ numbers의 모든 원소 ≤ 9</li>
<li>numbers의 모든 원소는 서로 다릅니다.</li>
</ul>
</li>
</ul>
<br>

<h3 id="입출력-예">입출력 예</h3>
<table>
<thead>
<tr>
<th align="center">numbers</th>
<th align="center">result</th>
</tr>
</thead>
<tbody><tr>
<td align="center">[1, 2, 3, 4, 6, 7, 8, 0]</td>
<td align="center">14</td>
</tr>
<tr>
<td align="center">[5, 8, 4, 0, 6, 7, 9]</td>
<td align="center">6</td>
</tr>
</tbody></table>
<h3 id="입출력-예-설명">입출력 예 설명</h3>
<h4 id="입출력-예-1">입출력 예 #1</h4>
<ul>
<li>5, 9가 numbers에 없으므로, 5 + 9 = 14를 return 해야 합니다.</li>
</ul>
<h4 id="입출력-예-2">입출력 예 #2</h4>
<ul>
<li>1, 2, 3이 numbers에 없으므로, 1 + 2 + 3 = 6을 return 해야 합니다.</li>
</ul>
<br>


<h2 id="🖋️-나의-풀이">🖋️ 나의 풀이</h2>
<pre><code class="language-js">function solution(numbers) {
    let result = 0;

    numbers.sort((a, b) =&gt; a - b);

    for (let i = 0; i &lt; 10; i++) {
        if (!numbers.includes(i)) {
            result += i;
        }
    }

    return result;
}</code></pre>
<br>


<h2 id="💡-다른-사람들의-풀이">💡 다른 사람들의 풀이</h2>
<h3 id="-1"># 1</h3>
<p><code>reduce()</code>를 이용하여 전체 합으로 구하는 방법</p>
<pre><code class="language-js">function solution(numbers) {
    return 45 - numbers.reduce((cur, acc) =&gt; cur + acc, 0);
}</code></pre>
<h3 id="-2"># 2</h3>
<pre><code class="language-js"></code></pre>
<br>

<hr>
<br>

<h2 id="📝-모르는-내용-찾아보기">📝 모르는 내용 찾아보기</h2>
<h2 id=""></h2>
<h3 id="-3"></h3>
]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스] 나누어 떨어지는 숫자 배열]]></title>
            <link>https://velog.io/@raumschiff_/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EB%82%98%EB%88%84%EC%96%B4-%EB%96%A8%EC%96%B4%EC%A7%80%EB%8A%94-%EC%88%AB%EC%9E%90-%EB%B0%B0%EC%97%B4</link>
            <guid>https://velog.io/@raumschiff_/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EB%82%98%EB%88%84%EC%96%B4-%EB%96%A8%EC%96%B4%EC%A7%80%EB%8A%94-%EC%88%AB%EC%9E%90-%EB%B0%B0%EC%97%B4</guid>
            <pubDate>Tue, 16 Jan 2024 07:19:39 GMT</pubDate>
            <description><![CDATA[<h2 id="🗒️-문제">🗒️ 문제</h2>
<p>array의 각 element 중 divisor로 나누어 떨어지는 값을 오름차순으로 정렬한 배열을 반환하는 함수, solution을 작성해주세요.
divisor로 나누어 떨어지는 element가 하나도 없다면 배열에 -1을 담아 반환하세요.</p>
<pre><code class="language-js"></code></pre>
<br>

<h3 id="제한-사항">제한 사항</h3>
<ul>
<li>arr은 자연수를 담은 배열입니다.</li>
<li>정수 i, j에 대해 i ≠ j 이면 arr[i] ≠ arr[j] 입니다.</li>
<li>divisor는 자연수입니다.</li>
<li>array는 길이 1 이상인 배열입니다.</li>
</ul>
<br>

<h3 id="입출력-예">입출력 예</h3>
<table>
<thead>
<tr>
<th align="center">arr</th>
<th align="center">divisor</th>
<th align="center">return</th>
</tr>
</thead>
<tbody><tr>
<td align="center">[5, 9, 7, 10]</td>
<td align="center">5</td>
<td align="center">[5, 10]</td>
</tr>
<tr>
<td align="center">[2, 36, 1, 3]</td>
<td align="center">1</td>
<td align="center">[1, 2, 3, 36]</td>
</tr>
<tr>
<td align="center">[3, 2, 6]</td>
<td align="center">10</td>
<td align="center">[-1]</td>
</tr>
</tbody></table>
<h3 id="입출력-예-설명">입출력 예 설명</h3>
<h4 id="입출력-예-1">입출력 예 #1</h4>
<ul>
<li>arr의 원소 중 5로 나누어 떨어지는 원소는 5와 10입니다. 따라서 [5, 10]을 리턴합니다.</li>
</ul>
<h4 id="입출력-예-2">입출력 예 #2</h4>
<ul>
<li>arr의 모든 원소는 1으로 나누어 떨어집니다. 원소를 오름차순으로 정렬해 [1, 2, 3, 36]을 리턴합니다.</li>
</ul>
<h4 id="입출력-예-3">입출력 예 #3</h4>
<ul>
<li>3, 2, 6은 10으로 나누어 떨어지지 않습니다. 나누어 떨어지는 원소가 없으므로 [-1]을 리턴합니다.</li>
</ul>
<br>


<h2 id="🖋️-나의-풀이">🖋️ 나의 풀이</h2>
<pre><code class="language-js">function solution(arr, divisor) {
    let result = [];

    for (let i = 0; i &lt; arr.length; i++) {
        if (arr[i] % divisor == 0) {
            result.push(arr[i]);
            result.sort((a, b) =&gt; a - b);
        }
    }

    if (result.length == 0) {
        result.push(-1);
    }

    return result;
}</code></pre>
<br>


<h2 id="💡-다른-사람들의-풀이">💡 다른 사람들의 풀이</h2>
<h3 id="-1"># 1</h3>
<pre><code class="language-js">function solution(arr, divisor) {
    var answer = arr.filter(v =&gt; v%divisor == 0);
    return answer.length == 0 ? [-1] : answer.sort((a,b) =&gt; a-b);
}</code></pre>
<h3 id="-2"># 2</h3>
<pre><code class="language-js">function solution(arr, divisor) {
    var answer = [];
    arr.map((o) =&gt; {
        o % divisor === 0 &amp;&amp; answer.push(o);
    })
    return answer.length ? answer.sort((a, b) =&gt; a - b) : [-1];

}</code></pre>
<br>

<hr>
<br>

<h2 id="📝-모르는-내용-찾아보기">📝 모르는 내용 찾아보기</h2>
<h2 id=""></h2>
<h3 id="-3"></h3>
]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스] 서울에서 김서방 찾기]]></title>
            <link>https://velog.io/@raumschiff_/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EC%84%9C%EC%9A%B8%EC%97%90%EC%84%9C-%EA%B9%80%EC%84%9C%EB%B0%A9-%EC%B0%BE%EA%B8%B0</link>
            <guid>https://velog.io/@raumschiff_/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EC%84%9C%EC%9A%B8%EC%97%90%EC%84%9C-%EA%B9%80%EC%84%9C%EB%B0%A9-%EC%B0%BE%EA%B8%B0</guid>
            <pubDate>Tue, 16 Jan 2024 06:39:11 GMT</pubDate>
            <description><![CDATA[<h2 id="🗒️-문제">🗒️ 문제</h2>
<p>String형 배열 seoul의 element중 &quot;Kim&quot;의 위치 x를 찾아, &quot;김서방은 x에 있다&quot;는 String을 반환하는 함수, solution을 완성하세요. seoul에 &quot;Kim&quot;은 오직 한 번만 나타나며 잘못된 값이 입력되는 경우는 없습니다.</p>
<pre><code class="language-js"></code></pre>
<br>

<h3 id="제한-사항">제한 사항</h3>
<ul>
<li>seoul은 길이 1 이상, 1000 이하인 배열입니다.</li>
<li>seoul의 원소는 길이 1 이상, 20 이하인 문자열입니다.</li>
<li>&quot;Kim&quot;은 반드시 seoul 안에 포함되어 있습니다.</li>
</ul>
<br>

<h3 id="입출력-예">입출력 예</h3>
<table>
<thead>
<tr>
<th align="center">seoul</th>
<th align="center">return</th>
</tr>
</thead>
<tbody><tr>
<td align="center">[&quot;Jane&quot;, &quot;Kim&quot;]</td>
<td align="center">&quot;김서방은 1에 있다&quot;</td>
</tr>
</tbody></table>
<br>


<h2 id="🖋️-나의-풀이">🖋️ 나의 풀이</h2>
<pre><code class="language-js">function solution(seoul) {
    let result = seoul.findIndex(el =&gt; el === &quot;Kim&quot;);

    return `김서방은 ${result}에 있다`
}</code></pre>
<br>


<h2 id="💡-다른-사람들의-풀이">💡 다른 사람들의 풀이</h2>
<h3 id="-1"># 1</h3>
<pre><code class="language-js">// 문제가 개편되었습니다. 이로 인해 함수 구성이나 테스트케이스가 변경되어, 과거의 코드는 동작하지 않을 수 있습니다.
// 새로운 함수 구성을 적용하려면 [코드 초기화] 버튼을 누르세요. 단, [코드 초기화] 버튼을 누르면 작성 중인 코드는 사라집니다.
function findKim(seoul){
  var idx = seoul.indexOf(&#39;Kim&#39;);

  return &quot;김서방은 &quot; + idx + &quot;에 있다&quot;;
}

// 실행을 위한 테스트코드입니다.
console.log( findKim([&quot;Queen&quot;, &quot;Tod&quot;, &quot;Kim&quot;]));</code></pre>
<h3 id="-2"># 2</h3>
<pre><code class="language-js">function findKim(seoul){
  var idx = 0;
  //함수를 완성하세요
    for (var i = 0; i &lt; seoul.length; ++i)
  {
    if (seoul[i] == &quot;Kim&quot;)
    {
        idx = i;
      break;
    }
  }
  return &quot;김서방은 &quot; + idx + &quot;에 있다&quot;;
}

// 실행을 위한 테스트코드입니다.
console.log( findKim([&quot;Queen&quot;, &quot;Tod&quot;, &quot;Kim&quot;]));</code></pre>
<br>

<hr>
<br>

<h2 id="📝-모르는-내용-찾아보기">📝 모르는 내용 찾아보기</h2>
<h2 id=""></h2>
<h3 id="-3"></h3>
]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스] 콜라츠 추측]]></title>
            <link>https://velog.io/@raumschiff_/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EC%BD%9C%EB%9D%BC%EC%B8%A0-%EC%B6%94%EC%B8%A1</link>
            <guid>https://velog.io/@raumschiff_/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EC%BD%9C%EB%9D%BC%EC%B8%A0-%EC%B6%94%EC%B8%A1</guid>
            <pubDate>Fri, 12 Jan 2024 08:22:22 GMT</pubDate>
            <description><![CDATA[<h2 id="🗒️-문제">🗒️ 문제</h2>
<p>1937년 Collatz란 사람에 의해 제기된 이 추측은, 주어진 수가 1이 될 때까지 다음 작업을 반복하면, 모든 수를 1로 만들 수 있다는 추측입니다. 작업은 다음과 같습니다.</p>
<blockquote>
<p>1-1. 입력된 수가 짝수라면 2로 나눕니다. 
1-2. 입력된 수가 홀수라면 3을 곱하고 1을 더합니다. 
2. 결과로 나온 수에 같은 작업을 1이 될 때까지 반복합니다. </p>
</blockquote>
<p>예를 들어, 주어진 수가 6이라면 6 → 3 → 10 → 5 → 16 → 8 → 4 → 2 → 1 이 되어 총 8번 만에 1이 됩니다. 위 작업을 몇 번이나 반복해야 하는지 반환하는 함수, solution을 완성해 주세요. 단, 주어진 수가 1인 경우에는 0을, 작업을 500번 반복할 때까지 1이 되지 않는다면 –1을 반환해 주세요.</p>
<pre><code class="language-js"></code></pre>
<br>

<h3 id="제한-사항">제한 사항</h3>
<ul>
<li>입력된 수, num은 1 이상 8,000,000 미만인 정수입니다.</li>
</ul>
<br>

<h3 id="입출력-예">입출력 예</h3>
<table>
<thead>
<tr>
<th align="center">n</th>
<th align="center">result</th>
</tr>
</thead>
<tbody><tr>
<td align="center">6</td>
<td align="center">8</td>
</tr>
<tr>
<td align="center">16</td>
<td align="center">4</td>
</tr>
<tr>
<td align="center">626331</td>
<td align="center">-1</td>
</tr>
</tbody></table>
<h3 id="입출력-예-설명">입출력 예 설명</h3>
<h4 id="입출력-예-1">입출력 예 #1</h4>
<ul>
<li>문제의 설명과 같습니다.</li>
</ul>
<h4 id="입출력-예-2">입출력 예 #2</h4>
<ul>
<li>16 → 8 → 4 → 2 → 1 이 되어 총 4번 만에 1이 됩니다.</li>
</ul>
<h4 id="입출력-예-3">입출력 예 #3</h4>
<ul>
<li>626331은 500번을 시도해도 1이 되지 못하므로 -1을 리턴해야 합니다.</li>
</ul>
<br>


<h2 id="🖋️-나의-풀이">🖋️ 나의 풀이</h2>
<pre><code class="language-js">function solution(num) {
    let result = 0;
    let number = 0;

    while (num != 1) {
        if (result &gt;= 500) {
            return -1;
            break;
        }

        else {
            if (num % 2 == 0) {
                number = num / 2;
                result++;
                num = number;

            } else {
                number = num * 3 + 1;
                result++;
                num = number;
            }
        }
    }
    return result;
}</code></pre>
<br>


<h2 id="💡-다른-사람들의-풀이">💡 다른 사람들의 풀이</h2>
<h3 id="-1"># 1</h3>
<pre><code class="language-js">// 문제가 개편되었습니다. 이로 인해 함수 구성이나 테스트케이스가 변경되어, 과거의 코드는 동작하지 않을 수 있습니다.
// 새로운 함수 구성을 적용하려면 [코드 초기화] 버튼을 누르세요. 단, [코드 초기화] 버튼을 누르면 작성 중인 코드는 사라집니다.
function collatz(num) {
    var answer = 0;
    while(num !=1 &amp;&amp; answer !=500){
        num%2==0 ? num = num/2 : num = num*3 +1;
    answer++;
  }
    return num == 1 ? answer : -1;
}
// 아래는 테스트로 출력해 보기 위한 코드입니다.
console.log( collatz(6) );</code></pre>
<h3 id="-2"># 2</h3>
<pre><code class="language-js">const solution = (num) =&gt; collatzGuessCount(num, 0);

const collatzGuessCount = (num, acc) =&gt; 
  (num === 1) ? ((acc &gt; 500) ? -1 : acc) : collatzGuessCount(processCollatz(num), acc + 1);

const processCollatz = (num) =&gt; (num % 2 === 0) ? (num / 2) : (num * 3 + 1);</code></pre>
<br>

<hr>
<br>

<h2 id="📝-모르는-내용-찾아보기">📝 모르는 내용 찾아보기</h2>
<h2 id=""></h2>
<h3 id="-3"></h3>
]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스] 음양 더하기]]></title>
            <link>https://velog.io/@raumschiff_/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EC%9D%8C%EC%96%91-%EB%8D%94%ED%95%98%EA%B8%B0</link>
            <guid>https://velog.io/@raumschiff_/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EC%9D%8C%EC%96%91-%EB%8D%94%ED%95%98%EA%B8%B0</guid>
            <pubDate>Fri, 12 Jan 2024 06:46:35 GMT</pubDate>
            <description><![CDATA[<h2 id="🗒️-문제">🗒️ 문제</h2>
<p>어떤 정수들이 있습니다. 이 정수들의 절댓값을 차례대로 담은 정수 배열 absolutes와 이 정수들의 부호를 차례대로 담은 불리언 배열 signs가 매개변수로 주어집니다. 실제 정수들의 합을 구하여 return 하도록 solution 함수를 완성해주세요.</p>
<pre><code class="language-js"></code></pre>
<br>

<h3 id="제한-사항">제한 사항</h3>
<ul>
<li>absolutes의 길이는 1 이상 1,000 이하입니다.<ul>
<li>absolutes의 모든 수는 각각 1 이상 1,000 이하입니다.</li>
</ul>
</li>
<li>signs의 길이는 absolutes의 길이와 같습니다.<ul>
<li>signs[i] 가 참이면 absolutes[i] 의 실제 정수가 양수임을, 그렇지 않으면 음수임을 의미합니다.</li>
</ul>
</li>
</ul>
<br>

<h3 id="입출력-예">입출력 예</h3>
<table>
<thead>
<tr>
<th align="center">absolutes</th>
<th align="center">signs</th>
<th align="center">result</th>
</tr>
</thead>
<tbody><tr>
<td align="center">[4, 7, 12]</td>
<td align="center">[true, false, true]</td>
<td align="center">9</td>
</tr>
<tr>
<td align="center">[1, 2, 3]</td>
<td align="center">[false, false, true]</td>
<td align="center">0</td>
</tr>
</tbody></table>
<h3 id="입출력-예-설명">입출력 예 설명</h3>
<h4 id="입출력-예-1">입출력 예 #1</h4>
<ul>
<li>signs가 [true,false,true] 이므로, 실제 수들의 값은 각각 4, -7, 12입니다.</li>
<li>따라서 세 수의 합인 9를 return 해야 합니다.</li>
</ul>
<h4 id="입출력-예-2">입출력 예 #2</h4>
<ul>
<li>signs가 [false,false,true] 이므로, 실제 수들의 값은 각각 -1, -2, 3입니다.</li>
<li>따라서 세 수의 합인 0을 return 해야 합니다.</li>
</ul>
<br>


<h2 id="🖋️-나의-풀이">🖋️ 나의 풀이</h2>
<pre><code class="language-js">function solution(abs, sign) {
    let arr = [];

    for (let i = 0; i &lt; abs.length; i++) {
        sign[i] ? arr.push(abs[i]) : arr.push(-abs[i])
    }

    return arr.reduce((a, b) =&gt; a + b);
}</code></pre>
<br>


<h2 id="💡-다른-사람들의-풀이">💡 다른 사람들의 풀이</h2>
<p><code>reduce()</code>보다는 <code>for</code>문이 성능이 더 좋다고 함!</p>
<h3 id="-1"># 1</h3>
<pre><code class="language-js">function solution(absolutes, signs) {

    return absolutes.reduce((acc, val, i) =&gt; acc + (val * (signs[i] ? 1 : -1)), 0);
}</code></pre>
<h3 id="-2"># 2</h3>
<pre><code class="language-js">function solution(absolutes, signs) {
    let answer = 0;
    for (let i = 0; i &lt; absolutes.length; i++) {
        signs[i] ? answer += absolutes[i] : answer -= absolutes[i]
    }
    return answer;
}</code></pre>
<br>

<hr>
<br>

<h2 id="📝-모르는-내용-찾아보기">📝 모르는 내용 찾아보기</h2>
<h2 id=""></h2>
<h3 id="-3"></h3>
]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스] 두 정수 사이의 합]]></title>
            <link>https://velog.io/@raumschiff_/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EB%91%90-%EC%A0%95%EC%88%98-%EC%82%AC%EC%9D%B4%EC%9D%98-%ED%95%A9</link>
            <guid>https://velog.io/@raumschiff_/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EB%91%90-%EC%A0%95%EC%88%98-%EC%82%AC%EC%9D%B4%EC%9D%98-%ED%95%A9</guid>
            <pubDate>Fri, 12 Jan 2024 06:22:47 GMT</pubDate>
            <description><![CDATA[<h2 id="🗒️-문제">🗒️ 문제</h2>
<p>두 정수 a, b가 주어졌을 때 a와 b 사이에 속한 모든 정수의 합을 리턴하는 함수, solution을 완성하세요.
예를 들어 a = 3, b = 5인 경우, 3 + 4 + 5 = 12이므로 12를 리턴합니다.</p>
<pre><code class="language-js"></code></pre>
<br>

<h3 id="제한-사항">제한 사항</h3>
<ul>
<li>a와 b가 같은 경우는 둘 중 아무 수나 리턴하세요.</li>
<li>a와 b는 -10,000,000 이상 10,000,000 이하인 정수입니다.</li>
<li>a와 b의 대소관계는 정해져있지 않습니다.</li>
</ul>
<br>

<h3 id="입출력-예">입출력 예</h3>
<table>
<thead>
<tr>
<th align="center">a</th>
<th align="center">b</th>
<th align="center">return</th>
</tr>
</thead>
<tbody><tr>
<td align="center">3</td>
<td align="center">5</td>
<td align="center">12</td>
</tr>
<tr>
<td align="center">3</td>
<td align="center">3</td>
<td align="center">3</td>
</tr>
<tr>
<td align="center">5</td>
<td align="center">3</td>
<td align="center">12</td>
</tr>
</tbody></table>
<br>


<h2 id="🖋️-나의-풀이">🖋️ 나의 풀이</h2>
<pre><code class="language-js">function solution(a, b) {
    let sum = 0;

    for (let i = a; i &lt;= b; i++) {
        sum += i;
    }

    if (a &gt; b) {
        for (let j = b; j &lt;= a; j++) {
            sum += j;
        }
    }
    return sum;
}</code></pre>
<br>


<h2 id="💡-다른-사람들의-풀이">💡 다른 사람들의 풀이</h2>
<p>댓글중에 가우스의 재림 ㅜㅜㅋㅋㅋㅋㅋㅋㅋ
수열을 이용할 생각은 못했는데 이래서 수학을 잘 하면 좀 편하다고 하는가보다</p>
<p>양 끝의 합 * 양 끝의 합의 개수</p>
<h3 id="-1"># 1</h3>
<pre><code class="language-js">// 문제가 개편되었습니다. 이로 인해 함수 구성이나 테스트케이스가 변경되어, 과거의 코드는 동작하지 않을 수 있습니다.
// 새로운 함수 구성을 적용하려면 [코드 초기화] 버튼을 누르세요. 단, [코드 초기화] 버튼을 누르면 작성 중인 코드는 사라집니다.
function adder(a, b){
    var result = 0
    //함수를 완성하세요
    return (a+b) * (Math.abs(a-b)+1) / 2;
}


// 아래는 테스트로 출력해 보기 위한 코드입니다.
console.log( adder(3, 5) )</code></pre>
<h3 id="-2"># 2</h3>
<pre><code class="language-js">// 문제가 개편되었습니다. 이로 인해 함수 구성이나 테스트케이스가 변경되어, 과거의 코드는 동작하지 않을 수 있습니다.
// 새로운 함수 구성을 적용하려면 [코드 초기화] 버튼을 누르세요. 단, [코드 초기화] 버튼을 누르면 작성 중인 코드는 사라집니다.
function adder(a, b, s = 0){
  for (var i = Math.min(a, b); i &lt;= Math.max(a, b); i++) s += i;
  return s;
}


// 아래는 테스트로 출력해 보기 위한 코드입니다.
console.log( adder(3, 5) )</code></pre>
<br>

<hr>
<br>

<h2 id="📝-모르는-내용-찾아보기">📝 모르는 내용 찾아보기</h2>
<h2 id=""></h2>
<h3 id="-3"></h3>
]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스] 하샤드 수]]></title>
            <link>https://velog.io/@raumschiff_/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%ED%95%98%EC%83%A4%EB%93%9C-%EC%88%98</link>
            <guid>https://velog.io/@raumschiff_/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%ED%95%98%EC%83%A4%EB%93%9C-%EC%88%98</guid>
            <pubDate>Fri, 12 Jan 2024 05:49:24 GMT</pubDate>
            <description><![CDATA[<h2 id="🗒️-문제">🗒️ 문제</h2>
<p>양의 정수 x가 하샤드 수이려면 x의 자릿수의 합으로 x가 나누어져야 합니다. 예를 들어 18의 자릿수 합은 1+8=9이고, 18은 9로 나누어 떨어지므로 18은 하샤드 수입니다. 자연수 x를 입력받아 x가 하샤드 수인지 아닌지 검사하는 함수, solution을 완성해주세요.</p>
<pre><code class="language-js"></code></pre>
<br>

<h3 id="제한-사항">제한 사항</h3>
<ul>
<li>x는 1 이상, 10000 이하인 정수입니다.</li>
</ul>
<br>

<h3 id="입출력-예">입출력 예</h3>
<table>
<thead>
<tr>
<th align="center">x</th>
<th align="center">return</th>
</tr>
</thead>
<tbody><tr>
<td align="center">10</td>
<td align="center">true</td>
</tr>
<tr>
<td align="center">12</td>
<td align="center">true</td>
</tr>
<tr>
<td align="center">11</td>
<td align="center">false</td>
</tr>
<tr>
<td align="center">13</td>
<td align="center">false</td>
</tr>
</tbody></table>
<h3 id="입출력-예-설명">입출력 예 설명</h3>
<h4 id="입출력-예-1">입출력 예 #1</h4>
<ul>
<li>10의 모든 자릿수의 합은 1입니다. 10은 1로 나누어 떨어지므로 10은 하샤드 수입니다.</li>
</ul>
<h4 id="입출력-예-2">입출력 예 #2</h4>
<ul>
<li>12의 모든 자릿수의 합은 3입니다. 12는 3으로 나누어 떨어지므로 12는 하샤드 수입니다.</li>
</ul>
<h4 id="입출력-예-3">입출력 예 #3</h4>
<ul>
<li>11의 모든 자릿수의 합은 2입니다. 11은 2로 나누어 떨어지지 않으므로 11는 하샤드 수가 아닙니다.</li>
</ul>
<h4 id="입출력-예-4">입출력 예 #4</h4>
<ul>
<li>13의 모든 자릿수의 합은 4입니다. 13은 4로 나누어 떨어지지 않으므로 13은 하샤드 수가 아닙니다.</li>
</ul>
<br>


<h2 id="🖋️-나의-풀이">🖋️ 나의 풀이</h2>
<p><code>do~while</code>문을 사용해서 풀어보려고 했는데 처음 써보는거라 뭐가 문제인지 잘 모르겠어서 결국 <code>split</code> 사용해서 풀었다..</p>
<pre><code class="language-js">function solution(x) {
    let arr = String(x).split(&quot;&quot;).map(Number);

    // do {
    //     arr.push(x % 10);
    //     x = Math.floor(x / 10);
    // } while (x &gt; 0)

    console.log(x);
    console.log(arr);

    if ((x % arr.reduce((a, b) =&gt; a + b)) == 0) return true;
    else return false;
}</code></pre>
<br>


<h2 id="💡-다른-사람들의-풀이">💡 다른 사람들의 풀이</h2>
<h3 id="-1"># 1</h3>
<p>내가 처음 사용하려던 방식... 내가 한 방식대로 하면 x가 계속 0으로 나와서 결과값이 true만 출력되었는데 이렇게 해야 하는 거였구나</p>
<pre><code class="language-js">function solution(x) {
    let num = x;
    let sum = 0;
    do {
        sum += x%10;
        x = Math.floor(x/10);
    } while (x&gt;0);

    return !(num%sum);
}</code></pre>
<h3 id="-2"># 2</h3>
<pre><code class="language-js"></code></pre>
<br>

<hr>
<br>

<h2 id="📝-모르는-내용-찾아보기">📝 모르는 내용 찾아보기</h2>
<h2 id=""></h2>
<h3 id="-3"></h3>
]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스] 정수 내림차순으로 배치하기]]></title>
            <link>https://velog.io/@raumschiff_/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EC%A0%95%EC%88%98-%EB%82%B4%EB%A6%BC%EC%B0%A8%EC%88%9C%EC%9C%BC%EB%A1%9C-%EB%B0%B0%EC%B9%98%ED%95%98%EA%B8%B0</link>
            <guid>https://velog.io/@raumschiff_/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EC%A0%95%EC%88%98-%EB%82%B4%EB%A6%BC%EC%B0%A8%EC%88%9C%EC%9C%BC%EB%A1%9C-%EB%B0%B0%EC%B9%98%ED%95%98%EA%B8%B0</guid>
            <pubDate>Fri, 12 Jan 2024 05:40:09 GMT</pubDate>
            <description><![CDATA[<h2 id="🗒️-문제">🗒️ 문제</h2>
<p>함수 solution은 정수 n을 매개변수로 입력받습니다. n의 각 자릿수를 큰것부터 작은 순으로 정렬한 새로운 정수를 리턴해주세요. 예를들어 n이 118372면 873211을 리턴하면 됩니다.</p>
<pre><code class="language-js"></code></pre>
<br>

<h3 id="제한-사항">제한 사항</h3>
<ul>
<li>n은 1이상 8000000000 이하인 자연수입니다.</li>
</ul>
<br>

<h3 id="입출력-예">입출력 예</h3>
<table>
<thead>
<tr>
<th align="center">n</th>
<th align="center">return</th>
</tr>
</thead>
<tbody><tr>
<td align="center">118372</td>
<td align="center">873211</td>
</tr>
</tbody></table>
<br>


<h2 id="🖋️-나의-풀이">🖋️ 나의 풀이</h2>
<pre><code class="language-js">function solution(n) {
    let result = String(n).split(&quot;&quot;).sort((a, b) =&gt; b - a).join(&quot;&quot;);
    return Number(result);
}</code></pre>
<br>


<h2 id="💡-다른-사람들의-풀이">💡 다른 사람들의 풀이</h2>
<h3 id="-1"># 1</h3>
<pre><code class="language-js">function solution(n) {
  const newN = n + &quot;&quot;;
  const newArr = newN
    .split(&quot;&quot;)
    .sort()
    .reverse()
    .join(&quot;&quot;);

  return +newArr;
}</code></pre>
<h3 id="-2"># 2</h3>
<p>문자보다 숫자풀이가 더 빠르다고 해서 가져옴</p>
<pre><code class="language-js">function solution(n) {
    //숫자가 분명히 더 빠름
    var nums =[];
    do {
        nums.push(n%10);
        n=Math.floor(n/10);
    } while(n&gt;0)

    return nums.sort((a,b)=&gt;b-a).join(&#39;&#39;)*1;
    //문자는 느림
    return (n+&quot;&quot;).split(&#39;&#39;).sort((a,b)=&gt;b-a).join(&#39;&#39;)*1;
}</code></pre>
<br>

<hr>
<br>

<h2 id="📝-모르는-내용-찾아보기">📝 모르는 내용 찾아보기</h2>
<h2 id=""></h2>
<h3 id="-3"></h3>
]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스] 정수 제곱근 판별]]></title>
            <link>https://velog.io/@raumschiff_/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EC%A0%95%EC%88%98-%EC%A0%9C%EA%B3%B1%EA%B7%BC-%ED%8C%90%EB%B3%84</link>
            <guid>https://velog.io/@raumschiff_/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EC%A0%95%EC%88%98-%EC%A0%9C%EA%B3%B1%EA%B7%BC-%ED%8C%90%EB%B3%84</guid>
            <pubDate>Thu, 11 Jan 2024 11:44:37 GMT</pubDate>
            <description><![CDATA[<h2 id="🗒️-문제">🗒️ 문제</h2>
<p>임의의 양의 정수 n에 대해, n이 어떤 양의 정수 x의 제곱인지 아닌지 판단하려 합니다.
n이 양의 정수 x의 제곱이라면 x+1의 제곱을 리턴하고, n이 양의 정수 x의 제곱이 아니라면 -1을 리턴하는 함수를 완성하세요.</p>
<pre><code class="language-js"></code></pre>
<br>

<h3 id="제한-사항">제한 사항</h3>
<ul>
<li>n은 1이상, 50000000000000 이하인 양의 정수입니다.</li>
</ul>
<br>

<h3 id="입출력-예">입출력 예</h3>
<table>
<thead>
<tr>
<th align="center">n</th>
<th align="center">return</th>
</tr>
</thead>
<tbody><tr>
<td align="center">121</td>
<td align="center">144</td>
</tr>
<tr>
<td align="center">3</td>
<td align="center">-1</td>
</tr>
</tbody></table>
<h3 id="입출력-예-설명">입출력 예 설명</h3>
<h4 id="입출력-예-1">입출력 예 #1</h4>
<ul>
<li>121은 양의 정수 11의 제곱이므로, (11+1)를 제곱한 144를 리턴합니다.</li>
</ul>
<h4 id="입출력-예-2">입출력 예 #2</h4>
<ul>
<li>3은 양의 정수의 제곱이 아니므로, -1을 리턴합니다.</li>
</ul>
<br>


<h2 id="🖋️-나의-풀이">🖋️ 나의 풀이</h2>
<p>처음에 <code>Math.floor</code>를 사용하지 않았을 때 제출 시 테스트 코드에 오류가 있었는데 추가하고 나니 오류가 잡힘</p>
<pre><code class="language-js">function solution(n) {
    const num = Math.floor(Math.sqrt(n));
    if (n == Math.pow(num, 2)) return Math.pow(num + 1, 2);
    else return -1;
}</code></pre>
<br>


<h2 id="💡-다른-사람들의-풀이">💡 다른 사람들의 풀이</h2>
<h3 id="-1"># 1</h3>
<pre><code class="language-js">// 문제가 개편되었습니다. 이로 인해 함수 구성이나 테스트케이스가 변경되어, 과거의 코드는 동작하지 않을 수 있습니다.
// 새로운 함수 구성을 적용하려면 [코드 초기화] 버튼을 누르세요. 단, [코드 초기화] 버튼을 누르면 작성 중인 코드는 사라집니다.
function nextSqaure(n){
 var result = 0; 
  var x = 0; 
  while ( x*x &lt; n)
  { 
    x++; 
  }
  if (x*x == n)
  { 
    x++; 
    result = x*x; 
  }else{ 
    result = &#39;no&#39;; 
  } 
  return result;

}

// 아래는 테스트로 출력해 보기 위한 코드입니다.
console.log(&quot;결과 : &quot; + nextSqaure(121));</code></pre>
<h3 id="-2"># 2</h3>
<pre><code class="language-js"></code></pre>
<br>

<hr>
<br>

<h2 id="📝-모르는-내용-찾아보기">📝 모르는 내용 찾아보기</h2>
<h2 id=""></h2>
<h3 id="-3"></h3>
]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스] 문자열 내 p와 y의 개수]]></title>
            <link>https://velog.io/@raumschiff_/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EB%AC%B8%EC%9E%90%EC%97%B4-%EB%82%B4-p%EC%99%80-y%EC%9D%98-%EA%B0%9C%EC%88%98</link>
            <guid>https://velog.io/@raumschiff_/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EB%AC%B8%EC%9E%90%EC%97%B4-%EB%82%B4-p%EC%99%80-y%EC%9D%98-%EA%B0%9C%EC%88%98</guid>
            <pubDate>Thu, 11 Jan 2024 11:40:05 GMT</pubDate>
            <description><![CDATA[<h2 id="🗒️-문제">🗒️ 문제</h2>
<p>대문자와 소문자가 섞여있는 문자열 s가 주어집니다. s에 &#39;p&#39;의 개수와 &#39;y&#39;의 개수를 비교해 같으면 True, 다르면 False를 return 하는 solution를 완성하세요. &#39;p&#39;, &#39;y&#39; 모두 하나도 없는 경우는 항상 True를 리턴합니다. 단, 개수를 비교할 때 대문자와 소문자는 구별하지 않습니다.</p>
<p>예를 들어 s가 &quot;pPoooyY&quot;면 true를 return하고 &quot;Pyy&quot;라면 false를 return합니다.</p>
<pre><code class="language-js"></code></pre>
<br>

<h3 id="제한-사항">제한 사항</h3>
<ul>
<li>문자열 s의 길이 : 50 이하의 자연수</li>
<li>문자열 s는 알파벳으로만 이루어져 있습니다.</li>
</ul>
<br>

<h3 id="입출력-예">입출력 예</h3>
<table>
<thead>
<tr>
<th align="center">s</th>
<th align="center">answer</th>
</tr>
</thead>
<tbody><tr>
<td align="center">&quot;pPoooyY&quot;</td>
<td align="center">true</td>
</tr>
<tr>
<td align="center">&quot;Pyy&quot;</td>
<td align="center">false</td>
</tr>
</tbody></table>
<h3 id="입출력-예-설명">입출력 예 설명</h3>
<h4 id="입출력-예-1">입출력 예 #1</h4>
<ul>
<li>&#39;p&#39;의 개수 2개, &#39;y&#39;의 개수 2개로 같으므로 true를 return 합니다.</li>
</ul>
<h4 id="입출력-예-2">입출력 예 #2</h4>
<ul>
<li>&#39;p&#39;의 개수 1개, &#39;y&#39;의 개수 2개로 다르므로 false를 return 합니다.</li>
</ul>
<br>


<h2 id="🖋️-나의-풀이">🖋️ 나의 풀이</h2>
<pre><code class="language-js">function solution(s) {
    let p = 0;
    let y = 0;
    let arr = String(s.toLowerCase()).split(&quot;&quot;);

    for (let i = 0; i &lt; arr.length; i++) {
        if (arr[i] == &quot;p&quot;) p++;
        else if (arr[i] == &quot;y&quot;) y++;
    }

    if (p == y) return true;
    else return false;
}</code></pre>
<br>


<h2 id="💡-다른-사람들의-풀이">💡 다른 사람들의 풀이</h2>
<h3 id="-1"># 1</h3>
<pre><code class="language-js">function numPY(s){
  //함수를 완성하세요
    return s.toUpperCase().split(&quot;P&quot;).length === s.toUpperCase().split(&quot;Y&quot;).length;
}


// 아래는 테스트로 출력해 보기 위한 코드입니다.
console.log( numPY(&quot;pPoooyY&quot;) )
console.log( numPY(&quot;Pyy&quot;) )</code></pre>
<h3 id="-2"># 2</h3>
<p>null값 보완을 못해서 에러나는 코드</p>
<pre><code class="language-js">function numPY(s){
  return s.match(/p/ig).length == s.match(/y/ig).length
}


// 아래는 테스트로 출력해 보기 위한 코드입니다.
console.log( numPY(&quot;pPoooyY&quot;) )
console.log( numPY(&quot;Pyy&quot;) )</code></pre>
<h3 id="-3"># 3</h3>
<p><code>reduce()</code>를 이용</p>
<pre><code class="language-js">function solution(s){

    return [...s.toLowerCase()].reduce((acc, cur) =&gt; {
        if(cur ===&#39;p&#39;) return acc + 1;
        else if(cur ===&#39;y&#39;) return acc - 1;
        return acc;
    }, 0) ? false : true;
}</code></pre>
<br>

<hr>
<br>

<h2 id="📝-모르는-내용-찾아보기">📝 모르는 내용 찾아보기</h2>
<h2 id=""></h2>
<h3 id="-4"></h3>
]]></description>
        </item>
    </channel>
</rss>