Created
December 5, 2016 17:10
-
-
Save Xmerr/d4f29f3a13fbd3df70eb195f650b5c15 to your computer and use it in GitHub Desktop.
For Reddit Easy Challenge 284
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
namespace Wandering_Fingers | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
List<string> words = new List<string>(); | |
using (StreamReader file = new StreamReader("Dictionary.txt")) | |
{ | |
string line; | |
//Each line of this file is a new word | |
while ((line = file.ReadLine()) != null) | |
words.Add(line.Trim()); | |
} | |
Console.WriteLine("Input Swiped Keys"); | |
string input = Console.ReadLine(); | |
Console.Clear(); | |
Console.WriteLine("Possible Words: "); | |
foreach(string word in words.Where(w => w.Length > 4 && w[0] == input[0])) | |
{ | |
bool possible = true; | |
int cursorPos = 0; | |
foreach(char c in word) | |
{ | |
cursorPos = input.Substring(cursorPos).IndexOf(c); | |
if (cursorPos == -1) | |
{ | |
possible = false; | |
cursorPos = 0; | |
break; | |
} | |
} | |
if (possible) | |
Console.WriteLine(word); | |
} | |
Console.ReadKey(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For Reddit Easy Challenge 284
Dictionary.txt can be found here