Пример #1
0
        static void Main(string[] args)
        {
            foreach( var inputFileName in Directory.EnumerateFiles(".", "*.in") )
            {
                var outputFileName = Path.ChangeExtension(inputFileName, ".out");

                Console.WriteLine("Solving {0}...", inputFileName);
                var inputFile = new InputFile(inputFileName);

                using( var outputFile = new OutputFile(outputFileName))
                {
                    foreach (var testCase in inputFile)
                    {
                        Console.WriteLine("TestCase: {0}", testCase);

                        var sortedX = new Vector(testCase.X.OrderBy(xi => xi));
                        var sortedY = new Vector(testCase.Y.OrderByDescending(yi => yi));

                        var product = sortedX * sortedY;

                        var testResult = new TestResult(product);

                        Console.WriteLine("TestResult: {0}", testResult);

                        outputFile.Add(testResult);
                    }
                }
                Console.WriteLine("Solving {0}... done", inputFileName);
            }

            Console.WriteLine("-- PRESS ENTER TO CLOSE --");
            Console.ReadLine();
        }
Пример #2
0
        static void Main(string[] args)
        {
            foreach( var inputFileName in System.IO.Directory.EnumerateFiles(".", "*.in") )
            {
                var outputFileName = Path.ChangeExtension(inputFileName, ".out");

                Console.WriteLine("Solving {0}...", inputFileName);
                var inputFile = new InputFile(inputFileName);

                using( var outputFile = new OutputFile(outputFileName))
                {
                    foreach (var testCase in inputFile.TestCases)
                    {
                        Console.WriteLine("TestCase: {0}", testCase);

                        var mkdirCount = 0;
                        var root = new Directory();

                        foreach (var directory in testCase.ExistingDirectories)
                        {
                            Debug.Assert(!string.IsNullOrEmpty(directory));
                            Debug.Assert(directory[0] == '/');
                            root.Mkdir(directory.Substring(1));
                        }

                        foreach (var directory in testCase.DirectoriesToCreate)
                        {
                            Debug.Assert(!string.IsNullOrEmpty(directory));
                            Debug.Assert(directory[0] == '/');

                            mkdirCount += root.Mkdir(directory.Substring(1));
                        }

                        var testResult = new TestResult(mkdirCount);

                        Console.WriteLine("TestResult: {0}", testResult);

                        outputFile.Add(testResult);
                    }
                }
                Console.WriteLine("Solving {0}... done", inputFileName);
            }

            Console.WriteLine("-- PRESS ENTER TO CLOSE --");
            Console.ReadLine();
        }
Пример #3
0
        static void Main(string[] args)
        {
            foreach( var inputFileName in Directory.EnumerateFiles(".", "*.in") )
            {
                var outputFileName = Path.ChangeExtension(inputFileName, ".out");

                Console.WriteLine("Solving {0}...", inputFileName);
                var inputFile = new InputFile(inputFileName);

                using( var outputFile = new OutputFile(outputFileName))
                {
                    foreach (var testCase in inputFile.TestCases)
                    {
                        Console.WriteLine("TestCase: {0}", testCase);

                        var intersectionCount = 0;

                        for (int index1 = 0; index1 < testCase.Wires.Count-1; index1++)
                        {
                            var wire1 = testCase.Wires[index1];

                            for (int index2 = index1+1; index2 < testCase.Wires.Count; index2++)
                            {
                                var wire2 = testCase.Wires[index2];

                                if (wire1.Intersects(wire2))
                                    intersectionCount++;
                            }
                        }

                        var testResult = new TestResult(intersectionCount);

                        Console.WriteLine("TestResult: {0}", testResult);

                        outputFile.Add(testResult);
                    }
                }
                Console.WriteLine("Solving {0}... done", inputFileName);
            }

            Console.WriteLine("-- PRESS ENTER TO CLOSE --");
            Console.ReadLine();
        }
Пример #4
0
        static void Main(string[] args)
        {
            foreach( var inputFileName in Directory.EnumerateFiles(".", "*.in") )
            {
                var outputFileName = Path.ChangeExtension(inputFileName, ".out");

                Console.WriteLine("Solving {0}...", inputFileName);
                var inputFile = new InputFile(inputFileName);

                using( var outputFile = new OutputFile(outputFileName))
                {
                    foreach (var testCase in inputFile.TestCases)
                    {
                        Console.WriteLine("TestCase: {0}", testCase);

                        var pattern = testCase.Pattern;
                        pattern = pattern.Replace('(','[');
                        pattern = pattern.Replace(')',']');

                        var regex = new Regex(pattern, RegexOptions.Compiled);

                        var matchCount = inputFile.Dictionnary.Count(regex.IsMatch);

                        var testResult = new TestResult(matchCount);

                        Console.WriteLine("TestResult: {0}", testResult);

                        outputFile.Add(testResult);
                    }
                }
                Console.WriteLine("Solving {0}... done", inputFileName);
            }

            Console.WriteLine("-- PRESS ENTER TO CLOSE --");
            Console.ReadLine();
        }
Пример #5
0
 public void Add(TestResult result)
 {
     file.WriteLine("Case #{0}: {1}", ++caseCount, result);
 }