가위는 2 바위는 0 보는 5로 표현합니다. 가위 바위 보를 내는 순서대로 나타낸 문자열 rsp가 매개변수로 주어질 때, rsp에 저장된 가위 바위 보를 모두 이기는 경우를 순서대로 나타낸 문자열을 return하도록 solution 함수를 완성해보세요.
가위, 바위, 보를 나타내는 숫자 표현끼리 연산한 결과를 토대로 경우의 수를 나누어 이기는 값을 문자열에 저장해 주었다.
class Solution {
public String solution(String rsp) {
StringBuffer answer = new StringBuffer();
for(int i=0; i<rsp.length(); i++){
int choice = Integer.parseInt(String.valueOf(rsp.charAt(i)));
if(choice - 0 == 2){
answer.append("0");
}else if(choice - 5 == -5){
answer.append("5");
}else if(choice - 2 == 3){
answer.append("2");
}
}
return answer.toString();
}
}
