-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpalindrome.py
More file actions
33 lines (29 loc) · 741 Bytes
/
palindrome.py
File metadata and controls
33 lines (29 loc) · 741 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from queues.queue import Queue
from stacks.stackarray import StackArray
import sys
import os
sys.path.append(os.path.abspath('.'))
print(sys.path)
def checkPalindrome(input):
input = input.lower()
input = removepuntuation(input)
inputLength = len(input)
stacks = StackArray(inputLength)
queues = Queue(inputLength)
for i in range(inputLength):
stacks.push(input[i])
queues.enqueue(input[i])
i = 0
while i < inputLength:
if not stacks.pop() == queues.dequeue():
return False
i += 1
return True
def removepuntuation(input):
puntuation = ".,/?;:! "
temp = ""
for i in range(len(input)):
if not input[i] in puntuation:
temp += input[i]
return temp
print(checkPalindrome("Racecare"))