def raw_group(divisors,messages,qh,rh,wh): ''' purpose return a group with: name: 'crc_d%i_m%i_' with divisor, message lengths divisors: a list of divisors of the same length messages: a list of messages of the same length forward only: no divisor or dividend hotspots quotient hotspots: list of all qh-tuples of hotspots remainder hotspots: list of all rh-tuples of hotspots work hotspots: list of all rh-tuples of hotspots preconditions divisors: non-empty list of bitstrings of length > 1 all divisors are the same length messages: non-empty list of bitstrings of length >= d all messages are the same length qh, rh, wh: legal hotspot counts ''' # extract divisor, message lengths d_len = len(divisors[0]) m_len = len(messages[0]) # compute quotient, remainder, work lengths q_len = crc_util.quotient_len(d_len,m_len) r_len = crc_util.remainder_len(d_len,m_len) num_rows = crc_util.number_of_rows(d_len,m_len) row_width = crc_util.row_width(d_len,m_len) # compute quotient, remainder, work index lists; index pairs for work q_indexes = range(0,q_len) r_indexes = range(0,r_len) w_indexes = generate_util.cross_product \ ([range(num_rows),range(row_width)]) # create the group, ready for cross product return [ 'crc_d%i_m%i_' % (d_len,m_len), [ divisors, messages, [ ], [ ], generate_util.choose_k(q_indexes,qh), generate_util.choose_k(r_indexes,rh), generate_util.choose_k(w_indexes,wh), ]]
def raw_group_num_questions(divisors,messages,qh,rh,wh): ''' purpose, preconditions, comments same as for group_count except that the number of questions generated by the return value of raw_group is returned ''' d_len = len(divisors[0]) m_len = len(messages[0]) q_len = crc_util.quotient_len(d_len,m_len) r_len = crc_util.remainder_len(d_len,m_len) num_rows = crc_util.number_of_rows(d_len,m_len) row_width = crc_util.row_width(d_len,m_len) q_indexes = range(0,q_len) r_indexes = range(0,r_len) w_indexes = generate_util.cross_product \ ([range(num_rows),range(row_width)]) return len(divisors) * len(messages) * \ generate_util.n_c_k(q_len,qh) * \ generate_util.n_c_k(r_len,rh) * \ generate_util.n_c_k(num_rows*row_width,wh)