File.Move(title, mydir);
if (File.Exists(mydir))
File.Delete(mydir);
File.Move(title, mydir);
using System;
using System.Collections.Generic;
namespace GetRepetitions
{
class Program
{
static void Main(string[] args)
{
var scoreCombo = new int[] { 1, 2, 1, 1, 1 };
var repetitions = GetRepetitionsCount(scoreCombo);
foreach (var kv in repetitions)
Console.WriteLine($"Num: {kv.Key}, Rep. Count: {kv.Value}");
}
static Dictionary<int, int> GetRepetitionsCount(int[] arr)
{
var repetitions = new Dictionary<int, int>();
foreach (var num in arr)
if (repetitions.ContainsKey(num))
repetitions[num]++;
else
repetitions.Add(num, 0);
return repetitions;
}
}
}
class Program
{
static void Main(string[] args)
{
var text_path = Environment.CurrentDirectory + @"/files/text.txt";
var text = File.ReadAllText(text_path);
var good_dict_path = Environment.CurrentDirectory + @"/files/good.txt";
var good_dict = File.ReadAllLines(good_dict_path).ToHashSet();
var bad_dict_path = Environment.CurrentDirectory + @"/files/bad.txt";
var bad_dict = File.ReadAllLines(bad_dict_path).ToHashSet();
var text_arr = GetTextAsArray(text);
var good_count = GetWordsCount(text_arr, good_dict);
var bad_count = GetWordsCount(text_arr, bad_dict);
Console.WriteLine(good_count);
Console.WriteLine(bad_count);
}
static IEnumerable<string> GetTextAsArray(string text)
{
return text.Split('.', ' ', ',', ':', ';', '!', '?', '\t', '\n', '\r', '(', ')')
.Where(x => x.Length > 0);
}
static int GetWordsCount(IEnumerable<string> text_arr, HashSet<string> dictionary)
{
var count = 0;
foreach (var str in text_arr)
if (dictionary.Contains(str))
count++;
return count;
}
}
static void AlternateCharCases(char[] word, int startIndex, List<string> result)
{
if (word.Length == startIndex)
{
result.Add(new string(word));
return;
}
word[startIndex] = char.ToLower(word[startIndex]);
AlternateCharCases(word, startIndex + 1, result);
word[startIndex] = char.ToUpper(word[startIndex]);
AlternateCharCases(word, startIndex + 1, result);
}