/
Python.py
34 lines (26 loc) · 863 Bytes
/
Python.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
#****************************************#
#* *#
#* CodinGame.com Solutions by pathosDev *#
#* *#
#* Puzzle: Bulk Email Generator *#
#* Difficulty: Easy *#
#* Date solved: 12.11.2018 *#
#* *#
#****************************************#
import re
#Read inputs.
N = int(input())
emailTemplateLines = [''] * N
for i in range(N):
emailTemplateLines[i] = input()
emailTemplate = '\n'.join(emailTemplateLines)
choicesCounter = -1
#Replacing choices.
def choiceReplace(match):
global choicesCounter
choicesCounter += 1
choices = match.group()[1:-1].split('|')
return choices[choicesCounter % len(choices)]
email = re.sub('\([^)]*\)', choiceReplace, emailTemplate)
#Output email.
print(email)