-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
84 lines (53 loc) · 2.14 KB
/
Copy pathProgram.cs
File metadata and controls
84 lines (53 loc) · 2.14 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
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
namespace DictionaryConsoleApp
{
class Program
{
static void Main(string[] args)
{
// get only duplicates from a string
string testString = "Hello, this is a string about Mookey & Moosley, they are cows, Moo!";
Console.WriteLine(ReverseEachWord.ReverseWords(testString));
}
public static void GetcharCountShort(string testString)
{
Dictionary<char, int> duplicates = GetcharCount(testString);
foreach (var w in duplicates)
{
Console.WriteLine(w.Key + "- " + w.Value);
}
}
public static Dictionary<char, int> GetcharCount(string input)
{
var charOccurance = new Dictionary<char, int>();
foreach (var i in input)
{
if (charOccurance.ContainsKey(i))
{
charOccurance[i]++;
}
else
{
charOccurance[i] = 1;
}
}
return charOccurance.Where(a => a.Value > 1).ToDictionary(a => a.Key, a => a.Value); // only duolocates not sinlge ones
// return charOccurance.ToDictionary(a => a.Key, a => a.Value);
}
}
//class Program
//{
// static void Main(string[] args)
// {
// // not duplicated: n g b u k & c !
// string myString = "Hello, this is a string about Mookey & Moosley, they are cows, Moo!";
// //Dictionary.SendMeLetters(myString);
// //Dictionary.SendMeMoreLetters(myString);
// // Dictionary.ParseCustomString(myString);
// //DictionaryConsoleApp.Repeating.SendMeLetters(myString);
// //Console.WriteLine(myString.GroupBy(n => n).Count(p => p.Count() >=2));
// // See https://aka.ms/new-console-template for more information
// //Repeating.cleanDups(myString);
// Console.WriteLine(HashTableTest.CheckChar("sweet lady let's talk"));
// }
//}
}