Advertisement
NPSF3000

WordDictFun

May 22nd, 2013
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.33 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3. using System.Linq;
  4. using System.Net;
  5. using System.Threading;
  6.  
  7. namespace WordDictionaryFun
  8. {
  9.     class Program
  10.     {
  11.         static Random r = new Random();
  12.  
  13.         static void Main(string[] args)
  14.         {
  15.             string text = null;
  16.             try
  17.             {
  18.                 text = File.ReadAllText("/words.txt");
  19.             }
  20.             catch (Exception e) { }
  21.  
  22.             if (text == null)
  23.                 try
  24.                 {
  25.                     text = new WebClient().DownloadString("http://www.mieliestronk.com/corncob_lowercase.txt");
  26.                     File.WriteAllText("/words.txt", text);
  27.                 }
  28.                 catch (Exception e) { }
  29.  
  30.             if (text == null) Console.WriteLine("Can't Find Text!");
  31.             else
  32.             {
  33.                 var matches = text.Split('\n')
  34.                     .Where(t => t.Contains("nt") && t.Length < 8)
  35.                     .OrderBy(t=> r.Next()).ToArray();
  36.  
  37.                 Console.WriteLine("Found {0} matches!", matches.Length);
  38.                 Console.ReadLine();
  39.                 foreach (var word in matches)
  40.                 {
  41.                     Console.WriteLine(word);
  42.                     Thread.Sleep(100);
  43.                 }
  44.             }
  45.             Console.ReadLine();
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement