he-010
1.000
Proposed solution
```python
def is_palindrome(string: str) -> bool:
""" Test if given string is a palindrome """
return string == string[::-1]
def make_palindrome(string: str) -> str:
""" Find the shortest palindrome that begins with a supplied string.
Algorithm idea is simple:
- 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.
>>> make_palindrome('')
''
>>> make_palindrome('cat')
'catac'
>>> make_palindrome('cata')
'catac'
"""
if not string:
return ""
# Find the longest palindromic postfix
for i in range(len(string)):
if is_palindrome(string[i:]):
# Append the reverse of the prefix to make it a palindrome
return string + string[:i][::-1]
# If no palindromic postfix found (shouldn't happen), append reverse of entire string except last char
return string + string[:-1][::-1]
```Test output (stdout)
. [100%] 1 passed in 0.01s
System prompt
You are an expert programmer. Solve the task exactly as specified. Output your solution as fenced code blocks using the required file name(s) and the exact function/type signatures requested. Prefer correctness; do not include prose outside code unless asked.