Skip to content

Instantly share code, notes, and snippets.

@Xmerr
Created December 5, 2016 17:10
Show Gist options
  • Save Xmerr/d4f29f3a13fbd3df70eb195f650b5c15 to your computer and use it in GitHub Desktop.
Save Xmerr/d4f29f3a13fbd3df70eb195f650b5c15 to your computer and use it in GitHub Desktop.
For Reddit Easy Challenge 284
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();
}
}
}
@Xmerr
Copy link
Author

Xmerr commented Dec 5, 2016

For Reddit Easy Challenge 284

Dictionary.txt can be found here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment