class PalinTester {
public static void main
(String[] args
) { printModifiable("010");
printModifiable("0110");
printNotModyfiable("010");
//printNotModyfiable("0110");
}
private static void printModifiable
(String string
) { StringBuilder sb = new StringBuilder(string);
for (int i = 0; i <= string.length(); i++) {
sb.insert(i, 'X');
sb.delete(i, i + 1);
}
}
private static void printNotModyfiable
(String string
) { StringBuilder sb = new StringBuilder(string);
for (int i = 0; i <= string.length(); i++) {
sb.insert(i, 'X');
for (int j = 0; j <= sb.length(); j++) {
sb.insert(j, 'Y');
sb.delete(j, j + 1);
}
sb.delete(i, i + 1);
}
}
}
Y2xhc3MgUGFsaW5UZXN0ZXIgewoKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluKFN0cmluZ1tdIGFyZ3MpIHsKCQlTeXN0ZW0ub3V0LnByaW50bG4oIlllczoiKTsKCQlwcmludE1vZGlmaWFibGUoIjAxMCIpOwoJCXByaW50TW9kaWZpYWJsZSgiMDExMCIpOwoJCQoJCVN5c3RlbS5vdXQucHJpbnRsbigiTm86Iik7CgkJcHJpbnROb3RNb2R5ZmlhYmxlKCIwMTAiKTsKCQkvL3ByaW50Tm90TW9keWZpYWJsZSgiMDExMCIpOwoJfQoKCXByaXZhdGUgc3RhdGljIHZvaWQgcHJpbnRNb2RpZmlhYmxlKFN0cmluZyBzdHJpbmcpIHsKCQlTdHJpbmdCdWlsZGVyIHNiID0gbmV3IFN0cmluZ0J1aWxkZXIoc3RyaW5nKTsKCQlmb3IgKGludCBpID0gMDsgaSA8PSBzdHJpbmcubGVuZ3RoKCk7IGkrKykgewoJCQlzYi5pbnNlcnQoaSwgJ1gnKTsKCQkJU3lzdGVtLm91dC5wcmludGxuKHNiKTsKCQkJc2IuZGVsZXRlKGksIGkgKyAxKTsKCQl9Cgl9CgoJcHJpdmF0ZSBzdGF0aWMgdm9pZCBwcmludE5vdE1vZHlmaWFibGUoU3RyaW5nIHN0cmluZykgewoJCVN0cmluZ0J1aWxkZXIgc2IgPSBuZXcgU3RyaW5nQnVpbGR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