public boolean isScramble(String s1, String s2) {
		int l1 = s1.length();
		int l2 = s2.length();
		if (l1 != l2)
			return false;
		if (s1.equals(s2))
			return true;
		int i;
		int sum1, sum2;
		for (i = 0, sum1 = 0, sum2 = 0; i < l1; i++) {
			sum1 += s1.charAt(i) - 'a';
			sum2 += s2.charAt(i) - 'a';
		}
		if (sum1 != sum2)
			return false;
		String s11, s12, s21, s22;
		for (i = 1; i < l1; i++) {
			s11 = s1.substring(0, i);
			s12 = s1.substring(i);
			// forward order
			{
				s21 = s2.substring(0, i);
				s22 = s2.substring(i);
				if ((isScramble(s11, s21) && isScramble(s12, s22))) {
					return true;
				}
			}
			// reversed order
			{
				s21 = s2.substring(l2 - i);
				s22 = s2.substring(0, l2 - i);
				if ((isScramble(s11, s21) && isScramble(s12, s22))) {
					return true;
				}
			}
		}
		return false;
	}