+ import std.math; import std.typecons; - import std.math; /* Find the shortest palindrome that begins with a supplied string. - Algorithm idea is simple: ? ---- + Algorithm idea is simple: - - Find the longest postfix of supplied string that is a palindrome. ? ---- + - Find the longest postfix of supplied string that is a palindrome. - - Append to the end of the string reverse of a string prefix that comes before the palindromic suffix. ? ---- + - Append to the end of the string reverse of a string prefix that comes before the palindromic suffix. - >>> make_palindrome("") ? ---- + >>> make_palindrome("") - "" + "" - >>> make_palindrome("cat") ? ---- + >>> make_palindrome("cat") - "catac" ? ---- + "catac" - >>> make_palindrome("cata") ? ---- + >>> make_palindrome("cata") - "catac" ? ---- + "catac" - */ string make_palindrome(string string)