예제 #1
0
    def test2(self):
        head = Node()
        head.buff = [1, 2, 3]
        head.count = 3

        n1 = Node()
        n1.buff = [4]
        n1.count = 1

        n2 = Node()
        n2.buff = [5, 6]
        n2.count = 2

        head.next = n1
        n1.next = n2

        sol = Solution()
        res = sol.get_idx_at(head, 0)
        exp = 1
        self.assertEqual(res, exp)

        res = sol.get_idx_at(head, 1)
        exp = 2
        self.assertEqual(res, exp)

        res = sol.get_idx_at(head, 4)
        exp = 5
        self.assertEqual(res, exp)

        res = sol.get_idx_at(head, 5)
        exp = 6
        self.assertEqual(res, exp)
예제 #2
0
    def test1(self):
        head = Node()
        head.buff = [1, 2, 3]
        head.count = 3

        n1 = Node()
        n1.buff = [4, 5, 6]
        n1.count = 3

        head.next = n1

        sol = Solution()
        res = sol.get_idx_at(head, 0)
        exp = 1
        self.assertEqual(res, exp)

        res = sol.get_idx_at(head, 1)
        exp = 2
        self.assertEqual(res, exp)

        res = sol.get_idx_at(head, 4)
        exp = 5
        self.assertEqual(res, exp)