예제 #1
0
    def anagram_2d_array(self):
        """
            This method is used to store prime anagram and prime number which are not anagram in matrix or 2d array.
            and print them accordingly
        """
        prime_list = Utility.get_prime()  # get prime numbers

        anagram_list = Utility.get_anagram_prime(
        )  # get anagram numbers which is prime also

        not_anagram = []
        row = 10
        column = 25

        two_d_array = [[0 for j in range(column)] for i in range(row)]

        k = 0

        index = 0

        for i in prime_list:

            if anagram_list.__contains__(
                    i) is not True:  # if file not contains same element

                not_anagram.append(i)  # append into not_anagram list

        for i in range(row):

            for j in range(column):

                if k < len(anagram_list):

                    two_d_array[i][j] = anagram_list[
                        k]  # add element of anagram list into array

                    k += 1

                if k >= len(anagram_list) and index < len(not_anagram):

                    two_d_array[i][j] = not_anagram[
                        index]  # add element of not_anagram list

                    k += 1  # into same array after anagram_list

                    index += 1

        for i in range(row):

            for j in range(column):

                if two_d_array[i][j] != 0:

                    print(two_d_array[i][j], end=" ")  # print 2d array

            print()
예제 #2
0
    def anagram_stack(self):
        """
            This method is used to print prime anagram in reverse order.
        """
        for i in Utility.get_anagram_prime(
        ):  # get anagram numbers which are prime

            stack.push(i)  # push numbers into stack

        for i in range(0, stack.size()):

            print(stack.pop())  # print in reverse order
예제 #3
0
    def anagram_queue(self):
        """
            This method is used to print prime anagram using queue.
        """

        for i in Utility.get_anagram_prime(
        ):  # get anagram numbers which are prime

            queue1.enqueue(i)  # add numbers into queue

        for i in range(0, queue1.size()):

            print(queue1.dequeue())  # print in reverse order