public void RunMultipleAnalyzers() { StringInputParser parser = new StringInputParser(); IEnumerable <IPassphraseAnalyzer> analyzers = new IPassphraseAnalyzer[] { new UniqueWordsAnalyzer(), new NoAnagramsAnalyzer() }; PassphraseListChecker checker = new PassphraseListChecker(parser, analyzers); var input = "abcde fghij\naa bb cc dd aa\noiii ioii iioi iiio"; Assert.Equal(1, checker.CountValidPassphrases(input)); }
public void CountValidPassphrasesFromList() { StringInputParser parser = new StringInputParser(); IEnumerable <IPassphraseAnalyzer> analyzers = new IPassphraseAnalyzer[] { new UniqueWordsAnalyzer() }; PassphraseListChecker checker = new PassphraseListChecker(parser, analyzers); var input = "aa bb cc dd ee\naa bb cc dd aa\naa bb cc dd aaa"; Assert.Equal(2, checker.CountValidPassphrases(input)); }
static void Main(string[] args) { // Part one FileInputParser parser = new FileInputParser(); IEnumerable <IPassphraseAnalyzer> partOneAnalyzer = new IPassphraseAnalyzer[] { new UniqueWordsAnalyzer() }; PassphraseListChecker partOne = new PassphraseListChecker(parser, partOneAnalyzer); Console.WriteLine(partOne.CountValidPassphrases("inputs/day-4.txt")); // Part two IEnumerable <IPassphraseAnalyzer> partTwoAnalyzers = new IPassphraseAnalyzer[] { new UniqueWordsAnalyzer(), new NoAnagramsAnalyzer() }; PassphraseListChecker partTwo = new PassphraseListChecker(parser, partTwoAnalyzers); Console.WriteLine(partTwo.CountValidPassphrases("inputs/day-4.txt")); }