def point_calc(ins_someone_info): sum_main_point = sum_list(ins_someone_info.hand_card_point) sum_sub_point = sum_list(ins_someone_info.hand_card_sub_point) while ((sum_sub_point > sum_main_point) and (sum_sub_point > goal_point)): # 1の枚数を数えるほうがいいかな…? sum_sub_point = sum_sub_point - 10 if (sum_sub_point == sum_main_point or sum_sub_point > goal_point): return_tuple = ((sum_main_point), ) return return_tuple else: return sum_main_point, sum_sub_point
def test_when_both_lists_have_the_same_digits(self): n1d1 = s.Node(9) n1d2 = s.Node(2) n1d3 = s.Node(3) n2d1 = s.Node(2) n2d2 = s.Node(3) n2d3 = s.Node(4) n1 = s.LinkedList(n1d1) n1.insert(n1d2) n1.insert(n1d3) n2 = s.LinkedList(n2d1) n2.insert(n2d2) n2.insert(n2d3) output = s.sum_list(n1, n2) self.assertEqual(output.display(), "1 6 7")
def test_when_lists_have_diff_num_of_digits(self): n1d1 = s.Node(9) n1d2 = s.Node(5) n1d3 = s.Node(3) n1d4 = s.Node(2) n1d5 = s.Node(1) n2d1 = s.Node(7) n2d2 = s.Node(5) n1 = s.LinkedList(n1d1) n1.insert(n1d2) n1.insert(n1d3) n1.insert(n1d4) n1.insert(n1d5) n2 = s.LinkedList(n2d1) n2.insert(n2d2) output = s.sum_list(n1, n2) self.assertEqual(output.display(), "6 1 4 2 1")
def print_avg(arr): return sum_list.sum_list(arr) / len(arr)
def test_sum_list(test_list, expected): from sum_list import sum_list answer = sum_list(test_list) assert answer == expected
def test_when_one_or_more_args_have_incorrect_data_type(self): n1d1 = s.Node(1) n1 = s.LinkedList(n1d1) with self.assertRaises(TypeError): s.sum_list(n1, 1)
def test_sum_list_for_3(self): sumList = sum_list(3) self.assertEqual(sumList, 6)
def test_sum_list_for_7(self): sumList = sum_list(7) self.assertEqual(sumList, 28)
def test_sum_list_for_0(self): sumList = sum_list(0) self.assertEqual(sumList, 0)
def test_sum_list_for_20(self): sumList = sum_list(20) self.assertEqual(sumList, 210)
def test_when_numbers_are_negative(self): self.assertEqual(sum_list([-100, -20]), -120)
def test_when_numbers_are_positives(self): self.assertEqual(sum_list([100, 20]), 120)
def test_when_list_is_empty(self): self.assertEqual(sum_list([]), 0)