Created
January 8, 2016 08:35
-
-
Save toboqus/75bd224abb41cac6b92d to your computer and use it in GitHub Desktop.
Rotating a string 180 degrees
This file contains 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
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