Home > other >  Shift letters in object array in a certain order
Shift letters in object array in a certain order

Time:05-22

I'm trying to create unique gematria (alphanumerical cipher) how do I achieve this?

The form is as follows:

ABCDEFGHIJKLMNOPQRSTUVWXYZ


alphabet1 = {
    "A": 1,
    "B": 2,
    "C": 3,
    "D": 4,
    "E": 5,
    "F": 6,
    "G": 7,
    "H": 8,
    "I": 9,
    "J": 10,
    "K": 11,
    "L": 12,
    "M": 13,
    "N": 14,
    "O": 15,
    "P": 16,
    "Q": 17,
    "R": 18,
    "S": 19,
    "T": 20,
    "U": 21,
    "V": 22,
    "W": 23,
    "X": 24,
    "Y": 25,
    "Z": 26
}
x=' ';
for i in range(1   1):
    for product in itertools.product(alphabet.keys(), repeat=i):
        value = 0
        comb = ""
        for char in product:
            
            print([char],":",(x*1),alphabet[char],",",sep='')

im search shift all leters

KEY OF THREE (A,D,G) (A=1,D=2,G=3,J=4,M=5,P=6,S=7,V=8,Y=9,B=10,E=11,H=12,K=13,N=14, Q=15,T=16,W=17,Z=18,C=19,F=20,I=21,K=22,N=23,Q=24,T=25,W=26)

KEY OF FIVE (A,F,K) (A=1,F=2,K=3,P=4,U=5,Z=6,E=7,J=8,O=9,T=10,Y=11,D=12,I=13,N=14, S=15,X=16,C=17,H=18,M=19,R=20,W=21,B=22,G=23,L=24,Q=25,V=26)

KEY OF SEVEN (A,H,O) (A=1,H=2,O=3,V=4,C=5,J=6,Q=7,X=8,E=9,L=10,S=11,Z=12,G=13,N=14, U=15,B=16,I=17,P=18,W=19,D=20,K=21,R=22,Y=23,F=24,M=25,T=26)

KEY OF ELEVEN (A,J,S)(A=1,J=2,S=3,B=4,K=5,T=6,C=7,L=8,U=9,D=10,M=11,V=12,E=13,N=14, W=15,F=16,O=17,X=18,G=19,P=20,Y=21,H=22,Q=23,Z=24,I=25,R=26)

KEY OF ELEVEN (A,L,W) (A=1,L=2,W=3,H=4,S=5,D=6,O=7,Z=8,K=9,V=10,G=11,R=12,C=13,N=14, Y=15,J=16,U=17,F=18,Q=19,B=20,M=21,X=22,I=23,T=24,E=25,P=26)

It is beyond my power someone would help me and edit the code than thank you so much I have been trying to do this for a few days but nothing works.

Those shifts will be more I basically want to start with the letter A / F / K and create attachments from the lower examples.

Those Gematria will be a lot, so need a script.

I'm search if input and shift 3 ABCDEFGHIJKLMNOPQRSTUVWXYZ

output is

alphabet1 = {
    "A": 1,
    "D": 2,
    "G": 3,
    "J": 4,
    "M": 5,
    "P": 6,
    "S": 7,
    "V": 8,
    "Y": 9,
    "B": 10,
    "E": 11,
    "H": 12,
    "K": 13,
    "N": 14,
    "Q": 15,
    "T": 16,
    "W": 17,
    "Z": 18,
    "C": 19,
    "F": 20,
    "I": 21,
    "K": 22,
    "N": 23,
    "Q": 24,
    "T": 25,
    "W": 26
}

CodePudding user response:

I think you are looking for something like this:

from string import ascii_uppercase

def gematria(n, alphabet):
    length = len(alphabet)
    ret = {}
    for i in range(length):
        j = i * n % length
        letter = alphabet[j]
        while letter in ret:
            j = (j   1) % length
            letter = alphabet[j]
        ret[letter] = i   1
    return ret

print(gematria(5, ascii_uppercase))
print(gematria(7, ascii_uppercase))
print(gematria(9, ascii_uppercase))
print(gematria(13, ascii_uppercase))

This gives the following output:

{'A': 1, 'F': 2, 'K': 3, 'P': 4, 'U': 5, 'Z': 6, 'E': 7, 'J': 8, 'O': 9, 'T': 10, 'Y': 11, 'D': 12, 'I': 13, 'N': 14, 'S': 15, 'X': 16, 'C': 17, 'H': 18, 'M': 19, 'R': 20, 'W': 21, 'B': 22, 'G': 23, 'L': 24, 'Q': 25, 'V': 26}
{'A': 1, 'H': 2, 'O': 3, 'V': 4, 'C': 5, 'J': 6, 'Q': 7, 'X': 8, 'E': 9, 'L': 10, 'S': 11, 'Z': 12, 'G': 13, 'N': 14, 'U': 15, 'B': 16, 'I': 17, 'P': 18, 'W': 19, 'D': 20, 'K': 21, 'R': 22, 'Y': 23, 'F': 24, 'M': 25, 'T': 26}
{'A': 1, 'J': 2, 'S': 3, 'B': 4, 'K': 5, 'T': 6, 'C': 7, 'L': 8, 'U': 9, 'D': 10, 'M': 11, 'V': 12, 'E': 13, 'N': 14, 'W': 15, 'F': 16, 'O': 17, 'X': 18, 'G': 19, 'P': 20, 'Y': 21, 'H': 22, 'Q': 23, 'Z': 24, 'I': 25, 'R': 26}
{'A': 1, 'N': 2, 'B': 3, 'O': 4, 'C': 5, 'P': 6, 'D': 7, 'Q': 8, 'E': 9, 'R': 10, 'F': 11, 'S': 12, 'G': 13, 'T': 14, 'H': 15, 'U': 16, 'I': 17, 'V': 18, 'J': 19, 'W': 20, 'K': 21, 'X': 22, 'L': 23, 'Y': 24, 'M': 25, 'Z': 26}

If a letter is already present in the output dictionary, the algorithm will skip to the next letter in the alphabet. This means it will work for values of n which the length of the alphabet is divisible by (e.g. when n is 13 the algorithm will produce results for all letters in the alphabet, not just "A" and "N").

  • Related