6 kyu https://www.codewars.com/kata/56b5afb4ed1f6d5fb0000991/train/javajava
//https://www.codewars.com/kata/56b5afb4ed1f6d5fb0000991/train/java package codewars; public class RevRot{ private static Boolean divisible(StringBuilder s){ long sum = 0; for(int i = 0; i < s.length(); i++){ sum += Math.pow(Integer.valueOf(s.charAt(i)),3); } if(sum % 2 == 0){ return true; }else{ return false; } } private static String rotate(StringBuilder sb){ sb.append(sb.charAt(0)); sb.deleteCharAt(0); return sb.toString(); } public static String revRot(String str, int sz){ if(sz <= 0 || str == null || "".equals(str) || sz > str.length()){ return ""; } StringBuilder[] sb = new StringBuilder[str.length() / sz]; for(int i = 0; i < sb.length; i++){ sb[i] = new StringBuilder(); for(int j = 0; j < sz; j++){ sb[i].append(str.charAt(j + i * sz)); } } for(int i = 0; i < sb.length; i++){ if(RevRot.divisible(sb[i])){ sb[i] = sb[i].reverse(); }else{ sb[i] = new StringBuilder(RevRot.rotate(sb[i])); } } StringBuilder re = new StringBuilder(); for(String x : sb){ re.append(x); } return re.toString(); } }