I am upskilling so please excuse what may seem like a dumb mistake; please just gently correct. All the solutions I’m finding online are in C++ and this is just my best attempt at thinking through it in Python. I’ve improved from NZEC and compiling error to “wrong answer.” I know I’m close.
import itertools
import revowels="aeiou"
consonants=“bcdfghjklmnpqrstvwxyzbcdfghjklmnpqrstvwxyz”longvowels=’‘
longconsonants=’’sum_value = 0
for i in itertools.cycle(vowels):
longvowels=longvowels+i
sum_value += 1
if sum_value > 50000:
breaksum_value = 0
for i in itertools.cycle(consonants):
longconsonants=longconsonants+i
sum_value += 1
if sum_value > 50000:
breakccount = {}
result = ‘’def encryption(t):
for c in t:
if c in ccount:
ccount[c] += 1
else:
ccount[c] = 1k = (ccount[c]-1) if c in vowels: #I want to find the kth occurence of c in infinitevowels #then find the index of this kth c #then print the same index number character within infiniteconsonants def encrypt(c): for i in range(len(longvowels)): newcount=0 if i == c: newcount+=1 if newcount == k: indices = [c for c in re.finditer(c, longvowels)] desiredindex=indices[k-1] #this above is supposed to be returning the index of the #desired character result.append(longconsonants[desiredindex]) else: #I want to find the kth occurence of c in infiniteconsonants #then find the index of this kth c #then print the same index number character within infinitevowels def encrypt2(c): for i in range (len(longconsonants)): newcount=0 if i == c: newcount+=1 if newcount == k: indices = [c for c in re.finditer(c, longconsonants)] desiredindex=indices[k-1] result.append(longvowels[desiredindex])
created
last reply
- 5
replies
- 497
views
- 2
users
- 1
link