Skip to content

Commit 9803aba

Browse files
committed
[level 0] Title: 외계행성의 나이, Time: 1.86 ms, Memory: 98.8 MB -BaekjoonHub
1 parent c1f159a commit 9803aba

2 files changed

Lines changed: 106 additions & 0 deletions

File tree

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# [level 0] 외계행성의 나이 - 120834
2+
3+
[문제 링크](https://school.programmers.co.kr/learn/courses/30/lessons/120834)
4+
5+
### 성능 요약
6+
7+
메모리: 98.8 MB, 시간: 1.86 ms
8+
9+
### 구분
10+
11+
코딩테스트 연습 > 코딩테스트 입문
12+
13+
### 채점결과
14+
15+
정확성: 100.0<br/>합계: 100.0 / 100.0
16+
17+
### 제출 일자
18+
19+
2026년 04월 21일 13:14:01
20+
21+
### 문제 설명
22+
23+
<p>우주여행을 하던 머쓱이는 엔진 고장으로 PROGRAMMERS-962 행성에 불시착하게 됐습니다. 입국심사에서 나이를 말해야 하는데, PROGRAMMERS-962 행성에서는 나이를 알파벳으로 말하고 있습니다. a는 0, b는 1, c는 2, ..., j는 9입니다. 예를 들어 23살은 cd, 51살은 fb로 표현합니다. 나이 <code>age</code>가 매개변수로 주어질 때 PROGRAMMER-962식 나이를 return하도록 solution 함수를 완성해주세요.</p>
24+
25+
<hr>
26+
27+
<h5>제한사항</h5>
28+
29+
<ul>
30+
<li><code>age</code>는 자연수입니다.</li>
31+
<li><code>age</code> ≤ 1,000</li>
32+
<li>PROGRAMMERS-962 행성은 알파벳 소문자만 사용합니다.</li>
33+
</ul>
34+
35+
<hr>
36+
37+
<h5>입출력 예</h5>
38+
<table class="table">
39+
<thead><tr>
40+
<th>age</th>
41+
<th>result</th>
42+
</tr>
43+
</thead>
44+
<tbody><tr>
45+
<td>23</td>
46+
<td>"cd"</td>
47+
</tr>
48+
<tr>
49+
<td>51</td>
50+
<td>"fb"</td>
51+
</tr>
52+
<tr>
53+
<td>100</td>
54+
<td>"baa"</td>
55+
</tr>
56+
</tbody>
57+
</table>
58+
<hr>
59+
60+
<h5>입출력 예 설명</h5>
61+
62+
<p>입출력 예 #1</p>
63+
64+
<ul>
65+
<li><code>age</code>가 23이므로 "cd"를 return합니다.</li>
66+
</ul>
67+
68+
<p>입출력 예 #2</p>
69+
70+
<ul>
71+
<li><code>age</code>가 51이므로 "fb"를 return합니다.</li>
72+
</ul>
73+
74+
<p>입출력 예 #3</p>
75+
76+
<ul>
77+
<li><code>age</code>가 100이므로 "baa"를 return합니다.</li>
78+
</ul>
79+
80+
81+
> 출처: 프로그래머스 코딩 테스트 연습, https://school.programmers.co.kr/learn/challenges
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
class Solution {
2+
public String solution(int age) {
3+
String answer = "";
4+
5+
String num = Integer.toString(age);
6+
char c;
7+
8+
for(int i=0; i<num.length(); i++){
9+
c = num.charAt(i);
10+
if(c=='0') answer += "a";
11+
if(c=='1') answer += "b";
12+
if(c=='2') answer += "c";
13+
if(c=='3') answer += "d";
14+
if(c=='4') answer += "e";
15+
if(c=='5') answer += "f";
16+
if(c=='6') answer += "g";
17+
if(c=='7') answer += "h";
18+
if(c=='8') answer += "i";
19+
if(c=='9') answer += "j";
20+
21+
}
22+
23+
return answer;
24+
}
25+
}

0 commit comments

Comments
 (0)