using System.Collections.Generic;
namespace CodingChallenge
public static void Main()
Console.WriteLine("Welcome to the Word Parser Coding Challenge");
var wordParser = new WordParser();
var distinctWordsDelimitedString = wordParser.ReturnUniqueWordsDelimited(words, delimiter: ",");
Console.WriteLine("ReturnUniqueWordsDelimited returned a count of " + distinctWordsDelimitedString.Split(',').Length);
var duplicateWordsList = wordParser.ReturnWordsWithDuplicatesList(words);
Console.WriteLine("ReturnWordsWithDuplicatesList returned a count of " + duplicateWordsList.Count);
var duplicatesDTOArray = wordParser.ReturnDuplicatesDTO(words);
Console.WriteLine("ReturnDuplicatesDTO returned a count of " + duplicatesDTOArray.Length);
Console.WriteLine("This concludes the Word Parser Coding Challenge!");
Console.WriteLine("Thank you for participating!");
public static Dictionary<string, string> GetWords()
var words = new Dictionary<string, string>();
words.Add("policeman", "bad_data");
words.Add("calculation", " ");
words.Add("thread", "bad_data");
words.Add("despair", "bad_data");
words.Add("reflection", "bad_data");
words.Add("penetrate", "bad_data");
words.Add("conference", "bad_data");
words.Add("worry", "bad_data");
words.Add("divide", "bad_data");
words.Add("organ", "bad_data");
words.Add("limited", "bad_data");
words.Add("smile", "bad_data");
words.Add("strain", "bad_data");
words.Add("expect", "bad_data");
words.Add("alcohol", "bad_data");
public String ReturnUniqueWordsDelimited(Dictionary<string, string> words, string delimiter)
List<string> uniqueWordsDelimited = new List<string>();
foreach(var v in words.Keys)
if(!uniqueWordsDelimited.Contains(v))
uniqueWordsDelimited.Add(v);
return string.Join(delimiter, uniqueWordsDelimited);
public List<string> ReturnWordsWithDuplicatesList(Dictionary<string, string> words)
List<string> duplicateWords = new List<string>();
foreach(var v in words.Keys)
foreach(var i in words.Keys)
public DuplicatesDTO[] ReturnDuplicatesDTO(Dictionary<string, string> words)
Dictionary<string, int> duplicateDTO = new Dictionary<string, int>();
foreach(var v in words.Keys)
if(!duplicateDTO.ContainsKey(v))
duplicateDTO[v] = duplicateDTO[v] +1;
var duplicatesDTOList = new List<DuplicatesDTO>();
foreach(var v in duplicateDTO)
duplicatesDTOList.Add(new DuplicatesDTO{ Word = v.Key, Count = v.Value });
return duplicatesDTOList.ToArray();
public class DuplicatesDTO
public string Word { get; set; }
public int? Count { get; set; }