NaPoWriMo x NaPoGenMo 2024 Day 26 : Transposition with Poems

NaPoWriMo x NaPoGenMo 2024 Day 26 : Transposition with Poems

Mathematically Engaged Poems

CipheringPoems

For the 26th day of NaPoWriMo/NaPoGenMo 2024, the poem is being generated through Transposition ciphers coded in Python.

"A Transposition cipher is one in which the order of characters is changed to obscure the message."https://math.libretexts.org/Bookshelves/Applied_Mathematics/Math_in_Society_(Lippman)/16%3A_Cryptography/16.03%3A_Transposition_Ciphers

Inputs

Input

Input 1:
[['H' 'O' 'E']
 ['T' 'W' 'N']
 ['S' 'D' 'D']
 ['E' 'S' 'Y']
 ['E' 'R' 'E']]

Input 2:
[['O' 'R' 'E']
 ['B' 'A' 'R']
 ['E' 'N' 'D']
 ['S' 'T' 'Y']
 ['X' 'E' 'A']]

Transposed Output

Transposed 1:
[['H' 'T' 'S' 'E' 'E']
 ['O' 'W' 'D' 'S' 'R']
 ['E' 'N' 'D' 'Y' 'E']]

Transposed 2:
[['O' 'B' 'E' 'S' 'X']
 ['R' 'A' 'N' 'T' 'E']
 ['E' 'R' 'D' 'Y' 'A']]

Output

Real Phrase:
['T' 'H' 'E' 'S' 'E']
['W' 'O' 'R' 'D' 'S']
['N' 'E' 'E' 'D' 'Y']

Real Phrase 2:
['B' 'O' 'X' 'E' 'S']
['A' 'R' 'E' 'N' 'T']
['R' 'E' 'A' 'D' 'Y']

Python Code

import numpy as np



def transformation(arr1):
    print(f'Original Array:\n{arr1}')

    arr1_transpose = arr1.transpose()


    print(f'Transposed Array:\n{arr1_transpose}')

    #Similar to the Row Operations, we can use this to rescramble the text to make the phrase "Boxes Arent Ready" & "These Words Needy"



    #represent the scrambled phrases

    cipher0 = arr1_transpose[0]
    cipher1 = arr1_transpose[1]
    cipher2 = arr1_transpose[2]

    #unscrambles the words contained in the array

    [cipher0[0],cipher0[1],cipher0[2],cipher0[3],cipher0[4]] = [cipher0[1],cipher0[0],cipher0[4],cipher0[2],cipher0[3]]
    [cipher1[0],cipher1[1],cipher1[2],cipher1[3],cipher1[4]] = [cipher1[1],cipher1[0],cipher1[4],cipher1[2],cipher1[3]]
    [cipher2[0],cipher2[1],cipher2[2],cipher2[3],cipher2[4]] = [cipher2[1],cipher2[0],cipher2[4],cipher2[2],cipher2[3]]

    print(f'Real Phrase:')
    print(cipher0)
    print(cipher1)
    print(cipher2)



#Making Micro Poems through Matrix Transposition Ciphers

transformation(np.array([["H", "O", "E"],["T", "W", "N"],['S',"D","D"],["E","S","Y"],["E","R","E"]]))
transformation(np.array([["O", "R", "E"],["B", "A", "R"],['E',"N","D"],["S","T","Y"],["X","E","A"]]))