Exemple #1
0
def test_solution():
    import solution

    vector_a = solution.Vector3D(1, 2, 3)
    vector_b = solution.Vector3D(y=1, z=3)
    vector_c = solution.Vector3D()

    assert (vector_a * vector_b) == 11
    assert (vector_a * vector_c) == 0
Exemple #2
0
def test_solution():
    import solution

    vector_a = solution.Vector3D(2, 4, 6)
    vector_b = solution.Vector3D(y=3, z=2)

    assert (vector_a + vector_b).x == 2
    assert (vector_a + vector_b).y == 7
    assert (vector_a + vector_b).z == 8
Exemple #3
0
def test_solution():
    import solution

    vec1 = solution.Vector3D(1, 2, 3)
    vec2 = solution.Vector3D(y=1, z=3)
    vec3 = solution.Vector3D()

    assert (vec1 * vec2) == 11
    assert (vec1 * vec3) == 0
    assert (vec1 * vec1) == 14
Exemple #4
0
def test_solution():
    import solution
    from math import sqrt as sq

    vector_a = solution.Vector3D(1, 5, 3)
    vector_b = solution.Vector3D(4, 4, 1)
    vector_c = solution.Vector3D(1, 5, 2)

    assert vector_a.magnitude() == sq(35)
    assert vector_b.magnitude() == sq(33)
    assert vector_c.magnitude() == sq(30)
Exemple #5
0
def test_solution():
    import solution

    vector1 = solution.Vector3D(1, 2, 3)
    assert str(vector1) == '(x = 1, y = 2, z = 3)'

    vector2 = solution.Vector3D(y=1, z=2)
    assert str(vector2) == '(x = 0, y = 1, z = 2)'

    vector3 = solution.Vector3D()
    assert str(vector3) == '(x = 0, y = 0, z = 0)'
Exemple #6
0
def test_solution():
    import solution

    vector_a = solution.Vector3D(-9, -9, 5)
    vector_b = solution.Vector3D(11, 11, 3)
    vector_c = solution.Vector3D(11, 11, 3)

    assert vector_c == vector_c
    assert not (vector_a == vector_b)
    assert not (vector_a == vector_c)
    
Exemple #7
0
def test_solution():
    import solution

    vec1 = solution.Vector3D(-4, -4, 1)
    vec2 = solution.Vector3D(4, 4, 1)
    vec3 = solution.Vector3D(4, 4, 1)

    assert not (vec1 == vec2)
    assert not (vec1 == vec3)
    assert vec3 == vec3
    assert vec1 == vec1
Exemple #8
0
def test_solution():
    import solution

    vector_a = solution.Vector3D(4, 5, 6)
    assert str(vector_a) == '(x = 4, y = 5, z = 6)'

    vector_b = solution.Vector3D(y=0, z=1)
    assert str(vector_b) == '(x = 0, y = 0, z = 1)'

    vector_c = solution.Vector3D()
    assert str(vector_c) == '(x = 0, y = 0, z = 0)'
Exemple #9
0
def test_solution():
    import solution
    import math

    vec1 = solution.Vector3D(1, 5, 3)
    vec2 = solution.Vector3D(4, 4, 1)
    vec3 = solution.Vector3D(1, 5, 2)

    assert vec1.magnitude() == math.sqrt(35)
    assert vec2.magnitude() == math.sqrt(33)
    assert vec3.magnitude() == math.sqrt(30)
Exemple #10
0
def test_solution():
    import solution
    vec1 = solution.Vector3D(1, 5, 3)
    vec2 = solution.Vector3D(4, 4, 1)
    vec3 = solution.Vector3D(1, 5, 2)
    vec4 = solution.Vector3D(4, 4, 1)
    vect_lst = [vec1, vec2, vec3, vec4]
    sorted_lst = [vec3, vec2, vec4, vec1]
    ret_lst = solution.sort_vectors(vect_lst)

    for x, y in zip(ret_lst, sorted_lst):
        assert str(x) == str(y)
Exemple #11
0
def test_solution():
    import solution

    vec1 = solution.Vector3D(1, 2, 0)
    vec2 = solution.Vector3D(y=1, z=3)
    vec3 = solution.Vector3D()

    assert (vec1 - vec2).x == 1
    assert (vec1 - vec2).y == 1
    assert (vec1 - vec2).z == -3

    assert (vec1 - vec3).x == 1
    assert (vec1 - vec3).y == 2
    assert (vec1 - vec3).z == 0
Exemple #12
0
def test_solution():
    import solution

    vector_a = solution.Vector3D(1, 2, 0)
    vector_b = solution.Vector3D(y=1, z=3)
    vector_c = solution.Vector3D()

    assert (vector_a - vector_b).x == 1
    assert (vector_a - vector_b).y == 1
    assert (vector_a - vector_b).z == -3

    assert (vector_a - vector_c).x == 1
    assert (vector_a - vector_c).y == 2
    assert (vector_a - vector_c).z == 0
Exemple #13
0
def test_solution():
    import solution

    vector_a = solution.Vector3D(1, 5, 3)
    vector_b = solution.Vector3D(4, 4, 1)
    vector_c = solution.Vector3D(1, 5, 2)
    assert vector_c < vector_a
    assert vector_b < vector_a
    assert not (vector_a < vector_c)
    
    assert vector_a > vector_c
    assert not (vector_b > vector_a)
    assert not (vector_c > vector_a)
    
Exemple #14
0
def test_solution():
    import solution

    vec1 = solution.Vector3D(1, 5, 3)
    vec2 = solution.Vector3D(4, 4, 1)
    vec3 = solution.Vector3D(1, 5, 2)

    assert not (vec1 < vec2)
    assert not (vec1 < vec3)
    assert vec3 < vec1
    assert vec2 < vec1

    assert not (vec2 > vec1)
    assert not (vec3 > vec1)
    assert vec1 > vec3
    assert vec1 > vec2
Exemple #15
0
def test_solution():
    import solution

    vec1 = solution.Vector3D(1, 2, 3)
    vec2 = solution.Vector3D(y=1, z=3)
    vec3 = solution.Vector3D()
    rvec1 = vec1 * 3
    rvec2 = vec2 * 2
    lvec1 = 3 * vec1

    assert (vec1 * vec2) == 11
    assert (vec1 * vec3) == 0
    assert (vec1 * vec1) == 14
    assert rvec1.x == 3 and rvec1.y == 6 and rvec1.z == 9
    assert rvec2.x == 0 and rvec2.y == 2 and rvec2.z == 6
    assert lvec1.x == 3 and lvec1.y == 6 and lvec1.z == 9
Exemple #16
0
def test_solution():
    import solution

    vector_a = solution.Vector3D(6, 7, 8)
    assert vector_a.x == 6
    assert vector_a.y == 7
    assert vector_a.z == 8

    vector_b = solution.Vector3D(y=77, z=88)
    assert vector_b.x == 0
    assert vector_b.y == 77
    assert vector_b.z == 88

    vector_c = solution.Vector3D()
    assert vector_c.x == 0
    assert vector_c.y == 0
    assert vector_c.z == 0
Exemple #17
0
def test_solution():
    import solution

    vector1 = solution.Vector3D(1, 2, 3)
    assert vector1.x == 1
    assert vector1.y == 2
    assert vector1.z == 3

    vector2 = solution.Vector3D(y=1, z=2)
    assert vector2.x == 0
    assert vector2.y == 1
    assert vector2.z == 2

    vector3 = solution.Vector3D()
    assert vector3.x == 0
    assert vector3.y == 0
    assert vector3.z == 0