python_data_scien/poc1/min_porj_4(Yahtzee).py
def gen_all_holds(hand):
    """
    Generate all possible choices of dice from hand to hold.

    hand: full yahtzee hand

    Returns a set of tuples, where each tuple is dice to hold
    """
    sorted_hand_list = sorted(list(hand))
    sorted_hand_len = len(sorted_hand_list)
    answer_set = set([])
    for i_idx in range(sorted_hand_len+1):
        if i_idx == 0:
            answer_set.add(tuple())
        elif i_idx == sorted_hand_len:
            answer_set.add(tuple(sorted_hand_list))
        else:
            temp_set = set()
            partial_answer_set = set([a for a in answer_set if len(a) == i_idx-1])
            for j_tuple in partial_answer_set:
                diff_list = get_diff_list(sorted_hand_list,j_tuple)
                for k_mem in diff_list:
                    j_list = list(j_tuple)
                    j_list.append(k_mem)
                    temp_set.add(tuple(j_list))
            answer_set.update(temp_set)
            #print '2:',answer_set
    sorted_answer_set = set([])
    for x_tuple in answer_set:
        sorted_x_tuple = tuple(sorted(list(x_tuple)))
        sorted_answer_set.add(sorted_x_tuple)
    return sorted_answer_set

    Generate all possible choices of dice from hand to hold.

    hand: full yahtzee hand

    Returns a set of tuples, where each tuple is dice to hold
    
Generate all possible choices of dice from hand to hold.
hand: full yahtzee hand

Returns a set of tuples, where each tuple is dice to hold
Generate all possible choices of dice from hand to hold . hand : full yahtzee hand Returns a set of tuples where each tuple is dice to hold
def gen_all_holds(hand):
    sorted_hand_list = sorted(list(hand))
    sorted_hand_len = len(sorted_hand_list)
    answer_set = set([])
    for i_idx in range(sorted_hand_len+1):
        if i_idx == 0:
            answer_set.add(tuple())
        elif i_idx == sorted_hand_len:
            answer_set.add(tuple(sorted_hand_list))
        else:
            temp_set = set()
            partial_answer_set = set([a for a in answer_set if len(a) == i_idx-1])
            for j_tuple in partial_answer_set:
                diff_list = get_diff_list(sorted_hand_list,j_tuple)
                for k_mem in diff_list:
                    j_list = list(j_tuple)
                    j_list.append(k_mem)
                    temp_set.add(tuple(j_list))
            answer_set.update(temp_set)
    sorted_answer_set = set([])
    for x_tuple in answer_set:
        sorted_x_tuple = tuple(sorted(list(x_tuple)))
        sorted_answer_set.add(sorted_x_tuple)
    return sorted_answer_set
def gen_all_holds ( hand ) : sorted_hand_list = sorted ( list ( hand ) ) sorted_hand_len = len ( sorted_hand_list ) answer_set = set ( [ ] ) for i_idx in range ( sorted_hand_len + 1 ) : if i_idx == 0 : answer_set . add ( tuple ( ) ) elif i_idx == sorted_hand_len : answer_set . add ( tuple ( sorted_hand_list ) ) else : temp_set = set ( ) partial_answer_set = set ( [ a for a in answer_set if len ( a ) == i_idx - 1 ] ) for j_tuple in partial_answer_set : diff_list = get_diff_list ( sorted_hand_list , j_tuple ) for k_mem in diff_list : j_list = list ( j_tuple ) j_list . append ( k_mem ) temp_set . add ( tuple ( j_list ) ) answer_set . update ( temp_set ) sorted_answer_set = set ( [ ] ) for x_tuple in answer_set : sorted_x_tuple = tuple ( sorted ( list ( x_tuple ) ) ) sorted_answer_set . add ( sorted_x_tuple ) return sorted_answer_set
Generate all possible choices of dice from hand to hold.
Generate all possible choices of dice from hand to hold .
"""
    Generate all possible choices of dice from hand to hold.

    hand: full yahtzee hand

    Returns a set of tuples, where each tuple is dice to hold
    """ #print '2:',answer_set

hand