Ejemplo n.º 1
0
        private static void TestMyCalendarThree()
        {
            List <int> list = new List <int>()
            {
                1, 2, 3
            };

            list.Insert(0, 4);

            MyCalendarThree instance = new MyCalendarThree();

            instance.Test();

            var arr = new[]
            {
                new[] { 24, 40 },
                new[] { 43, 50 },
                new[] { 27, 43 },
                new[] { 5, 21 },
                new[] { 30, 40 },
                new[] { 14, 29 },
                new[] { 3, 19 },
                new[] { 3, 14 },
                new[] { 25, 39 },
                new[] { 6, 19 }
            };

            //[null,1,1,2,2,3,3,3,3,4,4]

            foreach (var item in arr)
            {
                instance.Book(item[0], item[1]);
            }
        }
Ejemplo n.º 2
0
        public void Basic()
        {
            var calendar = new MyCalendarThree(0, 100);

            Assert.Equal(1, calendar.Book(10, 20)); // returns 1
            Assert.Equal(1, calendar.Book(50, 60)); // returns 1
            Assert.Equal(2, calendar.Book(10, 40)); // returns 2
            Assert.Equal(3, calendar.Book(5, 15));  // returns 3
            Assert.Equal(3, calendar.Book(5, 10));  // returns 3
            Assert.Equal(3, calendar.Book(25, 55)); // returns 3
        }
Ejemplo n.º 3
0
        public static void Main()
        {
            MyCalendarThree solution = new MyCalendarThree();

            Test.Check(solution.Book, 10, 20, 1);
            Test.Check(solution.Book, 50, 60, 1);
            Test.Check(solution.Book, 10, 40, 2);
            Test.Check(solution.Book, 5, 15, 3);
            Test.Check(solution.Book, 5, 10, 3);
            Test.Check(solution.Book, 25, 55, 3);
            Test.Check(solution.Book, 47, 50, 1);
            Test.Check(solution.Book, 1, 10, 1);
            Test.Check(solution.Book, 27, 36, 1);
            Test.Check(solution.Book, 40, 47, 1);
            Test.Check(solution.Book, 20, 27, 1);
            Test.Check(solution.Book, 15, 23, 2);
            Test.Check(solution.Book, 10, 18, 2);
            Test.Check(solution.Book, 27, 36, 2);
            Test.Check(solution.Book, 17, 25, 3);
            Test.Check(solution.Book, 8, 17, 3);
            Test.Check(solution.Book, 24, 33, 3);
            Test.Check(solution.Book, 23, 28, 4);
            Test.Check(solution.Book, 21, 27, 5);
            Test.Check(solution.Book, 47, 50, 5);
            Test.Check(solution.Book, 14, 21, 5);
            Test.Check(solution.Book, 26, 32, 5);
            Test.Check(solution.Book, 16, 21, 5);
            Test.Check(solution.Book, 2, 7, 5);
            Test.Check(solution.Book, 24, 33, 6);
            Test.Check(solution.Book, 6, 13, 6);
            Test.Check(solution.Book, 44, 50, 6);
            Test.Check(solution.Book, 33, 39, 6);
            Test.Check(solution.Book, 30, 36, 6);
            Test.Check(solution.Book, 6, 15, 6);
            Test.Check(solution.Book, 21, 27, 7);
            Test.Check(solution.Book, 49, 50, 7);
            Test.Check(solution.Book, 38, 45, 7);
            Test.Check(solution.Book, 4, 12, 7);
            Test.Check(solution.Book, 46, 50, 7);
            Test.Check(solution.Book, 13, 21, 7);
        }
Ejemplo n.º 4
0
        public void Failed_case_29()
        {
            /*
             * input: ["MyCalendarThree","book","book","book","book","book","book","book","book","book","book","book","book","book","book","book","book","book","book","book","book","book","book","book","book","book","book","book","book","book","book"]
             * [[],[47,50],[1,10],[27,36],[40,47],[20,27],[15,23],[10,18],[27,36],[17,25],[8,17],[24,33],[23,28],[21,27],[47,50],[14,21],[26,32],[16,21],[2,7],[24,33],[6,13],[44,50],[33,39],[30,36],[6,15],[21,27],[49,50],[38,45],[4,12],[46,50],[13,21]]
             * output:   [null,1,1,1,1,1,2,2,2,3,3,3,4,4,4,4,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6]
             * expected: [null,1,1,1,1,1,2,2,2,3,3,3,4,5,5,5,5,5,5,6,6,6,6,6,6,7,7,7,7,7,7]
             */

            var calendar   = new MyCalendarThree(0, 100);
            var operations = new int[, ] {
                { 47, 50 }, { 1, 10 }, { 27, 36 }, { 40, 47 }, { 20, 27 }, { 15, 23 }, { 10, 18 }, { 27, 36 }, { 17, 25 }, { 8, 17 }, { 24, 33 }, { 23, 28 }, { 21, 27 }, { 47, 50 }, { 14, 21 }, { 26, 32 }, { 16, 21 }, { 2, 7 }, { 24, 33 }, { 6, 13 }, { 44, 50 }, { 33, 39 }, { 30, 36 }, { 6, 15 }, { 21, 27 }, { 49, 50 }, { 38, 45 }, { 4, 12 }, { 46, 50 }, { 13, 21 }
            };
            var expected = new int[] { 1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7 };

            for (int i = 0; i < operations.GetLength(0); i++)
            {
                var result = calendar.Book(operations[i, 0], operations[i, 1]);
                Assert.Equal(expected[i], result);
            }
        }
Ejemplo n.º 5
0
        public void Failed_case_6()
        {
            /*
             * input: ["MyCalendarThree","book","book","book","book","book","book","book","book","book","book"]
             * [[],[24,40],[43,50],[27,43],[5,21],[30,40],[14,29],[3,19],[3,14],[25,39],[6,19]]
             * Output:[null,1,1,2,2,3,4,4,4,5,5]
             * Expected:[null,1,1,2,2,3,3,3,3,4,4]
             */

            var calendar   = new MyCalendarThree(0, 100);
            var operations = new int[, ] {
                { 24, 40 }, { 43, 50 }, { 27, 43 }, { 5, 21 }, { 30, 40 }, { 14, 29 }, { 3, 19 }, { 3, 14 }, { 25, 39 }, { 6, 19 }
            };
            var expected = new int[] { 1, 1, 2, 2, 3, 3, 3, 3, 4, 4 };

            for (int i = 0; i < operations.GetLength(0); i++)
            {
                var result = calendar.Book(operations[i, 0], operations[i, 1]);
                Assert.Equal(expected[i], result);
            }
        }