# par_count # # Run with: # # $ python par_count.py < par_out_121.txt # # The accompanying are par_out_121.txt, par_out_3950.txt # il nr finale e' il nr di parentesi sinistre (e quindi delle dx). # par_out_3950.txt e' cosi' lungo che il print non rimane tutto nella finestra import sys from collections import Counter data = sys.stdin.read() print('deb', 'tipo dato: ', type(data)) print('deb', 'dato: ', data) print('deb', 'len: ', len(data)) count_list = Counter(data).most_common() print('most_common in data: ', count_list) s=0 for i in range(1,len(data)-1): ds = 0 if data[i] == "(": ds = +1 if data[i] == ")": ds = -1 s += ds print(i,s)