This Python script is designed to solve a problem of finding all occurrences of two or more vowels in a string, surrounded by consonants. The user inputs a string, and the script uses regular expressions to find the desired patterns.
CodeRankGPT is a tool powered by GPT-4 that quietly assists you during your coding interview, providing the solutions you need.
In real-time and absolutely undetectable 🥷
The solution works by using Python's built-in 're' module, which provides support for regular expressions. The 'findall' function is used with a regular expression pattern that matches two or more vowels (AEIOUaeiou) surrounded by consonants. The pattern uses lookbehind and lookahead assertions to ensure that the vowels are surrounded by consonants. If any matches are found, they are printed out. If no matches are found, -1 is printed.
import re
s = input()
result = re.findall(r"(?<=[QWRTYPSDFGHJKLZXCVBNMqwrtypsdfghjklzxcvbnm])([AEIOUaeiou]{2,})(?=[QWRTYPSDFGHJKLZXCVBNMqwrtypsdfghjklzxcvbnm])",s,)
if result:
for i in result:
print(i)
else:
print(-1)
If you have a HackerRank coding test coming up, you can use CodeRankGPT to your advantage. It will assist you during your interview and help ensure you get the job.
AI is here now, and other candidates might be using it to get ahead and win the job. 🧐
The form has been successfully submitted.