Skip to content

Instantly share code, notes, and snippets.

@toboqus
Created January 8, 2016 08:35
Show Gist options
  • Save toboqus/75bd224abb41cac6b92d to your computer and use it in GitHub Desktop.
Save toboqus/75bd224abb41cac6b92d to your computer and use it in GitHub Desktop.
Rotating a string 180 degrees
public static String Reverse(String sentence){
String normal = "abcdefghijklmnopqrstuvwxyz_,;.?!/\\'";
String split = "ɐqɔpǝɟbɥıظʞןɯuodbɹsʇnʌʍxʎz‾'؛˙¿¡/\\,";
normal += "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
split += "∀qϽᗡƎℲƃHIſʞ˥WNOԀὉᴚS⊥∩ΛMXʎZ";
normal += "0123456789";
split += "0ƖᄅƐㄣϛ9ㄥ86";
StringBuilder res = new StringBuilder();
for(int i = sentence.length()-1; i>= 0; i--){
char letter = sentence.charAt(i);
int a = normal.indexOf(letter);
res.append((a != -1) ? split.charAt(a) : letter);
}
return res.toString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment