PY
py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# https://www.sololearn.com/Discuss/1041633/%EF%B8%8Fchallenge-%EF%B8%8F-typoglycemia
'''
☢️CHALLENGE☢️: Typoglycemia proposed by Murillo Pyaia
Typoglycemia is the mind's ability to decipher a mispelled word if the first and last letters of the word are correct.
Make a program that receives user input and outputs the typoglycemic version of the string.
Example:
Input: "I love SoloLearn"
Output: "I lvoe SLloorean"
Good luck and good coding!'''
from re import findall
from random import shuffle
text = "If you are coming from Java world, you might already have heard about the method overloading in Java. " \
"Kotlin, with the help of default parameters and named arguments helps us to reduce the number " \
"of overloads that we generally need in Java world."
pattern = r'(\w+)(\W+)'
matches = findall(pattern,text)
words = []
for m in matches:
words.append(m[0])
words.append(m[1])
glyc = [] ; s = ''
for i in range(len(words)):
if len(words[i])<4 or (len(words[i])==4 and words[i][1]==words[i][2]):
glyc.append(words[i])
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run