I'm trying to implement a permutation algorithm in Python.
It receives as input a phrase and a key (numeric value) that matches the amount of letters each group should have, numerical sequence from 1 to the value of the key.
Here is an example of data entry:
Input Phrase:
"Python is the best language !!"
Input key:
5
Input Sequence:
4 2 5 1 3
Expected output:
Hyopt
meena
rhllo
unaig
! gm
It follows my attempt, but without result, because I am not able to implement and do the division by groups to obtain the result illustrated in the example.
Code:
contador = 0
frase = input('Digite uma frase: ').upper
chave = int(input('Digite a chave: '))
seq = []
while contador <= chave:
seq.append(int(input('Digite o número da sequência: ')))
frase = frase.split()
frase = ''.join(frase)