Advertisement
Guest User

Untitled

a guest
May 4th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.*;
  3.  
  4. /**
  5. * @author ajay subramanya
  6. * */
  7. public class Solution {
  8.  
  9. public static void main(String[] args) {
  10. Scanner in = new Scanner(System.in);
  11. int n = in.nextInt();
  12. for(int i = 0; i <= n; i++){
  13. String line = in.nextLine();
  14. if (line.isEmpty() || line == null) continue;
  15. char[] letters = line.toCharArray();
  16. int len = letters.length - 1;
  17. int changes = 0;
  18. for(int j = 0; j <= len / 2 ; j++){
  19. if (letters[j] != letters[len - j])
  20. changes += Math.abs(Character.toLowerCase(letters[j]) - Character.toLowerCase(letters[len - j]));
  21. }
  22. System.out.println(changes);
  23. }
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement