Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            FileInputParser parser = new FileInputParser();
            BlockMemoryBank bank   = new BlockMemoryBank(parser.ParseInput("inputs/day-6.txt"));

            // Part one
            Console.WriteLine(bank.CountReallocationCycles());

            // Part two
            Console.WriteLine(bank.CountReallocationLoopLength());
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            var talks = new FileInputParser().Parse("input.txt");

            var sortedTalks = talks.OrderByDescending(t => t, new TalkComparer()).ToList();

            var schedule = new SessionScheduler().Schedule(sortedTalks);

            new ConsoleWriter().Write(schedule);

            Console.ReadKey();
        }
Ejemplo n.º 3
0
        public void TestFileParserHappyCase()
        {
            string    rootDirectory = Path.GetDirectoryName(Path.GetDirectoryName(Directory.GetCurrentDirectory()));
            string    testDataPath  = Path.Combine(rootDirectory, testDataRelativePath);
            DataTable testData      = FileInputParser.ReadDataTableFromFile(testDataPath, ',');

            Assert.AreEqual(4, testData.DimensionCount);
            Assert.AreEqual(16, testData.DataCount);
            Assert.IsFalse(testData.IsHomogeneous);
            Assert.IsFalse(testData.IsEmpty);
            Assert.AreEqual("Cool?", testData.ClassName);
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            // Part One
            FileInputParser     parser  = new FileInputParser();
            SimpleCaptchaSolver solver  = new SimpleCaptchaSolver();
            CaptchaService      service = new CaptchaService(parser, solver);

            Console.WriteLine(service.SolveCaptcha("inputs/part-one.txt"));

            // Part Two
            CircularCaptchaSolver circularSolver  = new CircularCaptchaSolver();
            CaptchaService        circularService = new CaptchaService(parser, circularSolver);

            Console.WriteLine(circularService.SolveCaptcha("inputs/part-one.txt"));
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            var trainingData = FileInputParser.ReadDataTableFromFile(@"C:\Users\fazia\Documents\DecisionTree\DecisionTree\DecisionTree\TestData\RestaurantTrainData.csv", ',');
            var testingData  = FileInputParser.ReadDataTableFromFile(@"C:\Users\fazia\Documents\DecisionTree\DecisionTree\DecisionTree\TestData\RestaurantTestData.csv", ',');
            var decisionTree = new DecisionTree.Source.Tree.DecisionTree();

            decisionTree.Train(trainingData);
            IList <string> predictions = decisionTree.Predict(testingData);

            Console.WriteLine(predictions.Count);
            foreach (var prediction in predictions)
            {
                Console.WriteLine(prediction);
            }
            Console.ReadLine();
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            FileInputParser parser = new FileInputParser();

            int[] inputs = parser.ParseFile("inputs/day-5.txt");

            // Part One
            OffsetJumper jumperOne = new OffsetJumper(inputs, new IncrementStrategy());
            var          timer     = System.Diagnostics.Stopwatch.StartNew();

            Console.WriteLine("Part one: " + jumperOne.StepsToExit() + " in " + timer.ElapsedMilliseconds + "ms.");

            // Part Two
            OffsetJumper jumperTwo = new OffsetJumper(inputs, new BalancingStrategy());

            timer = System.Diagnostics.Stopwatch.StartNew();
            Console.WriteLine("Part two: " + jumperTwo.StepsToExit() + " in " + timer.ElapsedMilliseconds + "ms.");
        }
Ejemplo n.º 7
0
        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"));
        }