Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static HashSet<string> dictionary;
- private static IOrderedEnumerable<string> results;
- static IEnumerable<string> Process() {
- var retVal = new List<string>();
- foreach (var word in dictionary) {
- if (word == "ANNA") {
- Console.Write("");
- }
- if (dictionary.Contains(NextWord(word))) {
- Console.WriteLine(NextWord(word) + " <-- " + word);
- retVal.Add(word);
- }
- }
- return retVal;
- }
- static string NextWord(string word) {
- var chars = word.ToUpper().ToCharArray().Select(c => (c == 'Z') ? 'A' : (char)((int)c + 1)).ToArray();
- return new string(chars);
- }
- static string PrevWord(string word) {
- var chars = word.ToUpper().ToCharArray().Select(c => (c == 'A') ? 'Z' : (char)((int)c - 1)).ToArray();
- return new string(chars);
- }
- static HashSet<string> LoadWords() {
- IEnumerable<string> words;
- using (var sr = new StreamReader(@"\\bcna.corp\DFS\shared\QuantStrat\iCredit-iOS\words.txt")) {
- words = sr.ReadToEnd().Split(new[] {"\r\n"}, StringSplitOptions.RemoveEmptyEntries);
- }
- return new HashSet<string>(words.Select(w => w.ToUpper()));
- }
- static void Main(string[] args) {
- dictionary = LoadWords();
- results = Process().OrderBy(w => w);
- using (var sw = new StreamWriter(@"\\bcna.corp\DFS\shared\QuantStrat\iCredit-iOS\result.txt")) {
- foreach (var word in results) {
- sw.WriteLine(NextWord(word) + " <-- " + word);
- }
- }
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement