Skip to content

Instantly share code, notes, and snippets.

@hackerdem
Created December 19, 2016 04:40
Show Gist options
  • Select an option

  • Save hackerdem/50731d28c3d1278479309a51681ad903 to your computer and use it in GitHub Desktop.

Select an option

Save hackerdem/50731d28c3d1278479309a51681ad903 to your computer and use it in GitHub Desktop.

Revisions

  1. hackerdem created this gist Dec 19, 2016.
    19 changes: 19 additions & 0 deletions check_paranthesis
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    import sys,re

    with open('C:/Users/erdem/Desktop/memories/newe.txt', 'r') as test_cases:
    for test in test_cases:
    if test in ['','\n']:pass
    else:
    v=re.search('([-;\w]+)', test).group(0)
    vqq=';'.join(re.findall('([\d|\w]+-[\d|\w]+)', test))
    st=''
    if vqq==v and 'END' in v and 'BEGIN' in v:
    a=[]
    st=re.search('(BEGIN-)([\d])',v).group(2)
    check=re.findall('(-[\d]+)',v)
    while st!='END' and st not in a:
    a.append(st)
    st=re.search('({}-)((END)|[\d]+)'.format(st),v).group(2)
    if st=='END' and len(a)==len(check):print('GOOD')
    else:print('BAD')