En este desafío, transforma una cadena en una serie de palabras (o secuencias de caracteres) separadas por un solo espacio, donde cada palabra tenga la misma longitud indicada por los primeros 15 dígitos de la representación decimal de Pi:
3.14159265358979Si una cadena contiene más caracteres que la cantidad total dada por la suma de los dígitos de Pi, los caracteres no utilizados se descartan y usarás solo los necesarios para formar 15 palabras.
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.14159265358979Además, si una cadena contiene menos caracteres que la cantidad total dada por la suma de los dígitos de Pi, en cualquier caso debes respetar la secuencia de los dígitos para obtener las palabras.
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.14Si las letras contenidas en la cadena no coinciden exactamente con los dígitos, repetirás la última letra hasta que la palabra tenga la longitud correcta.
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!)Si la cadena dada está vacía, se debe devolver una cadena vacía.
Dada una cadena txt, implementa una función que devuelva la misma cadena formateada de acuerdo con las instrucciones anteriores.
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("")➞ ""