Beispiel #1
0
def zad_1():
    p1 = {
        1: 2,
        2: 4,
        3: 6,
        4: 8,
        5: 10,
        6: 1,
        7: 3,
        8: 5,
        9: 7,
        10: 9,
    }
    p2 = {
        1: 1,
        2: 3,
        3: 5,
        4: 6,
        5: 9,
        6: 10,
        7: 8,
        8: 7,
        9: 4,
        10: 2,
    }

    p1p2 = Pi.multiply(p1, p2)
    print(p1p2)
    p2p1 = Pi.multiply(p2, p1)
    print(p2p1)
Beispiel #2
0
    def test_rank_naive_1(self):
        expected = 1

        permutation = {
            1: 1,
            2: 2,
            3: 3
        }

        result = Pi.rank_naive(permutation)
        self.assertEquals(expected, result)
Beispiel #3
0
    def test_rank_naive_3(self):
        expected = 3

        permutation = {
            1: 2,
            2: 3,
            3: 1
        }

        result = Pi.rank_naive(permutation)
        self.assertEquals(expected, result)
Beispiel #4
0
    def test_rank_naive_2(self):
        expected = 2

        permutation = {
            1: 2,
            2: 1,
            3: 4,
            4: 3
        }

        result = Pi.rank_naive(permutation)
        self.assertEquals(expected, result)
Beispiel #5
0
    def test_power_negative(self):
        expected = {
            1: 2,
            2: 3,
            3: 1,
        }

        permutation = {
            1: 2,
            2: 3,
            3: 1
        }

        result = Pi.power(permutation, -2)
        self.assertDictEqual(expected, result)
Beispiel #6
0
    def test_pi_reversed(self):
        expected = {
            2: 1,
            3: 2,
            1: 3,
        }

        permutation = {
            1: 2,
            2: 3,
            3: 1
        }

        result = Pi.pi_reversed(permutation)
        self.assertDictEqual(expected, result)
Beispiel #7
0
    def test_simple_multiply(self):
        expected = {
            1: 1,
            2: 2,
            3: 3,
            4: 4,
        }

        permutation = {
            1: 2,
            2: 1,
            3: 4,
            4: 3,
        }
        result = Pi.multiply(permutation, permutation)
        self.assertDictEqual(expected, result)
Beispiel #8
0
    def test_multiply_StatePoint(self):
        expected = {
            1: 1,
            2: 4,
            3: 2,
            4: 3,
        }

        permutation = {
            1: 1,
            2: 3,
            3: 4,
            4: 2,
        }
        result = Pi.multiply(permutation, permutation)
        self.assertDictEqual(expected, result)
Beispiel #9
0
    def test_power_positive(self):
        expected = {
            1: 1,
            2: 5,
            3: 6,
            4: 2,
            5: 3,
            6: 4
        }

        permutation = {
            1: 1,
            2: 3,
            3: 4,
            4: 5,
            5: 6,
            6: 2
        }

        result = Pi.power(permutation, 3)
        self.assertDictEqual(expected, result)
Beispiel #10
0
def zad_1():
    a1 = {
        1:2,
        2: 3,
        3: 1,
        4: 4,
        5: 5,
        6: 6,
        7: 7,
    }
    pi ={
        1: 3,
        2: 1,
        3: 2,
        4: 5,
        5: 4,
        6: 7,
        7: 6,
    }
    a2 = {
        1: 1,
        2: 2,
        3: 3,
        4: 5,
        5: 4,
        6: 6,
        7: 7,
    }

    ares = {
        1: 1,
        2: 2,
        3: 3,
        4: 4,
        5: 5,
        6: 7,
        7: 6,
    }

    result = Pi.multiply(Pi.multiply(a1, pi), a2)

    if result == ares:
        print("pi is correct")

    result1 = pi[1]
    result11 = Pi.rank_naive(pi)
    print("Pi")
    print(result1)
    print(result11)

    t2 = Pi.pi_reversed(pi)
    result2 = t2[1]
    result22 = Pi.rank_naive(t2)
    print("Pi^-1")
    print(result2)
    print(result22)

    t3 = Pi.power(pi, 2)
    result3 = t3[1]
    result33 = Pi.rank_naive(t3)
    print("Pi^2")
    print(result3)
    print(result33)