YJ의 새벽

프로그래머스(0) - 가위 바위 보 본문

코딩테스트연습/프로그래머스

프로그래머스(0) - 가위 바위 보

YJDawn 2024. 3. 13. 14:24

 

 

 

 

class Solution {
    public String solution(String rsp) {
        String answer = "";
        
        // 가위 2
        // 바위 0
        // 보  5
        
        for(int i=0; i<rsp.length(); i++) {
        	if(rsp.split("")[i].equals("0")) {
        		answer += "5";
        	}else if (rsp.split("")[i].equals("2")) {
        		answer += "0";
        	}else {
        		answer += "2";
        	}
        }
        
        return answer;
    }
}
Comments