From b240b35433887f5659b6d54004bebd73fb662d34 Mon Sep 17 00:00:00 2001 From: bt3 Date: Sun, 25 Oct 2015 20:15:33 -0700 Subject: [PATCH] Delete balance_parenthesis.py --- .../stacks/balance_parenthesis.py | 41 ------------------- 1 file changed, 41 deletions(-) delete mode 100644 src/abstract_structures/stacks/balance_parenthesis.py diff --git a/src/abstract_structures/stacks/balance_parenthesis.py b/src/abstract_structures/stacks/balance_parenthesis.py deleted file mode 100644 index a54c13d..0000000 --- a/src/abstract_structures/stacks/balance_parenthesis.py +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env python - -__author__ = "bt3" - -''' use a stack to balance the parenteses of a string ''' - - -from stack import Stack - -def balance_par_str_with_stack(str1): - - s = Stack() - balanced = True - index = 0 - - while index < len(str1) and balanced: - - symbol = str1[index] - - if symbol == "(": - s.push(symbol) - - else: - if s.isEmpty(): - balanced = False - else: - s.pop() - - index = index + 1 - - if balanced and s.isEmpty(): - return True - - else: - return False - - - -if __name__ == '__main__': - print(balance_par_str_with_stack('((()))')) - print(balance_par_str_with_stack('(()'))