using System.Collections.Generic;
public static void Main()
var dictionary = new string[]{"chill", "wind", "snow", "cold"};
var src = new string[]{"abcdc", "fgwio", "chill", "pqnsd", "uvdxy"};
var result = new WordFinder(dictionary).Find(src);
foreach (var resultString in result)
Console.WriteLine(resultString);
private readonly IEnumerable<string> _dictionary;
public WordFinder(IEnumerable<string> dictionary)
_dictionary = dictionary;
public IList<string> Find(IEnumerable<string> src)
var result = new HashSet<string>();
result.UnionWith(_dictionary.Where(word => src.Any(row => row.Contains(word))));
var length = src.First().Length;
var srcPivot = new char[length][];
foreach (var character in row)
srcPivot[j] = new char[length];
srcPivot[j][i] = character;
result.UnionWith(_dictionary.Where(word => srcPivot.Any(column => new string (column).Contains(word))));