def test_omega(omega, debug=False): print('before') util.print_array(omega) new_omega = comb(omega, debug) print('after') util.print_array(new_omega) return new_omega
def get_block_totals(): for size in range(3, 4): stacks = get_permutation_stacks(size) totals = [[0 for j in range(len(stacks[0][i]))] for i in range(len(stacks[0]))] #print('totals', totals) for s in stacks: util.print_array(s) for i in range(len(s)): for j in range(len(s[i])): totals[i][j] += s[i][j] print('size=', size) print('num triangles=', len(stacks)) #print(totals) tot = 0 for row in totals: tot += sum(row) print('total blocks=', tot) for x in totals: print(x) print("----------")
def stack_to_magog(stack): size = len(stack) magog = util.get_all_zero_triangle(size) print('CONVERTING') util.print_array(stack) for idx in range(size): stack_row = stack[size - 1 - idx] start_idx = idx mrow_idx = size - 1 for i in reversed(range(len(stack_row))): if stack_row[i] == 0: start_idx += 1 else: mrow_len = len(magog[mrow_idx]) for j in range(start_idx, mrow_len): magog[mrow_idx][j] = magog[mrow_idx][j] + 1 mrow_idx += -1 print('------ idx=', idx) util.print_array(magog) return magog
def test_layer_triangle(size): tss_list = btss.build_tss(size) bt_list = bbt.build_bt(size) after_map = dict() error_count = 0 for t in tss_list: tlayer = get_layer_triangle(t) s = util.flip_triangle2(tlayer) #print(t, s) print('before') util.print_array(t) print('after') util.print_array(s) key = str(s) if not key in after_map: after_map[key] = [ t,] else: after_map[key].append(t) # if not s in bt_list: # error_count+=1 # print('start tss') # print(t) # print('after') # util.print_array(s) #print('errors', error_count) print('tss size', len(tss_list)) print('after size', len(after_map)) rep_count = 0 for key in after_map: key_list = after_map[key] if len(key_list) > 1: rep_count += 1 print('repeated', key) print('AFTER') util.print_array(ast.literal_eval(key)) print('BEFORE') for x in key_list: util.print_array(x) print('>>>>>>>>>>>>>>>>missing') missing_count = 0 for b in bt_list: if not str(b) in after_map: print('missing', b) util.print_array(b) missing_count += 1 print('before', len(tss_list)) print('after', len(after_map)) print('repeated', rep_count) print('missing', missing_count)
def get_permutation_layers_right(bin_tri): triangle = [[x for x in row] for row in reversed(bin_tri)] size = len(triangle) print('input') util.print_array(triangle) layers = [] for i in range(size): layer = [] for j in range(len(triangle)-i): row = triangle[j] if 1 in row: rev_row = row[::-1] idx = len(rev_row) - 1 - rev_row.index(1) layer.append(idx+1) row[idx]=0 else: layer.append(0) layers.append(layer) print('output') util.print_array(layers) return layers
def comb(tss, debug=False): size = len(tss) triangle = util.clone_array(tss) if debug: prev = util.clone_array(tss) print("COMBING") util.print_array(triangle) for i in reversed(range(1,size)): print('dealing with row ', i) for j in range(i,size): print('\thandling row ', j) triangle = handle_row_swap(triangle, j) if debug and not prev == triangle: print('>>>>> i,j', i, j) util.print_array(triangle) prev = util.clone_array(triangle) # for i in range(1,size): # handle_row_swap(triangle, i) # # if debug and not prev == triangle: # print('>>>>> i', i) # util.print_array(triangle) # prev = util.clone_array(triangle) # return triangle
def comb_BD(binary_triangle, down_triangle): size = len(binary_triangle) B = [[x for x in row] for row in binary_triangle] D = [[x for x in row] for row in down_triangle] logging.debug('comb_DB start') logging.debug(str(B)) logging.debug(str(D)) logging.debug('omega') logging.debug(str(get_omega(B, D))) util.print_array(B) util.print_array(D) for k in reversed(range(size)): logging.debug('\tcomb row %s', k) for i in range(k, size - 1): B, D = untangle(B, D, i, k) logging.debug('\tuntangle %s %s', i, k) logging.debug('\t\t %s', B) logging.debug('\t\t %s', D) logging.debug('comb_DB returning') logging.debug(str(B)) logging.debug(str(D)) logging.debug('omega') logging.debug(str(get_omega(B, D))) logging.debug('++++++++++++++++++++++++') return B, D
def count_subtriangles(size): print('*************') gog_list = get_gog(size) magog_list = get_magog(size) kagog_list = get_kagog(size) count = 0 print('GOG ONLY') gog_not_magog_list = [] gog_not_kagog_list = [] all_list = [] for x in gog_list: if x not in magog_list: gog_not_magog_list.append(x) elif x in kagog_list: all_list.append(x) if x not in kagog_list: gog_not_kagog_list.append(x) for k in gog_not_kagog_list: util.print_array(k) print('gog not magog', len(gog_not_magog_list)) print('gog not kagog', len(gog_not_kagog_list)) print('MAGOG ONLY') magog_not_gog_list = [] magog_not_kagog_list = [] for x in magog_list: if x not in gog_list: magog_not_gog_list.append(x) if x not in kagog_list: magog_not_kagog_list.append(x) print('magog not gog', len(magog_not_gog_list)) print('magog not kagog', len(magog_not_kagog_list)) #print(len(magog_only)) #print(count) print('KAGOG ONLY') kagog_not_gog_list = [] kagog_not_magog_list = [] for x in kagog_list: if x not in gog_list: kagog_not_gog_list.append(x) if x not in magog_list: kagog_not_magog_list.append(x) for k in kagog_only: util.print_array(k) print('kagog not gog', len(kagog_not_gog_list)) print('kagog not magog', len(kagog_not_magog_list)) count = len(gog_list) print('gog and magog', count - len(gog_not_magog_list)) print('gog and kagog', count - len(gog_not_kagog_list)) print('magog and kagog', count - len(magog_not_kagog_list)) print('all three', len(all_list))
def comb(tss, debug=False): size = len(tss) triangle = util.clone_array(tss) if debug: prev = util.clone_array(tss) print("COMBING") util.print_array(triangle) for i in range(1, size): if debug: print('dealing with row ', i) for j in reversed(range(1, i + 1)): if debug: print('\thandling row ', j) triangle = handle_row_with_col_max_v4(triangle, j, size - i) if debug and not prev == triangle: print('>>>>> i,j', i, j) util.print_array(triangle) prev = util.clone_array(triangle) return triangle
def get_catalan_layers_impl(bin_tri_reversed): print('\timpl input', bin_tri_reversed) # we can change this one triangle = [[x for x in row] for row in bin_tri_reversed] if len(triangle) == 1: if triangle[0][0] == 1: return [ [ 0, ], ] else: return [ [ -1, ], ] # OTHERWISE: util.print_array(triangle) #triangle = util.flip_triangle2(triangle) size = len(triangle) layer = [] # find index of last one in each row for row in triangle: if 1 in row: layer.append(len(row) - 1 - row[::-1].index(1)) else: layer.append(-1) # check whether it is "supported" by a one in another row. for idx, val in enumerate(layer): if val > -1: if idx < len(layer) - 1 and any( x >= val for x in layer[idx + 1:len(layer)]): # can't take it yet layer[idx] = -1 else: # take it away from the triangle. print(triangle, idx, val) triangle[idx][val] = 0 new_triangle = [[x for x in row[0:len(row) - 1]] for row in triangle[0:len(triangle) - 1]] layers = get_catalan_layers_impl(new_triangle) layers.insert(0, layer) return layers
def compare(size): tss_list = get_boosted_tss(size) fbt_list = get_boosted_fbt(size) combed_map = dict() error_list = [] for k,t in enumerate(tss_list): print(k, 'before') util.print_array(t) if k % 1000 == 0: print('processed', k) b = comb(t) key = str(b) if not key in combed_map: combed_map[key] = [ t, ] else: print('REPEAT!!!!', k) combed_map[key].append(t) print(key, 'mapped from', combed_map[key]) print('after') util.print_array(b) if not b in fbt_list: print('ERROR NOT IN FBT LIST!', k) error_list.append([t,b]) print(t, 'mapped to', b) #print('======================') print('num errors', len(error_list)) for x in error_list: print(x[0], x[1], util.get_column_sums(x[0])) print('missing') for b in fbt_list: if not str(b) in combed_map: print(b, util.get_column_sums(b)) print('distinct', len(combed_map)) for k in combed_map: x = combed_map[k] if len(x) > 1: print(k) for y in x: print('\t', y, util.get_column_sums(y))
def test_to_magog(size): magogs = gog_magog.build_magog(size) magogs = [[row for row in reversed(magog)] for magog in magogs] stacks = build_stacks(size) # stacks = [[[1], [0,1]]] for s in stacks: # print('******************') # util.print_array(s) m = stack_to_magog(s) if not m in magogs: util.print_array(stack_to_magog(s))
def ponder_bad(): tri = bad5_list[10] print('START') util.print_array(tri) combed = comb(tri) print('END') util.print_array(combed) print(len(bad5_list)) print('hello') bad_map = dict() for bad in bad5_list: #print(bad) key = get_diag_sums(bad) if not str(key) in bad_map: bad_map[str(key)] = [] bad_map[str(key)].append(bad) for key in bad_map: print(key, len(bad_map[key])) print('here are the baddies') for x in bad_map['[2, 4, 3, 2, 1]']: print('BAD ==========') util.print_array(x) util.print_array(comb(x))
def comb(triangle_in, debug=False): triangle = util.clone_array(triangle_in) size = len(triangle) for i in range(size - 1): max_idx = len(triangle[i + 1]) for j in reversed(range(i + 1)): if debug: print('handle', i, j) new_big, new_small = handle_rows(triangle[j], triangle[j + 1], max_idx) triangle[j] = new_big triangle[j + 1] = new_small if debug: util.print_array(triangle) return triangle
def comb_with_col_max(tss, debug=False): size = len(tss) triangle = util.clone_array(tss) if debug: prev = util.clone_array(tss) print("COMBING with col max") util.print_array(triangle) for col_idx in reversed(range(0,size-1)): if debug: print('dealing with col_max ', col_idx) for j in reversed(range(0,size - col_idx-1)): if debug: print('\thandling row ', j) triangle = handle_row_with_col_max(triangle, j, col_idx) if debug and not prev == triangle: print('>>>>> col_max,j', col_idx, j) util.print_array(triangle) prev = util.clone_array(triangle) # for i in range(1,size): # handle_row_swap(triangle, i) # # if debug and not prev == triangle: # print('>>>>> i', i) # util.print_array(triangle) # prev = util.clone_array(triangle) # # # final time needed? # if debug: # print('one more time') # for j in reversed(range(0,size-1)): # if debug: # print('\thandling row ', j) # triangle = handle_row_with_col_max(triangle, j, col_max) # # if debug and not prev == triangle: # print('>>>>> col_max,j', col_max, j) # util.print_array(triangle) # prev = util.clone_array(triangle) return triangle
def test_flip_matrix(): mat_list = get_ssyt_matrix(4) out_list = [flip_matrix_to_omega(matrix) for matrix in mat_list] for idx in range(len(mat_list)): #print('the input is') #util.print_array(mat_list[idx]) #print('the output is') util.print_array(out_list[idx])
def test_bin_and_flipped_reordered(): ssyt_list = ssyt_triangle.get_ssyt_matrix(4) bin_tri_reordered = ssyt_triangle.get_bin3_tri_reordered() ssyt_omega_list = [ util.get_absolute_array(ssyt_triangle.flip_matrix_to_omega(m)) for m in ssyt_list ] bin_omega_list = [ util.get_absolute_array(binary_comb.get_omega_for_cliff(b)) for b in bin_tri_reordered ] count = 0 diff_count = 0 for s, b in zip(ssyt_omega_list, bin_omega_list): if not s == b: if not (s == comb_bin(b)): print("FAILED!!!!!!!!!!") print('>>>>>>>>>>> count=', count) print('binary') util.print_array(b) print('flipped ssyt x') util.print_array(s) diff_count += 1 print('*******combed binary') util.print_array(comb_bin(b)) count += 1 print('diff count ', diff_count)
def write_bin_and_flipped_ssyt(): ssyt_list = get_ssyt_matrix(4) ssyt_omega_list = [ absolute_triangle(flip_matrix_to_omega(m)) for m in ssyt_list ] bin_omega_list = [ absolute_triangle(binary_comb.get_omega_for_cliff(b)) for b in bin_tri_reordered ] count = 0 diff_count = 0 for s,b in zip(ssyt_omega_list, bin_omega_list): if not s == b: print('>>>>>>>>>>> count=', count) print('binary') util.print_array(b) print('flipped ssyt') util.print_array(s) diff_count+=1 count+=1 print('diff count ', diff_count)
def compare_words(): for size in range(4, 5): sst_list = build_stack_set.build_stacks(size) sst_list = stack_set_stats.one_one_per_col(sst_list, size) words = get_words(size) bad_count = 0 good_tri_list = [] bad_map = dict() for w in words: t = word_to_triangle(w) is_sst = check_sst(t) if not is_sst: print(w) util.print_array(t) key = get_key(t) if not key in bad_map: bad_map[key] = [] bad_map[key].append(t) bad_count += 1 else: good_tri_list.append(t) print('size', size) print('total', len(words)) print('bad', bad_count) print('good', len(words) - bad_count) sst_unmatched_map = dict() for sst in sst_list: if not sst in good_tri_list: key = get_key(sst) if not key in sst_unmatched_map: sst_unmatched_map[key] = [] sst_unmatched_map[key].append(sst) print('bad map', len(bad_map)) print('sst unmatched map', len(sst_unmatched_map)) print('--------------') for key in bad_map: print('==================') word_list = bad_map[key] sst_list = sst_unmatched_map[key] print('KEY', key, 'bad', len(word_list), 'sst', len(sst_list)) print('words') for w in word_list: util.print_array(w) print('sst') for s in sst_list: util.print_array(s)
] missing_fbt = [[[3, 1, 1], [1, 1], [0]]] #t = t_list[16] #t = t_list[17] #t = t_list[18] fail_list = [] for k in range(0): t = bad_tss[k] c = comb(t, True) b = missing_fbt[k] util.print_array(c) util.print_array(b) if not c == b: fail_list.append(k) print('failures', fail_list) t3a = [[2, 1, 1], [2, 1], [1]] t3b = [[2, 1, 0], [2, 1], [1]] t3c = [[2, 1, 0], [2, 1], [0]] t3d = [[2, 1, 0], [1, 1], [1]] t3e = [[2, 1, 0], [2, 1], [1]] tx = [[3, 2, 2, 1], [3, 2, 1], [1, 0], [0]] tx = [[3, 2, 2, 2], [3, 2, 2], [1, 0],
def get_std_omega_for_cliff(B): newB = [ [1 -x for x in row ] for row in B] util.print_array(newB) return get_omega(newB, get_down_for_cliff(newB))
def compare_two_rows(size, col_sums=()): # tss_list = get_boosted_tss(size) # fbt_list = get_boosted_fbt(size) # # # # tss_row_list = [] # # for tss in tss_list: # temp = [tss[0], tss[1]] # # if not temp in tss_row_list: # tss_row_list.append(temp) # # fbt_row_list = [] # # for fbt in fbt_list: # temp = [fbt[0], fbt[1]] # # if not temp in fbt_row_list: # fbt_row_list.append(temp) ########### # tss_row_list = [ [x[0], x[1]] for x in tss_list] # fbt_row_list = [ [x[0], x[1]] for x in fbt_list] #combed_row_list = [handle_row_with_col_max_v4(tss_rows, 1, size-1) for tss_rows in tss_row_list] #print(len(tss_row_list), len(fbt_row_list), len(combed_row_list)) ########### tss_row_list2 = get_boosted_tss_trapezoid(size, 2) fbt_row_list2 = get_boosted_fbt_trapezoid(size, 2) tss_row_list = tss_row_list2 fbt_row_list = fbt_row_list2 fbt_match_list = [f for f in fbt_row_list if get_col_sums(f) == col_sums] combed_map = dict() error_list = [] comb_match_list = [] for k, t in enumerate(tss_row_list): print(k, 'before') util.print_array(t) tt = util.clone_array(t) if k % 1000 == 0: print('processed', k) #print("HANDLING ROW WITH COL MAX") #b = handle_row_with_col_max_v4(tt, 1, size-1) b = untangle(tt, 1, size - 1) key = str(b) if not key in combed_map: combed_map[key] = [ t, ] else: print('REPEAT!!!!', k) combed_map[key].append(t) print(key, 'mapped from', combed_map[key]) print('after') util.print_array(b) if not b in fbt_row_list: print('ERROR NOT IN FBT LIST!', k) error_list.append([t, b]) print(t, 'mapped to', b) else: if get_col_sums(b) == col_sums: comb_match_list.append(b) #print('======================') print('num errors', len(error_list)) for x in error_list: print(x[0], x[1], util.get_column_sums(x[0])) missing_count = 0 print('missing') for b in fbt_row_list: if not str(b) in combed_map: missing_count += 1 #print(b, util.get_column_sums(b)) print(missing_count) rep_count = 0 print('repeated') for k in combed_map: x = combed_map[k] if len(x) > 1: print(k) rep_count += 1 for y in x: print('\t', y, util.get_column_sums(y)) print('summary') print('tss=', len(tss_row_list), 'combed=', len(combed_map), 'fbt=', len(fbt_row_list), 'repeated=', rep_count, 'error=', len(error_list)) # print('only tss 1') # for t in tss_row_list: # if not t in tss_row_list2: # print('\t', t) # print('only tss 2') # for t in tss_row_list2: # if not t in tss_row_list: # print('\t', t) # # print('only fbt 1') # for t in fbt_row_list: # if not t in fbt_row_list2: # print('\t', t) # print('only fbt 2') # for t in fbt_row_list2: # if not t in fbt_row_list: # print('\t', t) if not col_sums == (): print('missing fbt with col_sums', col_sums) for f in fbt_match_list: if not f in comb_match_list: print(f)
b = [[2, 1, 1], [2, 1], [0]] s = [[3, 3, 1], [1, 0], [0]] # b = [[2, 1, 1], [1, 0], [1]] # s = [[3, 1, 1], [1, 0], [0]] # b = [[2, 1, 1], [1, 0], [1]] # s = [[3, 1, 1], [1, 0], [0]] b = [[3, 2, 2, 2], [3, 3, 2], [2, 2], [1]] b = [[3, 2, 1], [2, 2], [0]] b = [[2, 1, 0], [2, 1], [0]] b = [[2, 2, 1], [2, 2], [1]] b = [[3, 2, 1], [2, 2], [1]] b = [[2, 1, 1], [2, 1], [0]] b = [[2, 1, 1], [2, 1], [0]] print('binary') util.print_array(b) #print('flipped ssyt') #util.print_array(s) print('*******combed binary') util.print_array(comb_bin(b))
def test_size(size): bin_comb_omega_list = binary_comb.get_combed_triangles(size - 1) matrix_list = build_ssyt.get_ssyt_matrix(size) vless_comb_list = [] vless_comb_str_list = [] for k, m in enumerate(matrix_list): omega = build_ssyt.flip_matrix_to_omega(m) print('========= matrix', k) util.print_array(m) new_omega = test_omega(omega) for i in range(size - 1): new_omega[i][0] = abs(new_omega[i][0]) if new_omega[0] == [3, -2, -1]: print('matched first row') print(new_omega) print(vless_comb_list) if str(new_omega) in vless_comb_str_list: '>>>>>>> REPEAT!!!!' vless_comb_str_list.append(str(new_omega)) vless_comb_list.append(new_omega) combed_key = str(new_omega) if not combed_key in combed_map: combed_map[combed_key] = [ omega, ] else: combed_map[combed_key].append(omega) bad_vless_count = 0 for new_omega in vless_comb_list: for row in new_omega: row[0] = abs(row[0]) for k, new_omega in enumerate(vless_comb_list): if not new_omega in bin_comb_omega_list: print('bad vless comb', k) util.print_array(new_omega) bad_vless_count += 1 bin_count = 0 for k, omega in enumerate(bin_comb_omega_list): if not omega in vless_comb_list: print('missing', k) util.print_array(omega) bin_count += 1 print('bad count', bad_vless_count) print('missing count', bin_count) print(len(vless_comb_list)) temp_set = set() for x in vless_comb_list: temp_set.add(str(x)) print(len(vless_comb_list)) print('repeats!!!!') rep_count = 0 for key in combed_map: if len(combed_map[key]) > 1: print(key, len(combed_map[key]), combed_map[key]) rep_count += 1 print('repcount', rep_count)
def test_comb(): size = 3 combed_list = binary_comb.get_combed_triangles(size) bc_list = get_bigog_for_comb(size) #bc_list = [ bc_list[18], bc_list[52], bc_list[21], bc_list[53], bc_list[41], bc_list[60] ] #bc_list = [ bc_list[41], ] print('starting') fail_count = 0 #bc_list = [ [[0, 2, 3], [0, 2], [0]]] bc_mapping = dict() double_count = 0 bigog_omega_list = [] bigog_omega_after_list = [] for count, bc in enumerate(bc_list): B, D = to_BD(bc) #B, D = binary_comb.comb_BD(B,D) print('>>>>>>>>>>>>>>><<<<<<<<<<<<<<<') util.print_array(bc) util.print_array(B) util.print_array(D) util.print_array(binary_comb.get_omega(B, D)) # print('>>>>>>>>>>>>>>><<<<<<<<<<<<<<<') # print('>>>>>>>>>>>>>>><<<<<<<<<<<<<<<') # print('>>>>>>>>>>>>>>><<<<<<<<<<<<<<<') print('>>>>>>> combing', count, bc, B, D) print('\t', binary_comb.get_omega(B, D)) bigog_omega_list.append(binary_comb.get_omega(B, D)) BB, DD = gen_comb.comb_BD(B, D) combed = binary_comb.get_omega(BB, DD) bigog_omega_after_list.append(combed) print('\t\t\t', combed) combed_str = str(combed) before = binary_comb.get_omega(B, D) #print(combed) if not combed in combed_list: util.print_array(bc) util.print_array(B) util.print_array(D) print('before') util.print_array(before) print('fail') util.print_array(combed) fail_count += 1 elif not combed_str in bc_mapping: bc_mapping[combed_str] = [ before, ] else: bc_mapping[combed_str].append(before) print('error double map:', combed_str, 'is mapped to by', bc_mapping[combed_str]) print('\tcount=', count) double_count += 1 # #print('-------') # else: # print('pass') # util.print_array(combed) # print('BINARY COMBED LIST') # for x in combed_list: # print(x) before_file_name = '/Users/abeverid/PycharmProjects/asm/data/bigog/bigog' + str( size) + '.tex' after_file_name = '/Users/abeverid/PycharmProjects/asm/data/bigog/bigog' + str( size) + '-after.tex' util.omega_list_to_tex_file(bigog_omega_list, before_file_name) util.omega_list_to_tex_file(bigog_omega_after_list, after_file_name) print(len(combed_list)) print('fail count', fail_count) print('doubles', double_count)
def jeu_test(): #debug_on = True size = 3 gog_list = get_gog(size) magog_list = get_magog(size) #gog = [[0,0,0],[0,1],[0]] error_list = [] magog_map = dict() for gog in gog_list: jeu = jeu_de_taquin(gog) #print(gog) #print(jeu) if jeu not in magog_list: error_list.append([gog, jeu]) # print('\t NOT MAGOG!!!') else: if str(jeu) in magog_map: magog_map[str(jeu)].append(gog) print('multimap:', magog_map[str(jeu)]) else: magog_map[str(jeu)] = [jeu, gog] #print('----------') print('ERRORS!!!!!!') for error in error_list: util.print_array(error[0]) util.print_array(error[1]) print('----------') print('num error', len(error_list)) print(len(magog_map)) #logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.DEBUG) #logging.basicConfig(level=logging.DEBUG) #t = [[0,0,0,4],[0,1,1],[0,1],[1]] #t = [[0, 0, 0, 1], [0, 1, 1], [0, 2], [1]] #t = [[0, 0, 0, 4], [0, 1, 1], [0, 1], [1]] # t = [[0, 0, 0, 1],[0, 1, 1],[1, 1],[1]] # t = [[0, 0, 1, 3], [0, 0, 1], [1, 0], [0]] t = [[0, 0, 2], [1, 1], [1]] util.print_array(t) s = jeu_update(t, 1, 0) #s = jeu_de_taquin(t) util.print_array(s) if s in magog_list: print('success') else: print('failed!!!!')
for idx, val in enumerate(layer): if val > -1: if idx < len(layer) - 1 and any( x >= val for x in layer[idx + 1:len(layer)]): # can't take it yet layer[idx] = -1 else: # take it away from the triangle. print(triangle, idx, val) triangle[idx][val] = 0 new_triangle = [[x for x in row[0:len(row) - 1]] for row in triangle[0:len(triangle) - 1]] layers = get_catalan_layers_impl(new_triangle) layers.insert(0, layer) return layers if __name__ == '__main__': size = 2 layered_list = get_binary_layers(size) for x in layered_list: util.print_array(x) print(len(layered_list))
def build_trees(size): sst_list = build_stack_set.build_stacks(size) sst_list = stack_set_stats.one_one_per_col(sst_list, size) tree_list = [] for sst in sst_list: index_list = [] for row in sst: index_list.append([i for i, x in enumerate(row) if x == 1]) #### match to the rightmost available #m = len(index_list[-1]) #path_list = [] # for idx in range(1,m+1): # path = [index_list[-1][-idx]+1] # for row_idx in range(2,size+1): # print(index_list[-row_idx], 'has size', len(index_list[-row_idx])) # if len(index_list[-row_idx]) >= idx: # path.append(index_list[-row_idx][-idx]+1) # # path_list.append(path) #### match to the "first available" #### this actually seems to do worse. ugh! path_list = [[ x, ] for x in index_list[-1]] print('processing ', sst) for k in reversed(range(size - 1)): taken_idx_list = [] row_idx_list = index_list[k] for val in reversed(row_idx_list): for i, path in enumerate(path_list): if not i in taken_idx_list and val < path[-1]: print('\tmatching', val, 'to', path[-1]) taken_idx_list.append(i) path.append(val) break path_list = [[x + 1 for x in path] for path in path_list] print('\t\t', path_list) tree_list.append(path_list) print('THE INVOLUTIONS') sst_inv_list = [] for sst, tree in zip(sst_list, tree_list): #print(tree) inv = tree_to_involution(tree) #print(inv) temp = [0] * size for x in inv: if len(x) == 1: val = x[0] temp[val - 1] = val else: v1 = x[0] v2 = x[1] temp[v1 - 1] = v2 temp[v2 - 1] = v1 print(temp) if str(temp) == '[3, 4, 1, 2, 5]': print('duplicate', inv, 'tree', tree) util.print_array(sst) sst_inv_list.append(temp) #util.print_array(sst) print(len(sst_inv_list)) inv_list = get_involutions(size) for x in inv_list: if not x in sst_inv_list: print('missing', x) print(len(inv_list))
if count[size-1] > 0: new_list.append([size,] + prev) col_map[size] = new_list return col_map[size] def to_sst(columns): size = len(columns) triangle = util.get_all_zero_triangle(size) for idx,x in enumerate(reversed(columns)): if x > 0: triangle[idx][x-1] = 1 return triangle for size in range(4,5): col_list = get_columns(size) for c in col_list: print('column is', c) util.print_array(to_sst(c)) print('count', len(col_list))
#t = krat(s) #print(s) #print(t) #test_krat(2) size = 3 k_list = [uplift(k) for k in get_kagog(size)] g_list = [uplift(g) for g in get_gog(size)] print('=======kagog only') for k in k_list: if k not in g_list: util.print_array(k) print('=======gog only') for g in g_list: if g not in k_list: util.print_array(g) print('KAGOG TIME') klist = get_kagog(3) for k in klist: #util.print_array(k) krev = [row for row in reversed(k)] print(util.to_tex_ytableau(krev)) print('BIGOG TIME')