예제 #1
0
            expressions, '', logical_operators, relational_operators, None
        ]
    ],

    # ! ( x $relop0 y $logop0 $exp ) $logop1 y $relop1 x
    [
        'logical_relational_o2_p_',
        [
            '$x0', '$y0', not_operator, '(', relational_operators,
            logical_operators, expressions, ')', logical_operators,
            relational_operators, None
        ]
    ],
]

G = generate_util.Group_list(raw_group_list, 12)
G.cross_product('c%i_', cross_product_indexes)
G.substitute(None, substitute_indexes, substitute_values)
group_list = G.group_list

print '***** expected number of questions:', \
 len(substitute_values) * \
 len(relational_operators) * \
 len(logical_operators) * \
 len(expressions) * \
 len(logical_operators) * \
 len(relational_operators) * \
 3 # not operator: group[0]:1; group[1]:2
#       = 2 * 6 * 2 * 2 * 2 * 6 * 3 = 1728

global_code_template = '''\
예제 #2
0
    ['newton_method_4_h%i_', [4, '2.500', '2.050', '2.001']],
    ['newton_method_5_h%i_', [5, '3.000', '2.333', '2.238']],
    ['newton_method_6_h%i_', [6, '3.500', '2.607', '2.454']],
    ['newton_method_7_h%i_', [7, '4.000', '2.875', '2.655']],
    ['newton_method_8_h%i_', [8, '4.500', '3.139', '2.844']],
    ['newton_method_9_h%i_', [9, '5.000', '3.400', '3.024']],
    ['newton_method_10_h%i_', [10, '5.500', '3.659', '3.196']],
]
hotspot_counts = [1, 2, 3]
hotspot_indexes = [1, 2, 3]

# generate 3 groups, 1 for each hotspot count
raw_group_list0 = copy.deepcopy(raw_group_list)
for g in raw_group_list0:
    g[0] = g[0] % 1
G1 = generate_util.Group_list(raw_group_list0, 4)
G1.generalize(None, hotspot_indexes, 1)

raw_group_list0 = copy.deepcopy(raw_group_list)
for g in raw_group_list0:
    g[0] = g[0] % 2
G2 = generate_util.Group_list(raw_group_list0, 4)
G2.generalize(None, hotspot_indexes, 2)

raw_group_list0 = copy.deepcopy(raw_group_list)
for g in raw_group_list0:
    g[0] = g[0] % 3
G3 = generate_util.Group_list(raw_group_list0, 4)
G3.generalize(None, hotspot_indexes, 3)

# concatenate for solution
예제 #3
0
d_3 = ['100','101','110','111']
m_3 = ['000','001','010','011', '100','101','110','111']

d_m_qh_rh_wh_list = [
	[ d_2, m_2, 1, 1, 2 ], # 240
	[ d_2, m_3, 1, 1, 2 ], # 2160
	[ d_3, m_3, 1, 1, 1 ], # 2860
	[ ['10100'], ['100000'], 1, 1, 1 ], # 1320
]

# generate groups
G0 = [ ]
for x in d_m_qh_rh_wh_list:
	G0.append(raw_group(x[0],x[1],x[2],x[3],x[4]))
G1 = generate_util.Group_list(G0,7)
G1.cross_product(None,[0,1,4,5,6])
group_list = G1.group_list
'''
for g in group_list:
	print g[0]
	for h in g[1:]:
		print '\t',h
'''

# compute counts
n = 0
print '***** expected number of questions:',
for x in d_m_qh_rh_wh_list:
	n += raw_group_num_questions(x[0],x[1],x[2],x[3],x[4])
print n
예제 #4
0
# counting -------------------------------------------------------
cut = 'n_c_k'
actual = generate_util.n_c_k(3, 2)
expected = 3
message = '''Error in %s:
\tactual: %s
\texpect: %s
if actual != expected:
	print message % (cut,str(actual),str(expected))
'''

# Group_list -------------------------------------------------------

# ********** cross_product
G = generate_util.Group_list([['g', [[0, 1], 'x', [2, 3]]]], 3)
G.cross_product(None, [0, 2])
actual = G.group_list
expected = [
    ['g', [0, 'x', 2], [0, 'x', 3], [1, 'x', 2], [1, 'x', 3]],
]
message = '''Error in %s:
\tactual: %s
\texpected: %s
'''
if actual != expected:
    print message % (cut, str(actual), str(expected))

cut = 'cross_product'
G = generate_util.Group_list([['g', [[0, 1], 'x', [2, 3]]]], 3)
G.cross_product('_%i', [0, 2])