fork download
  1. def _convert_to_altered_equivalent(ch):
  2. return '*'
  3.  
  4. def _is_vowel(ch):
  5. vowels = {'A', 'a', 'E', 'e', 'I', 'i', 'O', 'o', 'U', 'u'}
  6. return ch in vowels
  7.  
  8. def gibberizer(input_str):
  9. altered_str = list(input_str)
  10.  
  11. count_vowels = 0
  12.  
  13. for i in range(len(altered_str)):
  14. if _is_vowel(altered_str[i]):
  15. count_vowels += 1
  16.  
  17. if count_vowels < 3:
  18. return ''.join(altered_str)
  19.  
  20. count_vowels -= 3 # because first three vowels can never be altered
  21. for i in range(len(altered_str)-1, -1, -1):
  22. if count_vowels == 0:
  23. break
  24. elif _is_vowel(altered_str[i]):
  25. altered_str[i] = _convert_to_altered_equivalent(altered_str[i])
  26. count_vowels -= 1
  27.  
  28. return ''.join(altered_str)
  29. print(gibberizer("gghhjjkkkllaa"))
  30. print(gibberizer("alphabetical"))
  31. print(gibberizer("thisisaverylongexample"))
  32. print(gibberizer("gghhjjkkkllaaae"))
  33.  
Success #stdin #stdout 0.02s 7092KB
stdin
Standard input is empty
stdout
gghhjjkkkllaa
alphabet*c*l
thisisav*ryl*ng*x*mpl*
gghhjjkkkllaaa*