internal void Process(string inputDataFilePath, StreamWriter outFile, string inputWordsFilePath) { List<string> inputWords = ExtractDataRows(inputWordsFilePath); inputWords.Sort(new DescendingComparer()); string inputData = ExtractData(inputDataFilePath); int rowCount, columnCount; columnCount = inputData.IndexOf("\r\n"); inputData = inputData.Replace("\r\n", String.Empty); if (inputData.Length % columnCount != 0) throw new ArgumentException("Jagged array found."); rowCount = inputData.Length / columnCount; CharacterGrid characterGrid = new CharacterGrid(rowCount, columnCount, inputData.ToCharArray()); List<Word> words = new List<Word>(); inputWords.ForEach(x => words.Add(new Word(x))); characterGrid.FindWords(words); //Console.WriteLine(); //Console.WriteLine("------------------------------"); //foreach (FoundWord foundWord in characterGrid.FoundWords) //{ // Console.WriteLine(foundWord.ToString()); //} //Console.WriteLine("------------------------------"); //Console.WriteLine(); }
public TBLRFoundWord(string text, int startingIndex, CharacterGrid characterGrid) : base(text, characterGrid) { Coordinates = new FoundWordCoordinates( new Point(startingIndex % Grid.ColumnCount, startingIndex / Grid.ColumnCount), new Point((startingIndex % Grid.ColumnCount) + Length - 1, (startingIndex / Grid.ColumnCount) + Length - 1)); GetPointHandler = (FoundWord foundWord, int index) => { return new Point(foundWord.Coordinates.A.X + index, foundWord.Coordinates.A.Y + index); }; }
public RLFoundWord(string wordText, int startingIndex, CharacterGrid characterGrid) : base(wordText, characterGrid) { Coordinates = new FoundWordCoordinates( new Point(startingIndex % Grid.ColumnCount, startingIndex / Grid.ColumnCount), new Point((startingIndex % Grid.ColumnCount) - Length + 1, startingIndex / Grid.ColumnCount)); GetPointHandler = (FoundWord foundWord, int index) => { return new Point(foundWord.Coordinates.A.X - index, foundWord.Coordinates.A.Y); }; }
public void Initialize() { _rows = new List<string>(){ "---------------------------america--------------------------", // 0 0 - 59 "------------------------------------------------------------", // 1 60 - 119 "---------------------------p--------------------------------", // 2 120 - 179 "---------------------------i--------------------------------", // 3 180 - 239 "---------------------e-----h-------------c------------------", // 4 240 - 299 "--------------nehctik------s--------f----a------------------", // 5 300 - 359 "-------------------ac------r---------l---k------------------", // 6 360 - 419 "------------------c-i------a----------o--e------------------", // 7 420 - 479 "------a----------t--k------t-----------w--------------------", // 8 480 - 539 "-----l----------s-----yrratstars--------d-------------m-----", // 9 540 - 599 "----i----------e-----------t-------------a-------------i----", //10 600 - 659 "---m----------r------------a--------------b-------------s---", //11 660 - 719 "--o----------o-------------r-----------------------------e--", //12 720 - 779 "-n----------f---------------------------------------------r-", //13 780 - 839 "y----------------------------------------------------------y" //14 840 = 899 }; _words = new List<string>() { AMERICA, BAD_WOLF, CAKE, FOREST_CAKE, KITCHEN, KICK, MISERY, ALIMONY, STARS, STAR, STARRY, STARSHIP}; _rowCount = _rows.Count; _columnCount = 60; _characters = new char[_rowCount * _columnCount]; int k = 0; for (int i = 0; i < _rowCount; i++ ) { char[] row = _rows[i].ToCharArray(); for (int j = 0; j < row.Length; j++) { _characters[k++] = row[j]; } } _characterGrid = new WordSearch2.CharacterGrid(_rowCount, _columnCount, _characters); }