Created
October 16, 2016 11:41
-
-
Save yssharma/7fd4342a75e614239f89ede6ab0480d8 to your computer and use it in GitHub Desktop.
Codeforces 376 Div 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package codeforces.x376; | |
import java.util.Scanner; | |
/** | |
* Created by ysharma on 10/16/16. | |
*/ | |
public class A { | |
public static void main(String[] args) { | |
new A().doit(); | |
} | |
private void doit(){ | |
Scanner sc = new Scanner(System.in); | |
String name = sc.next(); | |
char last = 'a'; | |
int res = 0; | |
for(char ch : name.toCharArray()){ | |
res += Math.min(Math.abs(last - ch), 26 - Math.abs(last - ch)); | |
last = ch; | |
} | |
System.out.println(res); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment