Esempio n. 1
0
def main():
    print('Welcome to the Mobile Robots course.\n')

    helper.check_solution(for_loop, [125, 216, 343, 512, 729, 1000])

    helper.check_solution(format_string, '1.23', 1.2345)
    helper.check_solution(format_string, '3.14', math.pi)

    helper.check_solution(filter_list, [1, 3], range(5), lambda v: v % 2 == 1)
    helper.check_solution(filter_list, [], range(5), lambda v: False)

    helper.check_solution(find_root, 0.5, lambda x: x * 2 - 1., approx=True)
    helper.check_solution(find_root, 0.7071, lambda x: x**2 - .5, approx=True)

    helper.check_solution(finished_tictactoe, True, ['XO ', ' X ', 'O X'])
    helper.check_solution(finished_tictactoe, True, [' O ', 'XXX', 'O  '])
    helper.check_solution(finished_tictactoe, True, ['XO ', 'X  ', 'X O'])
    helper.check_solution(finished_tictactoe, False, ['XO ', ' OX', 'O X'])
    helper.check_solution(finished_tictactoe, True, ['XOO', 'XOX', 'OXX'])
Esempio n. 2
0
def main():
    helper.check_solution(null_vector, [0] * 10)
    helper.check_solution(chess,
                          [[1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1],
                           [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1],
                           [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1],
                           [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]])
    helper.check_solution(
        polar, [[0.70710678118, np.pi / 4.], [0.70710678118 * 2, np.pi / 4.]],
        np.array([[.5, .5], [1., 1.]], np.float32),
        approx=True)
    helper.check_solution(cap, [1, 2, 2], np.array([1, 2, 3]), 2)
    helper.check_solution(cap, [2, 1, 2], np.array([3., 1., 3.]), 2)
    helper.check_solution(moving_average, [2, 3], np.array([1., 2., 3., 4.]))
    helper.check_solution(moving_average, [2], np.array([2., 2., 2.]))