-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChallenge7.cs
81 lines (69 loc) · 1.78 KB
/
Challenge7.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//Challenge 7 - Encrypted lines
using System.Collections.Generic;
using System.IO;
class Challenge7
{
static string InputFileName = @"/Inputs/Challenge 7/submitInput.txt";
static string OutputFileName = @"/Outputs/Challenge 7/submitOutput.txt";
static void Main()
{
string[] input = File.ReadAllLines(InputFileName);
int casesTotal = int.Parse(input[0]);
string[] output = new string[casesTotal];
for (int i = 0; i < casesTotal; i++)
{
string line = input[i + 1];
string lineDecrypt = Decrypt(line);
output[i] = string.Format("Case #{0}: {1}", i + 1, lineDecrypt);
}
File.WriteAllLines(OutputFileName, output);
}
static string Decrypt(string line)
{
string lineDecrypt = string.Empty;
for (int i = 0; i < line.Length; i++)
{
char letter = line[i];
if (letter != ' ' && Dictionary.ContainsKey(letter))
{
letter = Dictionary[letter];
}
lineDecrypt += letter;
}
return lineDecrypt;
}
static Dictionary<char, char> Dictionary = new Dictionary<char, char>
{
{'a','a'},
{'.','e'},
{'c','i'},
{'r','o'},
{'g','u'},
{'x','b'},
{'j','c'},
{'e','d'},
{'u','f'},
{'i','g'},
{'d','h'},
{'h','j'},
{'t','k'},
{'n','l'},
{'m','m'},
{'b','n'},
{'l','p'},
{'\'','q'},
{'p','r'},
{'o','s'},
{'y','t'},
{'k','v'},
{',','w'},
{'q','x'},
{'f','y'},
{';','z'},
{'w',','},
{'v','.' },
{'-','\'' },
{'z','/' },
{'s',';' }
};
}