-
Notifications
You must be signed in to change notification settings - Fork 54
/
CSharp.cs
44 lines (36 loc) · 1.24 KB
/
CSharp.cs
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
41
42
43
44
/****************************************/
/* */
/* CodinGame.com Solutions by pathosDev */
/* */
/* Puzzle: Bulk Email Generator */
/* Difficulty: Easy */
/* Date solved: 12.11.2018 */
/* */
/****************************************/
using System;
using System.Text.RegularExpressions;
public class Solution
{
public static void Main()
{
//Read inputs.
int N = int.Parse(Console.ReadLine());
string[] emailTemplateLines = new string[N];
for (int i = 0; i < N; i++)
{
emailTemplateLines[i] = Console.ReadLine();
}
string emailTemplate = string.Join("\n", emailTemplateLines);
int choicesCounter = -1;
//Find all choices.
string email = Regex.Replace(emailTemplate, @"\([^)]*\)", (match) =>
{
choicesCounter++;
//Replace the choices using "random".
string[] choices = match.Value.Substring(1, match.Value.Length - 2).Split('|');
return choices[choicesCounter % choices.Length];
});
//Output email.
Console.WriteLine(email);
}
}