<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>youngjun.log</title>
        <link>https://velog.io/</link>
        <description></description>
        <lastBuildDate>Mon, 17 Jan 2022 15:19:15 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <copyright>Copyright (C) 2019. youngjun.log. All rights reserved.</copyright>
        <atom:link href="https://v2.velog.io/rss/youngjun_dev" rel="self" type="application/rss+xml"/>
        <item>
            <title><![CDATA[[프로그래머스] 다리를 지나는 트럭]]></title>
            <link>https://velog.io/@youngjun_dev/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EB%8B%A4%EB%A6%AC%EB%A5%BC-%EC%A7%80%EB%82%98%EB%8A%94-%ED%8A%B8%EB%9F%AD</link>
            <guid>https://velog.io/@youngjun_dev/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EB%8B%A4%EB%A6%AC%EB%A5%BC-%EC%A7%80%EB%82%98%EB%8A%94-%ED%8A%B8%EB%9F%AD</guid>
            <pubDate>Mon, 17 Jan 2022 15:19:15 GMT</pubDate>
            <description><![CDATA[<h3 id="문제-설명">문제 설명</h3>
<blockquote>
<p>트럭 여러 대가 강을 가로지르는 일차선 다리를 정해진 순으로 건너려 합니다. 모든 트럭이 다리를 건너려면 최소 몇 초가 걸리는지 알아내야 합니다. 다리에는 트럭이 최대 bridge_length대 올라갈 수 있으며, 다리는 weight 이하까지의 무게를 견딜 수 있습니다. 단, 다리에 완전히 오르지 않은 트럭의 무게는 무시합니다.</p>
</blockquote>
<blockquote>
<p>예를 들어, 트럭 2대가 올라갈 수 있고 무게를 10kg까지 견디는 다리가 있습니다. 
무게가 [7, 4, 5, 6]kg인 트럭이 순서대로 최단 시간 안에 다리를 건너려면 다음과 같이 
건너야 합니다.</p>
</blockquote>
<blockquote>
<table>
<thead>
<tr>
<th align="center">경과 시간</th>
<th align="center">다리를 지난 트럭</th>
<th align="center">다리를 건너는 트럭</th>
<th align="center">대기 트럭</th>
</tr>
</thead>
<tbody><tr>
<td align="center">0</td>
<td align="center">[]</td>
<td align="center">[]</td>
<td align="center">[7,4,5,6]</td>
</tr>
<tr>
<td align="center">1~2</td>
<td align="center">[]</td>
<td align="center">[7]</td>
<td align="center">[4,5,6]</td>
</tr>
<tr>
<td align="center">3</td>
<td align="center">[7]</td>
<td align="center">[4]</td>
<td align="center">[5,6]</td>
</tr>
<tr>
<td align="center">4</td>
<td align="center">[7]</td>
<td align="center">[4,5]</td>
<td align="center">[6]</td>
</tr>
<tr>
<td align="center">5</td>
<td align="center">[7,4]</td>
<td align="center">[5]</td>
<td align="center">[6]</td>
</tr>
<tr>
<td align="center">6~7</td>
<td align="center">[7,4,5]</td>
<td align="center">[6]</td>
<td align="center">[]</td>
</tr>
<tr>
<td align="center">8</td>
<td align="center">[7,4,5,6]</td>
<td align="center">[]</td>
<td align="center">[]</td>
</tr>
</tbody></table>
</blockquote>
<blockquote>
<p>따라서, 모든 트럭이 다리를 지나려면 최소 8초가 걸립니다.</p>
</blockquote>
<blockquote>
<p>solution 함수의 매개변수로 다리에 올라갈 수 있는 트럭 수 bridge_length, 다리가 견딜 수 있는 무게 weight, 트럭 별 무게 truck_weights가 주어집니다. 이때 모든 트럭이 다리를 건너려면 최소 몇 초가 걸리는지 return 하도록 solution 함수를 완성하세요.</p>
</blockquote>
<h3 id="제한-사항">제한 사항</h3>
<blockquote>
<p>bridge_length는 1 이상 10,000 이하입니다.
weight는 1 이상 10,000 이하입니다.
truck_weights의 길이는 1 이상 10,000 이하입니다.
모든 트럭의 무게는 1 이상 weight 이하입니다.</p>
</blockquote>
<h3 id="입출력-예">입출력 예</h3>
<blockquote>
<table>
<thead>
<tr>
<th align="center">bridge_length</th>
<th align="center">weight</th>
<th align="center">truck_weights</th>
<th align="center">return</th>
</tr>
</thead>
<tbody><tr>
<td align="center">2</td>
<td align="center">10</td>
<td align="center">[7,4,5,6]</td>
<td align="center">8</td>
</tr>
<tr>
<td align="center">100</td>
<td align="center">100</td>
<td align="center">[10]</td>
<td align="center">101</td>
</tr>
<tr>
<td align="center">100</td>
<td align="center">100</td>
<td align="center">[10,10,10,10,10,10,10,10,10,10]</td>
<td align="center">110</td>
</tr>
</tbody></table>
</blockquote>
<h3 id="문제풀이">문제풀이</h3>
<pre><code>def solution(bridge_length, weight, truck_weights):

    answer = 0
    bridge = [0 for _ in range(bridge_length)]

    while bridge:

        answer += 1
        bridge.pop(0)

        if truck_weights:
            if sum(bridge) + truck_weights[0] &lt;= weight:            
                t = truck_weights.pop(0)
                bridge.append(t)
            else:
                bridge.append(0)


    return answer
</code></pre><h3 id="문제-해설">문제 해설</h3>
<pre><code>answer = 0
bridge = [0 for _ in range(bridge_length)]
answer : 경과시간
bridge : 다리 길이와 같은 길이의 값이 0으로 된 리스트 생성

  while bridge:
      if truck_weights:
            if sum(bridge) + truck_weights[0] &lt;= weight:   
bridge 리스트 안 ( 다리 위에 있는 트럭의 총 무게)과 다음 대기열에 있는 트럭 무게가 
다리가 감당할 수 있는 총 무게 (weight) 을 넘지 않는 조건을 만족하면 
t = truck_weights.pop(0)
                bridge.append(t)
다음 트럭을 리스트에 추가한다
만족을 하지 못한다면 0을 추가하여 다리의 길이를 유지
트럭의 대기열의 길이가 0이 되면 내부 반복문 종료

 else:
    bridge.append(0)

bridge 리스트의 길이가 0이 되면 반복문 종료후 경과시간 (answer) 리턴
</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스]기능개발]]></title>
            <link>https://velog.io/@youngjun_dev/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4%EA%B8%B0%EB%8A%A5%EA%B0%9C%EB%B0%9C</link>
            <guid>https://velog.io/@youngjun_dev/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4%EA%B8%B0%EB%8A%A5%EA%B0%9C%EB%B0%9C</guid>
            <pubDate>Mon, 17 Jan 2022 14:57:32 GMT</pubDate>
            <description><![CDATA[<h3 id="문제-설명">문제 설명</h3>
<blockquote>
<p>프로그래머스 팀에서는 기능 개선 작업을 수행 중입니다. 각 기능은 진도가 100%일 때 서비스에 반영할 수 있습니다.</p>
</blockquote>
<blockquote>
<p>또, 각 기능의 개발속도는 모두 다르기 때문에 뒤에 있는 기능이 앞에 있는 기능보다 먼저 개발될 수 있고, 이때 뒤에 있는 기능은 앞에 있는 기능이 배포될 때 함께 배포됩니다.</p>
</blockquote>
<blockquote>
<p>먼저 배포되어야 하는 순서대로 작업의 진도가 적힌 정수 배열 progresses와 각 작업의 개발 속도가 적힌 정수 배열 speeds가 주어질 때 각 배포마다 몇 개의 기능이 배포되는지를 return 하도록 solution 함수를 완성하세요.</p>
</blockquote>
<h3 id="제한-사항">제한 사항</h3>
<blockquote>
<p>작업의 개수(progresses, speeds배열의 길이)는 100개 이하입니다.</p>
</blockquote>
<blockquote>
<p>작업 진도는 100 미만의 자연수입니다.</p>
</blockquote>
<blockquote>
<p>작업 속도는 100 이하의 자연수입니다.</p>
</blockquote>
<blockquote>
<p>배포는 하루에 한 번만 할 수 있으며, 하루의 끝에 이루어진다고 가정합니다. </p>
</blockquote>
<blockquote>
<p>예를 들어 진도율이 95%인 작업의 개발 속도가 하루에 4%라면 배포는 2일 뒤에 이루어집니다.</p>
</blockquote>
<h3 id="입출력-예">입출력 예</h3>
<blockquote>
<table>
<thead>
<tr>
<th align="center">progresses</th>
<th align="center">speeds</th>
<th align="center">return</th>
</tr>
</thead>
<tbody><tr>
<td align="center">[93, 30, 55]</td>
<td align="center">[1, 30, 5]</td>
<td align="center">[2, 1]</td>
</tr>
<tr>
<td align="center">[95, 90, 99, 99, 80, 99]</td>
<td align="center">[1, 1, 1, 1, 1, 1]</td>
<td align="center">[1, 3, 2]</td>
</tr>
</tbody></table>
</blockquote>
<h3 id="입출력-예-설명">입출력 예 설명</h3>
<blockquote>
<p>입출력 예 #1
첫 번째 기능은 93% 완료되어 있고 하루에 1%씩 작업이 가능하므로 7일간 작업 후 배포가 가능합니다.
두 번째 기능은 30%가 완료되어 있고 하루에 30%씩 작업이 가능하므로 3일간 작업 후 배포가 가능합니다. 하지만 이전 첫 번째 기능이 아직 완성된 상태가 아니기 때문에 첫 번째 기능이 배포되는 7일째 배포됩니다.
세 번째 기능은 55%가 완료되어 있고 하루에 5%씩 작업이 가능하므로 9일간 작업 후 배포가 가능합니다.</p>
</blockquote>
<blockquote>
<p>따라서 7일째에 2개의 기능, 9일째에 1개의 기능이 배포됩니다.</p>
</blockquote>
<blockquote>
<p>입출력 예 #2
모든 기능이 하루에 1%씩 작업이 가능하므로, 작업이 끝나기까지 남은 일수는 각각 5일, 10일, 1일, 1일, 20일, 1일입니다. 어떤 기능이 먼저 완성되었더라도 앞에 있는 모든 기능이 완성되지 않으면 배포가 불가능합니다.</p>
</blockquote>
<blockquote>
<p>따라서 5일째에 1개의 기능, 10일째에 3개의 기능, 20일째에 2개의 기능이 배포됩니다.</p>
</blockquote>
<h3 id="문제풀이">문제풀이</h3>
<pre><code>def solution(progresses, speeds):

    answer = []
    time = 0
    count = 0

    while len(progresses)&gt; 0:
        if (progresses[0] + time*speeds[0]) &gt;= 100: 
            progresses.pop(0)
            speeds.pop(0)
            count += 1

        else:
            if count &gt; 0:
                answer.append(count)
                count = 0
            time += 1
    answer.append(count)
    return answer
</code></pre><h3 id="문제-해설">문제 해설</h3>
<pre><code>문제에 대해 설명을 하자면,

 count, time 변수를 설정해둔다. 

 첫번째가 100이 될때까지 loop 를 돌며 time 을 늘린다. ( whlile문 )

    else --&gt; time+=1

 (time =7) 이 되면  첫번째 값이(93) 100이 되어 if에 따라 pop 되고 count +=1

현재 time 이 7이기 때문에 두번째 값(30)도 if에 따라 pop 되고 count +=1 

 세번째 값은 100이 안되기 때문에 loop를 돌며 time 을 늘리는데 

   그전에 완성된 count 값이 있기 때문에 count를 이용한다. 

answer 리스트에 append하고 count 초기화하고  그후에 loop를 돌며 time 을 늘리는데 

세번째 값(55)이 100을 넘으면 count +=1 하고 

count 를 다시한번 answer 리스트에 append 해줌으로써 마지막 개발까지 힌다.
</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스] 주식가격]]></title>
            <link>https://velog.io/@youngjun_dev/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EC%A3%BC%EC%8B%9D%EA%B0%80%EA%B2%A9</link>
            <guid>https://velog.io/@youngjun_dev/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EC%A3%BC%EC%8B%9D%EA%B0%80%EA%B2%A9</guid>
            <pubDate>Mon, 17 Jan 2022 14:19:18 GMT</pubDate>
            <description><![CDATA[<h3 id="문제-설명">문제 설명</h3>
<blockquote>
<p>초 단위로 기록된 주식가격이 담긴 배열 prices가 매개변수로 주어질 때, 가격이 떨어지지 않은 기간은 몇 초인지를 return 하도록 solution 함수를 완성하세요.</p>
</blockquote>
<h3 id="제한-사항">제한 사항</h3>
<blockquote>
<p>prices의 각 가격은 1 이상 10,000 이하인 자연수입니다.
 prices의 길이는 2 이상 100,000 이하입니다.</p>
</blockquote>
<h3 id="입출력-예">입출력 예</h3>
<blockquote>
<table>
<thead>
<tr>
<th align="center">prices</th>
<th align="center">return</th>
</tr>
</thead>
<tbody><tr>
<td align="center">[1, 2, 3, 2, 3]</td>
<td align="center">[4, 3, 1, 1, 0]</td>
</tr>
</tbody></table>
</blockquote>
<h3 id="문제풀이">문제풀이</h3>
<pre><code>from collections import deque

def solution(prices):
    queue = deque(prices)
    answer = []

    while queue:
        price = queue.popleft()
        sec = 0
        for q in queue:
            sec += 1
            if price &gt; q:
                break 
        answer.append(sec)        
    return answer
</code></pre><h3 id="문제-해설">문제 해설</h3>
<pre><code>문제에 대해 설명을 하자면,

주식 가격을 초 단위로 기록한다. 1초 2초 3초 마다 얼마씩 변하는지 적어 논 배열을 prices.

그 초 당시에 가격이 떨어지지 않은 초 만큼 return 받아야 한다.

1초 시점 주식의 가격은 1, 

2초 시점 주식의 가격은 2,

3초 시점 주식의 가격은 3,

4초 시점 주식의 가격은 2,

5초 시점 주식의 가격은 3,

으로 이루어져 있다면,



1초에 샀을 때는 4초동안 안 떨어졌고,

2초에 샀을 때는 3초동안 안 떨어졌고,

3초에 샀을 때는 1초동안 안 떨어졌고,(1초 뒤에 가격 떨어지니까 1초동안만 방어한것)

4초에 샀을 때도 1초

5초는 마지막 초니까 0초 

그래서 [4,3,1,1,0]이 return되어야 한다.
</code></pre><h3 id="queuefifo-활용">Queue(FIFO) 활용</h3>
<blockquote>
<p>반복문을 2 중첩해서 풀 수 있었다. 인덱스가 0인 시점부터 가격이 떨어질 때까지의 초를 세고, 인덱스가 1인 시점부터 가격이 떨어질 때까지의 초를 세고, 이 과정을 모든 인덱스에 반복하는 것이다.</p>
</blockquote>
<blockquote>
<p>큐를 사용한다면 추가적인 인덱싱 없이 구현이 가능할 것 같아서 큐를 활용하였다. 
prices로 queue를 초기화 시킨 후에 반복문을 돌면서 앞에서부터 하나씩 popleft해서 
popleft한 뒤의, 남은 queue를 순회하며 값이 작아지기 전까지 초를 증가시키는 것을 
queue가 빌때까지 반복하면 된다.</p>
</blockquote>
]]></description>
        </item>
        <item>
            <title><![CDATA[A+B - 5]]></title>
            <link>https://velog.io/@youngjun_dev/AB-5</link>
            <guid>https://velog.io/@youngjun_dev/AB-5</guid>
            <pubDate>Thu, 06 Jan 2022 06:20:14 GMT</pubDate>
            <description><![CDATA[<h3 id="문제-설명">문제 설명</h3>
<blockquote>
<p>두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오.</p>
</blockquote>
<h3 id="입력">입력</h3>
<blockquote>
<p>입력은 여러 개의 테스트 케이스로 이루어져 있다.</p>
</blockquote>
<blockquote>
<p>각 테스트 케이스는 한 줄로 이루어져 있으며, 각 줄에 A와 B가 주어진다. (0 &lt; A, B &lt; 10)</p>
</blockquote>
<blockquote>
<p>입력의 마지막에는 0 두 개가 들어온다.</p>
</blockquote>
<h3 id="출력">출력</h3>
<blockquote>
<p>각 테스트 케이스마다 A+B를 출력한다.</p>
</blockquote>
<h3 id="문제풀이">문제풀이</h3>
<pre><code>while True:
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        break;
    else:
        print(a+b)
</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[구구단 ]]></title>
            <link>https://velog.io/@youngjun_dev/%EA%B5%AC%EA%B5%AC%EB%8B%A8</link>
            <guid>https://velog.io/@youngjun_dev/%EA%B5%AC%EA%B5%AC%EB%8B%A8</guid>
            <pubDate>Thu, 06 Jan 2022 06:16:38 GMT</pubDate>
            <description><![CDATA[<h3 id="문제-설명">문제 설명</h3>
<blockquote>
<p>N을 입력받은 뒤, 구구단 N단을 출력하는 프로그램을 작성하시오. 출력 형식에 맞춰서 출력하면 된다.</p>
</blockquote>
<h3 id="입력">입력</h3>
<blockquote>
<p>첫째 줄에 N이 주어진다. N은 1보다 크거나 같고, 9보다 작거나 같다</p>
</blockquote>
<h3 id="출력">출력</h3>
<blockquote>
<p>출력형식과 같게 N<em>1부터 N</em>9까지 출력한다.</p>
</blockquote>
<h3 id="문제풀이">문제풀이</h3>
<pre><code>n = int(input())

for i in range(1,10):  # 1~9
    print(n, &#39;*&#39;, i, &#39;=&#39;, n*i)
</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[두 수 비교하기 ]]></title>
            <link>https://velog.io/@youngjun_dev/%EB%91%90-%EC%88%98-%EB%B9%84%EA%B5%90%ED%95%98%EA%B8%B0</link>
            <guid>https://velog.io/@youngjun_dev/%EB%91%90-%EC%88%98-%EB%B9%84%EA%B5%90%ED%95%98%EA%B8%B0</guid>
            <pubDate>Thu, 06 Jan 2022 00:02:17 GMT</pubDate>
            <description><![CDATA[<h3 id="문제-설명">문제 설명</h3>
<blockquote>
<p>두 정수 A와 B가 주어졌을 때, A와 B를 비교하는 프로그램을 작성하시오.</p>
</blockquote>
<h3 id="제한-조건">제한 조건</h3>
<blockquote>
<p>arr은 길이 1이상, 15이하인 배열입니다.
arr의 원소는 100 이하인 자연수입니다.</p>
</blockquote>
<h3 id="입력">입력</h3>
<blockquote>
<p>첫째 줄에 A와 B가 주어진다. A와 B는 공백 한 칸으로 구분되어져 있다.</p>
</blockquote>
<h3 id="출력">출력</h3>
<blockquote>
<p>첫째 줄에 다음 세 가지 중 하나를 출력한다.</p>
<p>A가 B보다 큰 경우에는 &#39;&gt;&#39;를 출력한다.
A가 B보다 작은 경우에는 &#39;&lt;&#39;를 출력한다.
A와 B가 같은 경우에는 &#39;==&#39;를 출력한다.</p>
</blockquote>
<h3 id="제한">제한</h3>
<blockquote>
<p>-10,000 ≤ A, B ≤ 10,000</p>
</blockquote>
<h3 id="문제풀이">문제풀이</h3>
<pre><code>A,B = map(int,input().split())

if A &gt; B:
    print(&#39;&gt;&#39;)
elif A &lt; B:
    print(&#39;&lt;&#39;)
else:
    print(&#39;==&#39;)
</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스]N개의 최소공배수]]></title>
            <link>https://velog.io/@youngjun_dev/least-common-multiple</link>
            <guid>https://velog.io/@youngjun_dev/least-common-multiple</guid>
            <pubDate>Sat, 01 Jan 2022 13:11:38 GMT</pubDate>
            <description><![CDATA[<h3 id="문제-설명">문제 설명</h3>
<blockquote>
<p>두 수의 최소공배수(Least Common Multiple)란 입력된 두 수의 배수 중 공통이 되는 가장 작은 숫자를 의미합니다. 예를 들어 2와 7의 최소공배수는 14가 됩니다. 정의를 확장해서, n개의 수의 최소공배수는 n 개의 수들의 배수 중 공통이 되는 가장 작은 숫자가 됩니다. n개의 숫자를 담은 배열 arr이 입력되었을 때 이 수들의 최소공배수를 반환하는 함수, solution을 완성해 주세요.</p>
</blockquote>
<h3 id="제한-조건">제한 조건</h3>
<blockquote>
<p>arr은 길이 1이상, 15이하인 배열입니다.
arr의 원소는 100 이하인 자연수입니다.</p>
</blockquote>
<h3 id="입출력-예">입출력 예</h3>
<blockquote>
<table>
<thead>
<tr>
<th align="center">s</th>
<th align="center">return</th>
</tr>
</thead>
<tbody><tr>
<td align="center">[2,6,8,14]</td>
<td align="center">168</td>
</tr>
<tr>
<td align="center">[1,2,3]</td>
<td align="center">6</td>
</tr>
</tbody></table>
</blockquote>
<h3 id="문제풀이">문제풀이</h3>
<pre><code>def solution(arr):

    from math import gcd

    answer = arr[0]

    for num in arr:

        answer = answer*num // gcd(answer, num) 

    return answer
</code></pre><h3 id="문제-해설">문제 해설</h3>
<pre><code>def solution(arr):
    from math import gcd                            # 최대공약수를 구하는 gcd() import
    answer = arr[0]                                 # answer을 arr[0]으로 초기화

    for num in arr:                                 # 반복문을 처음부터 끝까지 돈다.
        #1. (arr[0],arr[1])의 최소공배수를 구한 후 answer에 저장
        #2. (#1에서 구한 최소공배수, arr[2])의 최소공배수를 구한 후 answer에 저장
        #3. 모든 배열을 돌면서 최소공배수를 구하고, 저장하고 하는 방식을 진행
        answer = answer*num // gcd(answer, num)     

    return answer</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스]문자열 다루기 기본]]></title>
            <link>https://velog.io/@youngjun_dev/stringhandlingbasics</link>
            <guid>https://velog.io/@youngjun_dev/stringhandlingbasics</guid>
            <pubDate>Sat, 01 Jan 2022 13:06:42 GMT</pubDate>
            <description><![CDATA[<h3 id="문제-설명">문제 설명</h3>
<blockquote>
<p>문자열 s의 길이가 4 혹은 6이고, 숫자로만 구성돼있는지 확인해주는 함수, solution을 완성하세요. 예를 들어 s가 &quot;a234&quot;이면 False를 리턴하고 &quot;1234&quot;라면 True를 리턴하면 됩니다.</p>
</blockquote>
<h3 id="제한-조건">제한 조건</h3>
<blockquote>
<p>s는 길이 1 이상, 길이 8 이하인 문자열입니다.</p>
</blockquote>
<h3 id="입출력-예">입출력 예</h3>
<blockquote>
<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>
</blockquote>
<h3 id="문제풀이">문제풀이</h3>
<pre><code>def solution(s):
    answer = True

    if len(s) in [4, 6]:
        for i in range(len(s)):
            if not s[i].isdigit():
                answer = False
                break
    else:
        answer = False

    return answer
</code></pre><h3 id="문제-해설">문제 해설</h3>
<pre><code>s의 길이가 4 또는 6일 경우 문자열 속 각 문자를 탐색하면서 숫자가 아닌 문자가
있는지 확인 합니다. 만약 숫자가 아닌 문자가 있을 경우 answer = False 로
s의 길이가 4 또는 6이면서 숫자인 문자만 발견되면 True로 그렇지 않은 경우는
모두 False</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스]문자열 내림차순으로 배치하기]]></title>
            <link>https://velog.io/@youngjun_dev/sorted</link>
            <guid>https://velog.io/@youngjun_dev/sorted</guid>
            <pubDate>Sat, 01 Jan 2022 12:46:12 GMT</pubDate>
            <description><![CDATA[<h3 id="문제-설명">문제 설명</h3>
<blockquote>
<p>문자열 s에 나타나는 문자를 큰것부터 작은 순으로 정렬해 새로운 문자열을 리턴하는 함수, solution을 완성해주세요.
s는 영문 대소문자로만 구성되어 있으며, 대문자는 소문자보다 작은 것으로 간주합니다.</p>
</blockquote>
<blockquote>
<p>예를 들어 s가 &quot;pPoooyY&quot;면 true를 return하고 &quot;Pyy&quot;라면 false를 return합니다.</p>
</blockquote>
<h3 id="제한-조건">제한 조건</h3>
<blockquote>
<p>str은 길이 1 이상인 문자열입니다.</p>
</blockquote>
<h3 id="입출력-예">입출력 예</h3>
<blockquote>
<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>
</blockquote>
<h3 id="문제풀이">문제풀이</h3>
<pre><code>def solution(s):
    return (&quot;&quot;.join(sorted(s)[::-1]))</code></pre><h3 id="문제-해설">문제 해설</h3>
<pre><code>def solution(s):
    return (&quot;&quot;.join(sorted(s)[::-1]))

 sorte() 함수를 사용하여 주어진 문자열을 오름차 순으로 정렬한다.
 sored() 함수를 사용하면 아래와 같은 상태로 정렬되는데

 [&#39;Z&#39;, &#39;d&#39;, &#39;e&#39;, &#39;f&#39;, &#39;i&#39;, &#39;j&#39;, &#39;k&#39;, &#39;k&#39;, &#39;l&#39;, &#39;l&#39;]

 return (&quot;&quot;.join(sorted(s)[::-1]))

 &quot;&quot;.join() 함수로 리스트 안의 원소들을 이어붙인다.
 [::-1]을 사용하여 join 한 결과를 거꾸로 출력한다.</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스]문자열 내 p와 y의 개수]]></title>
            <link>https://velog.io/@youngjun_dev/pandy</link>
            <guid>https://velog.io/@youngjun_dev/pandy</guid>
            <pubDate>Sat, 01 Jan 2022 12:37:54 GMT</pubDate>
            <description><![CDATA[<h3 id="문제-설명">문제 설명</h3>
<blockquote>
<p>대문자와 소문자가 섞여있는 문자열 s가 주어집니다. s에 &#39;p&#39;의 개수와 &#39;y&#39;의 개수를 비교해 같으면 True, 다르면 False를 return 하는 solution를 완성하세요. &#39;p&#39;, &#39;y&#39; 모두 하나도 없는 경우는 항상 True를 리턴합니다. 단, 개수를 비교할 때 대문자와 소문자는 구별하지 않습니다.</p>
</blockquote>
<blockquote>
<p>예를 들어 s가 &quot;pPoooyY&quot;면 true를 return하고 &quot;Pyy&quot;라면 false를 return합니다.</p>
</blockquote>
<h3 id="제한-조건">제한 조건</h3>
<blockquote>
<p>문자열 s의 길이 : 50 이하의 자연수
문자열 s는 알파벳으로만 이루어져 있습니다.</p>
</blockquote>
<h3 id="입출력-예">입출력 예</h3>
<blockquote>
<table>
<thead>
<tr>
<th align="center">s</th>
<th align="center">return</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>
</blockquote>
<h3 id="입출력-예-1">입출력 예</h3>
<p>입출력 예 #1
&#39;p&#39;의 개수 2개, &#39;y&#39;의 개수 2개로 같으므로 true를 return 합니다.</p>
<p>입출력 예 #2
&#39;p&#39;의 개수 1개, &#39;y&#39;의 개수 2개로 다르므로 false를 return 합니다.</p>
<h3 id="문제풀이">문제풀이</h3>
<pre><code>def solution(s):
    answer = True
    p = y = 0
    for i in range(len(s)):
        if s[i].lower()==&#39;p&#39;:
            p += 1
        elif s[i].lower()==&#39;y&#39;:
            y += 1
    if p != y:
        answer = False   

    return answer</code></pre><h3 id="문제-해설">문제 해설</h3>
<pre><code>def solution(s):
    answer = True
    p = y = 0            // p 와 y를 만들어서
    for i in range(len(s)):
        if s[i].lower()==&#39;p&#39;:    // 각각 문자를 셀수 있게 해서
            p += 1                 // 대소문자 구분하기 않기 위해 lower()를 이용해
        elif s[i].lower()==&#39;y&#39;:  // 단순비교를 통해 배열의 인덱스가 
            y += 1                 // p 또는 y와 일치할 경우 카운트하며 
    if p != y:                     // 최종으로 개수 비교해 True / False 출력
        answer = False   

    return answer</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스] 이상한 문자 만들기]]></title>
            <link>https://velog.io/@youngjun_dev/createweirdcharacters</link>
            <guid>https://velog.io/@youngjun_dev/createweirdcharacters</guid>
            <pubDate>Sat, 01 Jan 2022 12:12:16 GMT</pubDate>
            <description><![CDATA[<h3 id="문제-설명">문제 설명</h3>
<blockquote>
<p>문자열 s는 한 개 이상의 단어로 구성되어 있습니다. 각 단어는 하나 이상의 공백문자로 구분되어 있습니다. 각 단어의 짝수번째 알파벳은 대문자로, 홀수번째 알파벳은 소문자로 바꾼 문자열을 리턴하는 함수, solution을 완성하세요.</p>
</blockquote>
<h3 id="제한-조건">제한 조건</h3>
<blockquote>
<p>문자열 전체의 짝/홀수 인덱스가 아니라, 단어(공백을 기준)별로 짝/홀수 인덱스를 판단해야합니다.
첫 번째 글자는 0번째 인덱스로 보아 짝수번째 알파벳으로 처리해야 합니다.</p>
</blockquote>
<h3 id="입출력-예">입출력 예</h3>
<blockquote>
<table>
<thead>
<tr>
<th align="center">s</th>
<th align="center">return</th>
</tr>
</thead>
<tbody><tr>
<td align="center">&quot;try hello world&quot;</td>
<td align="center">&quot;TrY HeLlO WoRlD&quot;</td>
</tr>
</tbody></table>
</blockquote>
<h3 id="입출력-예-1">입출력 예</h3>
<p>입출력 예 #1</p>
<p>&quot;try hello world&quot;는 세 단어 &quot;try&quot;, &quot;hello&quot;, &quot;world&quot;로 구성되어 있습니다. 각 단어의 짝수번째 문자를 대문자로, 홀수번째 문자를 소문자로 바꾸면 &quot;TrY&quot;, &quot;HeLlO&quot;, &quot;WoRlD&quot;입니다. 따라서 &quot;TrY HeLlO WoRlD&quot; 를 리턴합니다.</p>
<h3 id="문제풀이">문제풀이</h3>
<pre><code>def solution(s):
    answer = []
    s = s.split(&#39; &#39;)

    for i in range(len(s)):
        result = &#39;&#39;
        for j in range(len(s[i])):
            if j % 2 == 0:
                result += s[i][j].upper()
            else:
                result += s[i][j].lower()

        answer.append(result)

    return &#39; &#39;.join(answer)</code></pre><h3 id="문제-해설">문제 해설</h3>
<pre><code>def solution(s):
    answer = []
    s = s.split(&#39; &#39;)

    for i in range(len(s)):
        result = &#39;&#39;
        for j in range(len(s[i])):    // 공백을 기준으로 문자를 나눠준다.
            if j % 2 == 0:
                result += s[i][j].upper()
            else:
                result += s[i][j].lower()   // 글자 인덱스에 맞게 2로 나눈 경우
                              // 나머지가 0이면 대문자로, 아니면 소문자로 변경한다.
        answer.append(result)

    return &#39; &#39;.join(answer)</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스] 약수의 합]]></title>
            <link>https://velog.io/@youngjun_dev/sumoffactors</link>
            <guid>https://velog.io/@youngjun_dev/sumoffactors</guid>
            <pubDate>Sat, 01 Jan 2022 11:45:20 GMT</pubDate>
            <description><![CDATA[<h3 id="문제-설명">문제 설명</h3>
<blockquote>
<p>정수 n을 입력받아 n의 약수를 모두 더한 값을 리턴하는 함수, solution을 완성해주세요.</p>
</blockquote>
<h3 id="제한-조건">제한 조건</h3>
<blockquote>
<p>n은 0 이상 3000이하인 정수입니다.</p>
</blockquote>
<h3 id="입출력-예">입출력 예</h3>
<blockquote>
<table>
<thead>
<tr>
<th align="center">n</th>
<th align="center">return</th>
</tr>
</thead>
<tbody><tr>
<td align="center">12</td>
<td align="center">28</td>
</tr>
<tr>
<td align="center">5</td>
<td align="center">6</td>
</tr>
</tbody></table>
</blockquote>
<h3 id="입출력-예-1">입출력 예</h3>
<p>입출력 예 #1</p>
<p>12의 약수는 1, 2, 3, 4, 6, 12입니다. 이를 모두 더하면 28입니다.</p>
<p>입출력 예 #2</p>
<p>5의 약수는 1, 5입니다. 이를 모두 더하면 6입니다.</p>
<h3 id="문제풀이">문제풀이</h3>
<pre><code>def solution(n):
    answer = 0
    sum = 0

    for i in range ( 1, n + 1 ):
        if n % i  == 0:
            sum += i
            answer = sum

    return answer</code></pre><h3 id="문제-해설">문제 해설</h3>
<pre><code>def solution(n):
    answer = 0 
    sum = 0

    for i in range ( 1, n + 1 ):   // 1부터 입력받은 수 n까지 돌리고
        if n % i  == 0:            //  n 을 i로 나눠서 나머지가 0 일 때
            sum += i               //  sum에 더한다.
            answer = sum

    return answer                    // answer를 return 한다.</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스] 핸드폰 번호 가리기]]></title>
            <link>https://velog.io/@youngjun_dev/hidenum</link>
            <guid>https://velog.io/@youngjun_dev/hidenum</guid>
            <pubDate>Sat, 01 Jan 2022 11:24:40 GMT</pubDate>
            <description><![CDATA[<h3 id="문제-설명">문제 설명</h3>
<blockquote>
<p>프로그래머스 모바일은 개인정보 보호를 위해 고지서를 보낼 때 고객들의 전화번호의 일부를 가립니다.
전화번호가 문자열 phone_number로 주어졌을 때, 전화번호의 뒷 4자리를 제외한 나머지 숫자를 전부 *으로 가린 문자열을 리턴하는 함수, solution을 완성해주세요.</p>
</blockquote>
<h3 id="제한-조건">제한 조건</h3>
<blockquote>
<p>s는 길이 4 이상, 20이하인 문자열입니다.</p>
</blockquote>
<h3 id="입출력-예">입출력 예</h3>
<blockquote>
<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;<strong>***</strong>4444&quot;</td>
</tr>
<tr>
<td align="center">&quot;027778888&quot;</td>
<td align="center">&quot;*****8888&quot;</td>
</tr>
</tbody></table>
</blockquote>
<h3 id="문제풀이">문제풀이</h3>
<pre><code>def solution(phone_number):

    phone_number_len = len(phone_number)

    answer = &#39;*&#39; * (phone_number_len - 4)

    answer += phone_number[-4:]

    return answer</code></pre><h3 id="문제-해설">문제 해설</h3>
<pre><code>def solution(phone_number):

    phone_number_len = len(phone_number)

    먼저 전화번호의 길이를 구해야 합니다.

    뒷자리 4개를 뺴고는 * 로 치환할 것이므로 

    answer = &#39;*&#39; * (phone_number_len - 4)

     먼저 (전화번호 - 4) 만큼의 *을 정답에 붙여줍니다.

    answer += phone_number[-4:]

    phone_number의 뒷자리 4개를 -4 index를 활용해서 잘라 붙입니다.

    뒷자리 4개를 뺴고는 모두 *로 치환한 전화번호가 나옵니다.

    return answer</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스]짝수와 홀수]]></title>
            <link>https://velog.io/@youngjun_dev/evenandodd</link>
            <guid>https://velog.io/@youngjun_dev/evenandodd</guid>
            <pubDate>Sat, 25 Dec 2021 16:13:14 GMT</pubDate>
            <description><![CDATA[<h3 id="문제-설명">문제 설명</h3>
<blockquote>
<p>정수 num이 짝수일 경우 &quot;Even&quot;을 반환하고 홀수인 경우 &quot;Odd&quot;를 반환하는 함수, solution을 완성해주세요.</p>
</blockquote>
<h3 id="제한-조건">제한 조건</h3>
<blockquote>
<p>num은 int 범위의 정수입니다.
0은 짝수입니다.</p>
</blockquote>
<h3 id="입출력-예">입출력 예</h3>
<blockquote>
<table>
<thead>
<tr>
<th align="center">num</th>
<th align="center">return</th>
</tr>
</thead>
<tbody><tr>
<td align="center">3</td>
<td align="center">&quot;Odd&quot;</td>
</tr>
<tr>
<td align="center">4</td>
<td align="center">&quot;Even&quot;</td>
</tr>
</tbody></table>
</blockquote>
<h3 id="문제풀이">문제풀이</h3>
<pre><code>def solution(num):
    if num % 2 == 0:
        return &#39;Even&#39;
    else:
        return &#39;Odd&#39;
</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스]평균 구하기]]></title>
            <link>https://velog.io/@youngjun_dev/average</link>
            <guid>https://velog.io/@youngjun_dev/average</guid>
            <pubDate>Sat, 25 Dec 2021 16:11:16 GMT</pubDate>
            <description><![CDATA[<h3 id="문제-설명">문제 설명</h3>
<blockquote>
<p>arr은 길이 1 이상, 100 이하인 배열입니다.
arr의 원소는 -10,000 이상 10,000 이하인 정수입니다.</p>
</blockquote>
<h3 id="제한-조건">제한 조건</h3>
<blockquote>
<p>a와 b가 같은 경우는 둘 중 아무 수나 리턴하세요.
a와 b는 -10,000,000 이상 10,000,000 이하인 정수입니다.
a와 b의 대소관계는 정해져있지 않습니다.</p>
</blockquote>
<h3 id="입출력-예">입출력 예</h3>
<blockquote>
<table>
<thead>
<tr>
<th align="center">arr</th>
<th align="center">return</th>
</tr>
</thead>
<tbody><tr>
<td align="center">[1, 2, 3, 4]</td>
<td align="center">2, 5</td>
</tr>
<tr>
<td align="center">[5, 5]</td>
<td align="center">5</td>
</tr>
</tbody></table>
</blockquote>
<h3 id="문제풀이">문제풀이</h3>
<pre><code>def solution(arr):
    answer = sum(arr) / len(arr)
    return answer
</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스]x만큼 간격이 있는 n개의 숫자]]></title>
            <link>https://velog.io/@youngjun_dev/nnumbersspacedbyx</link>
            <guid>https://velog.io/@youngjun_dev/nnumbersspacedbyx</guid>
            <pubDate>Sat, 25 Dec 2021 16:09:06 GMT</pubDate>
            <description><![CDATA[<h3 id="문제-설명">문제 설명</h3>
<blockquote>
<p>함수 solution은 정수 x와 자연수 n을 입력 받아, x부터 시작해 x씩 증가하는 숫자를 n개 지니는 리스트를 리턴해야 합니다. 다음 제한 조건을 보고, 조건을 만족하는 함수, solution을 완성해주세요.</p>
</blockquote>
<h3 id="제한-조건">제한 조건</h3>
<blockquote>
<p>x는 -10000000 이상, 10000000 이하인 정수입니다.
n은 1000 이하인 자연수입니다.</p>
</blockquote>
<h3 id="입출력-예">입출력 예</h3>
<blockquote>
<table>
<thead>
<tr>
<th align="center">x</th>
<th align="center">n</th>
<th align="center">answer</th>
</tr>
</thead>
<tbody><tr>
<td align="center">2</td>
<td align="center">5</td>
<td align="center">[2, 4, 6, 8, 10]</td>
</tr>
<tr>
<td align="center">4</td>
<td align="center">3</td>
<td align="center">[4, 8, 12]</td>
</tr>
<tr>
<td align="center">-4</td>
<td align="center">2</td>
<td align="center">[-4, -8]</td>
</tr>
</tbody></table>
</blockquote>
<h3 id="문제풀이">문제풀이</h3>
<pre><code>def solution(x, n):
    answer = []
    for i in range(1, n+1):
        answer.append(x*i)
    return answer
</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스]가운데 글자 가져오기]]></title>
            <link>https://velog.io/@youngjun_dev/getmiddleletter</link>
            <guid>https://velog.io/@youngjun_dev/getmiddleletter</guid>
            <pubDate>Sat, 25 Dec 2021 16:04:42 GMT</pubDate>
            <description><![CDATA[<h3 id="문제-설명">문제 설명</h3>
<blockquote>
<p>단어 s의 가운데 글자를 반환하는 함수, solution을 만들어 보세요. 단어의 길이가 짝수라면 가운데 두글자를 반환하면 됩니다.</p>
</blockquote>
<h3 id="제한-조건">제한 조건</h3>
<blockquote>
<p>s는 길이가 1 이상, 100이하인 스트링입니다.</p>
</blockquote>
<h3 id="입출력-예">입출력 예</h3>
<blockquote>
<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>
</blockquote>
<h3 id="문제풀이">문제풀이</h3>
<pre><code>def solution(s):
    center = int(len(s)/2)
    if len(s) % 2 !=0:
        return s[center]
    else:
        return s[center-1:center+1]
    return answer
</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스]서울에서 김서방 찾기]]></title>
            <link>https://velog.io/@youngjun_dev/seobangkim</link>
            <guid>https://velog.io/@youngjun_dev/seobangkim</guid>
            <pubDate>Sat, 25 Dec 2021 16:01:50 GMT</pubDate>
            <description><![CDATA[<h3 id="문제-설명">문제 설명</h3>
<blockquote>
<p>String형 배열 seoul의 element중 &quot;Kim&quot;의 위치 x를 찾아, &quot;김서방은 x에 있다&quot;는 String을 반환하는 함수, solution을 완성하세요. seoul에 &quot;Kim&quot;은 오직 한 번만 나타나며 잘못된 값이 입력되는 경우는 없습니다.  </p>
</blockquote>
<h3 id="제한-조건">제한 조건</h3>
<blockquote>
<p>seoul은 길이 1 이상, 1000 이하인 배열입니다.
seoul의 원소는 길이 1 이상, 20 이하인 문자열입니다.
&quot;Kim&quot;은 반드시 seoul 안에 포함되어 있습니다.</p>
</blockquote>
<h3 id="입출력-예">입출력 예</h3>
<blockquote>
<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>
</blockquote>
<h3 id="문제풀이">문제풀이</h3>
<pre><code>def solution(seoul):
    x = seoul.index(&#39;Kim&#39;)
    answer = &#39;김서방은 {0}에 있다&#39;.format(x)
    return answer
</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스]수박수박수박수박수박수?]]></title>
            <link>https://velog.io/@youngjun_dev/watermelon</link>
            <guid>https://velog.io/@youngjun_dev/watermelon</guid>
            <pubDate>Sat, 25 Dec 2021 15:59:21 GMT</pubDate>
            <description><![CDATA[<h3 id="문제-설명">문제 설명</h3>
<blockquote>
<p>길이가 n이고, &quot;수박수박수박수....&quot;와 같은 패턴을 유지하는 문자열을 리턴하는 함수, solution을 완성하세요. 예를들어 n이 4이면 &quot;수박수박&quot;을 리턴하고 3이라면 &quot;수박수&quot;를 리턴하면 됩니다.</p>
</blockquote>
<h3 id="제한-조건">제한 조건</h3>
<blockquote>
<p>n은 길이 10,000이하인 자연수입니다</p>
</blockquote>
<h3 id="입출력-예">입출력 예</h3>
<blockquote>
<table>
<thead>
<tr>
<th align="center">a</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">3</td>
<td align="center">&quot;수박수박&quot;</td>
</tr>
</tbody></table>
</blockquote>
<h3 id="문제풀이">문제풀이</h3>
<pre><code>def solution(n):
    answer = &#39;&#39;

    for i in range(n):
        if i % 2 == 0:
            answer += &#39;수&#39;
        else:
            answer += &#39;박&#39;
    return answer
</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스]두 정수 사이의 합]]></title>
            <link>https://velog.io/@youngjun_dev/suminteger</link>
            <guid>https://velog.io/@youngjun_dev/suminteger</guid>
            <pubDate>Sat, 25 Dec 2021 15:53:38 GMT</pubDate>
            <description><![CDATA[<h3 id="문제-설명">문제 설명</h3>
<blockquote>
<p>두 정수 a, b가 주어졌을 때 a와 b 사이에 속한 모든 정수의 합을 리턴하는 함수, solution을 완성하세요.
예를 들어 a = 3, b = 5인 경우, 3 + 4 + 5 = 12이므로 12를 리턴합니다.</p>
</blockquote>
<h3 id="제한-조건">제한 조건</h3>
<blockquote>
<p>a와 b가 같은 경우는 둘 중 아무 수나 리턴하세요.
a와 b는 -10,000,000 이상 10,000,000 이하인 정수입니다.
a와 b의 대소관계는 정해져있지 않습니다.</p>
</blockquote>
<h3 id="입출력-예">입출력 예</h3>
<blockquote>
<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>
</blockquote>
<h3 id="문제풀이">문제풀이</h3>
<pre><code class="language-python">def solution(a, b):
    answer = 0
    if a==b:
        return a
    elif a&lt;b:
        for i in range(a,b+1):
            answer+=i
    elif a&gt;b:
        for i in range(b,a+1):
            answer+=i
    return answer
</code></pre>
]]></description>
        </item>
    </channel>
</rss>