static void Main(string[] args) { List <ScrabbleWord> gameDictionary = new List <ScrabbleWord>(); ScrabbleRuleset ruleset = new ScrabbleRuleset(); ruleset.AddCharScores("eaionrtlsu", 1); ruleset.AddCharScores("dg", 2); ruleset.AddCharScores("bcmp", 3); ruleset.AddCharScores("fhvwy", 4); ruleset.AddCharScores("k", 5); ruleset.AddCharScores("jx", 8); ruleset.AddCharScores("qz", 10); int N = int.Parse(Console.ReadLine()); for (int i = 0; i < N; i++) { string W = Console.ReadLine(); gameDictionary.Add(new ScrabbleWord(W, ruleset)); } ScrabbleWord bestWord = null; string gameLetters = Console.ReadLine(); foreach (ScrabbleWord gameWord in gameDictionary) { if (gameWord.Usable(gameLetters) && bestWord == null) { bestWord = gameWord; } else if (gameWord.Usable(gameLetters) && gameWord.Score > bestWord.Score) { bestWord = gameWord; } } if (bestWord == null) { Console.WriteLine("Empty list"); } else { Console.WriteLine(bestWord.Word); } }
public ScrabbleWord(string word, ScrabbleRuleset ruleset) { Word = word; Score = ruleset.CalculateWordScore(word); Length = word.Length; }