-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
32 lines (25 loc) · 1.16 KB
/
Program.cs
File metadata and controls
32 lines (25 loc) · 1.16 KB
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
using MonoAlphabeticCipher_Semestralka_Andrei;
const string BEST_SOLUTION_FILENAME = "best.txt",
CIPHER_FILENAME = "monoalphabetic_cipher_2024.txt",
WORDS_LIST_FILENAME = "words_united.txt",
DECODED_RESULT_FILENAME = "result.txt";
var work = new Work(CIPHER_FILENAME, WORDS_LIST_FILENAME);
work.Init();
Console.Write("Write 'solution' to find solution and 'decode' to decode text with the best found solution: ");
string? choice;
while ((choice = Console.ReadLine()) == null || (choice.ToLower() != "solution" && choice.ToLower() != "decode")) Console.WriteLine("Something wrong.");
if (choice.ToLower() == "decode")
{
string bestSolution = File.Exists(BEST_SOLUTION_FILENAME) ? File.ReadAllText(BEST_SOLUTION_FILENAME) : string.Empty;
string decoded = work.Decode(bestSolution);
Console.WriteLine("Decoded with our best solution. Writed to 'result.txt'.");
File.WriteAllText(DECODED_RESULT_FILENAME, decoded);
Console.WriteLine("These words were not found in English dictionary: ");
work.WriteNotFoundWords(bestSolution);
Console.WriteLine();
}
else
{
work.FindSolution();
}
Console.ReadKey();