Skip to content

Commit 7096127

Browse files
committed
feat : 프로그래머스 greedy 실패
1 parent 8173842 commit 7096127

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package sgyj.programmers.yeji.greedy;
2+
3+
// 조이스틱
4+
public class Solution42860 {
5+
private static int answer;
6+
private static int min = Integer.MAX_VALUE;
7+
private static int[] visited;
8+
// A - 65, Z - 90
9+
public static int solution(String name) {
10+
visited = new int[name.length()];
11+
int startAlpha = name.charAt( 0 );
12+
13+
if(startAlpha<=77){
14+
visited[0] = startAlpha+1;
15+
answer+= startAlpha+1;
16+
}else{
17+
visited[0] = 90-startAlpha;
18+
answer+= 90-startAlpha;
19+
}
20+
for(int i=1; i<name.length(); i++){
21+
moveJoyStick(1,visited[i-1], name,0);
22+
}
23+
return answer;
24+
}
25+
26+
public static void moveJoyStick(int i, int cur, String name, int count){
27+
int result = Integer.valueOf(name.charAt( i ));
28+
int abs = Math.abs( 90 - cur );
29+
30+
31+
}
32+
public static void main ( String[] args ) {
33+
String name = "JEROEN";
34+
System.out.println(solution(name));
35+
}
36+
}

0 commit comments

Comments
 (0)