Neste desafio, transforme uma string em uma série de palavras (ou sequências de caracteres) separadas por um único espaço, com cada palavra tendo o mesmo comprimento indicado pelos primeiros 15 dígitos da representação decimal de Pi:
3.14159265358979Se uma string contiver mais caracteres do que a quantidade total dada pela soma dos dígitos de Pi, os caracteres não utilizados serão descartados e você usará apenas os necessários para formar 15 palavras.
String = "HOWINEEDADRINKALCOHOLICINNATUREAFTERTHEHEAVYLECTURESINVOLVINGQUANTUMMECHANICSANDALLTHESECRETSOFTHEUNIVERSE"
Pi String = "HOW I NEED A DRINK ALCOHOLIC IN NATURE AFTER THE HEAVY LECTURES INVOLVING QUANTUM MECHANICS"
# Every word has the same length of the digit of Pi found at the same index ?
# "HOW" = 3, "I" = 1, "NEED" = 4, "A" = 1, "DRINK" = 5
# "ALCOHOLIC" = 9, "IN" = 2, "NATURE" = 6, "AFTER" = 5
# "THE" = 3, "HEAVY" = 5, "LECTURES" = 8, "INVOLVING" = 9
# "QUANTUM" = 7, "MECHANICS" = 9
# 3.14159265358979Além disso, se uma string contiver menos caracteres do que a quantidade total dada pela soma dos dígitos de Pi, você deverá, de qualquer forma, respeitar a sequência dos dígitos para obter as palavras.
String = "FORALOOP"
Pi String = "FOR A LOOP"
# Every word has the same length of the digit of Pi found at the same index ?
# "FOR" = 3, "A" = 1, "LOOP" = 4
# 3.14Se as letras contidas na string não corresponderem exatamente aos dígitos, você repetirá a última letra até que a palavra tenha o comprimento correto.
String = "CANIMAKEAGUESSNOW"
Pi String = "CAN I MAKE A GUESS NOWWWWWWW"
# Every word has the same length of the digit of Pi found at the same index ?
# "CAN" = 3, "I" = 1, "MAKE" = 4, "A" = 1, "GUESS" = 5, "NOW" = 3
# 3.14153 (Wrong!)
# The length of the sixth word "NOW" (3)...
# ...doesn't match the sixth digit of Pi (9)
# The last letter "W" will be repeated...
# ...until the length of the word will match the digit
# "CAN" = 3, "I" = 1, "MAKE" = 4, "A" = 1, "GUESS" = 5, "NOWWWWWWW" = 9
# 3.14159 (Correct!)Se a string fornecida estiver vazia, uma string vazia deverá ser retornada.
Dada uma string txt, implemente uma função que retorne a mesma string formatada de acordo com as instruções acima.
pilish_string("33314444") ➞ "333 1 4444"
# 3.14
pilish_string("TOP") ➞ "TOP"
# 3
pilish_string("X")➞ "XXX"
# "X" has to match the same length of the first digit (3)
# The last letter of the word is repeated
pilish_string("")➞ ""