Skip to content

Instantly share code, notes, and snippets.

@mvallebr
Created June 15, 2017 09:43
Show Gist options
  • Select an option

  • Save mvallebr/aa0fd0ea4a692473a674a445a96fee2a to your computer and use it in GitHub Desktop.

Select an option

Save mvallebr/aa0fd0ea4a692473a674a445a96fee2a to your computer and use it in GitHub Desktop.
"""
# Expecto Palindronum
Memory Limit:64 MB
Time Limit: 5 s
A palindrome is a word that reads the same backward and forward.
Given a string S, you are allowed to convert it to a palindrome by adding 0 or more characters in front of it.
Find the length of the shortest palindrome that you can create from S by applying the above transformation.
## Input Specifications
Your program will take
A string S ( 1 ≤ Length(S) ≤ 100) where each character of S will be
a lowercase alphabet (Between 'a' to 'z')
## Output Specifications
For each input, print out an integer L denoting the length of the shortest palindrome you can
generate from S.
## Sample Input/Output
INPUT
baaa
OUTPUT
7
EXPLANATION
The shortest palindrome you can construct from 'baaa' is 'aaabaaa'.
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment