def mirror(s):
"""
"""
stack = Stack()
x = 0
n = len(s)
# Check that the index x is valid index before using it. Short circuit evaluation.
while x < n and s[x] != 'm':
stack.push(s[x])
x = x + 1
# skip over 'm'
x = x + 1
while x < n and not stack.is_empty() and s[x] == stack.pop():
x = x + 1
is_mirror = ( x == n and stack.empty() )
return is_mirror
Created
May 10, 2016 17:55
-
-
Save rickhenderson/0a913c16ecf28738147b21427be86f6a to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment