repl.it
@Quelklef/

https://codegolf.stackexchange.com/questions/94534/progruzzl

Python 2.7

No description

fork
loading
Files
  • main.py
main.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
29
30
31
32
33
34
35
36
37
38
39
40
v="aeiou"
n=lambda a,b:a[:a.index(([l for l in[[l,"!"][i!=0and a[i-1]in v]for i,l in enumerate(a)]if l in v]*2)[-2])]+b[sorted([(b+v).index(c)for c in v])[0]:]

"""
vowels="aeiou"
def to_vowel(string):
	return string[sorted([(string+vowels).index(vowel) for vowel in vowels])[0]:]
	
print to_vowel("angel")
print to_vowel("bush")
print to_vowel("bill")

def n_min_1_vowel_group(string):
	s=[]
	for i,letter in enumerate(string):  # replace vowels with vowel followed by "!" in order to effectively reduce vowel groups to one vowel
		s.append([letter,'!'][i!=0 and string[i-1] in vowels])
	vo=[letter for letter in s if letter in vowels] # vowels only
	if len(vo)==1: # one vowel group
		return string[:string.index(vo[0])]
	else: # more than one vowel groups
		return string[:string.index(vo[-2])]
#def n_min_1_vowel_group(h):p=[l for l in[[l,"!"][i!=0and h[i-1]in v]for i,l in enumerate(h)]if l in v];return h[:h.index(p[[-2,0][len(p)==1]])]
def n_min_1_vowel_group(h):return h[:h.index(([l for l in[[l,"!"][i!=0and h[i-1]in v]for i,l in enumerate(h)]if l in v]*2)[-2])]
# return h[:h.index(p[[-2,0][len(p)==1]])] ::::: p[[-2,0][len(p)==1]] => (p*2)[-2]

f=n_min_1_vowel_group
print '---'
print f("bill")
print f("britain")
print f("programming")

def final(string1,string2):
	return f(string1) + to_vowel(string2)
	
print '---'
"""

print n("brad", "angelina")
print n("out", "go")
print n("code","golf")