Ejemplo n.º 1
0
 public void Overlap()
 {
     Assert.IsTrue(IPReader.Overlap(new uint[] { 0, 10 }, new uint[] { 5, 15 }));
     Assert.IsTrue(IPReader.Overlap(new uint[] { uint.MaxValue - 20, uint.MaxValue - 10 }, new uint[] { uint.MaxValue - 15, uint.MaxValue }));
     Assert.IsFalse(IPReader.Overlap(new uint[] { uint.MaxValue - 20, uint.MaxValue - 10 }, new uint[] { uint.MaxValue - 5, uint.MaxValue }));
     Assert.IsFalse(IPReader.Overlap(new uint[] { 0, 5 }, new uint[] { 10, 15 }));
     Assert.IsTrue(IPReader.Overlap(new uint[] { 0, 5 }, new uint[] { 6, 15 }));
 }
Ejemplo n.º 2
0
        public void DoPuzzle()
        {
            var blocked         = GetBlockedIpsOfInput();
            var lowestUnblocked = IPReader.GetLowestUnblocked(blocked, 0, 4294967295);

            Assert.IsTrue(lowestUnblocked > 1770166); //wrong!

            Console.Out.WriteLine(lowestUnblocked);
        }
Ejemplo n.º 3
0
 public void Example()
 {
     Assert.AreEqual((uint)3, IPReader.GetLowestUnblocked(new uint[][]
     {
         new uint[] { 5, 8 },
         new uint[] { 0, 2 },
         new uint[] { 4, 7 }
     }, 0, 9));
 }
Ejemplo n.º 4
0
 public void MergeContigious2()
 {
     Assert.AreEqual("1-4, 6-9", string.Join(", ", IPReader.MergeContigious(new uint[][]
     {
         new uint[] { 1, 2 },
         new uint[] { 3, 4 },
         new uint[] { 6, 9 },
         new uint[] { 8, 9 }
     }).Select(u => string.Join("-", u))));
 }
Ejemplo n.º 5
0
        public void ExamplePart2()
        {
            var blocked = new[]
            {
                new uint[] { 5, 8 },
                new uint[] { 0, 2 },
                new uint[] { 4, 7 }
            };

            Assert.AreEqual(2, IPReader.GetCountUnblocked(blocked, 0, 9));
        }
Ejemplo n.º 6
0
        public void GetNumAllowed()
        {
            var blocked = GetBlockedIpsOfInput();

            Console.Out.WriteLine(IPReader.GetCountUnblocked(blocked, 0, 4294967295));
        }