def main(): our_queue = da.Queue() populate_obj = read_file(args.inputFileName, our_queue) our_queue_list = da.Queue() for i in range(len(our_queue)): dequeue = our_queue[i]._dequeue() our_queue_list._enqueue(dequeue) #copy_queue = copy.deepcopy(our_queue) palindrome_yes = palindrome(populate_obj) print(palindrome_yes) reverse_queue = reverse(our_queue_list) palindrome_yes_yes = palindrome(reverse_queue) print(palindrome_yes_yes) print(populate_obj._front()) print(length_and_sum(populate_obj))
def palindrome(Array_Queue): Queue = da.Queue() reverse_queue = da.Queue() initial_list = [] queue_list = [] if Array_Queue != None: dequeue = Array_Queue._dequeue() initial_list.append(dequeue) Queue._enqueue(dequeue) queue_list = initial_list[::-1] for i in queue_list: Array_Queue._enqueue(i) Queue._enqueue(i) if Queue == reverse_queue: return True else: return False
def reverse(Array_queue): our_list = da.Queue() the_list = [] if not Array_queue.isempty(): dequeue = Array_queue._dequeue() the_list.append(dequeue) new_list = the_list[::-1] our_list._enqueue(new_list) return our_list
def main(): our_queue = da.Queue() populate_obj = read_file(args.inputFileName, our_queue) #first_que_copy = da.Queue() #second_que_copy = da.Queue() #for i in range(len(our_queue)): #dequeue = our_queue[i] #first_que_copy.enqueue(dequeue) #second_que_copy.enqueue(dequeue) palindrome_yes = palindrome(populate_obj) print(palindrome_yes) reverse_queue = reverse(our_queue) palindrome_yes_yes = palindrome(reverse_queue) print(palindrome_yes_yes) print(populate_obj.front()) print(length_and_sum(populate_obj))
def read_file(inputFileName, queue): queue = da.Queue() read_file = open(inputFileName, 'r').readlines() for i in read_file: queue._enqueue(i) return queue