Example #1
0
        public void ShouldCountConnectedComponents()
        {
            KnotHash    kh   = new KnotHash();
            GridCreator g    = new GridCreator(kh);
            var         grid = g.Generate("flqrgnkx");

            Defragmentor f = new Defragmentor();

            Assert.Equal(1242, f.CountUsedGroups(grid));
        }
Example #2
0
        public void ShouldCalculateUsedSpace()
        {
            KnotHash    kh   = new KnotHash();
            GridCreator g    = new GridCreator(kh);
            var         grid = g.Generate("flqrgnkx");

            Defragmentor f = new Defragmentor();

            Assert.Equal(8108, f.GetUsedSpace(grid));
        }
Example #3
0
        static void Main(string[] args)
        {
            KnotHash     kh     = new KnotHash();
            GridCreator  d      = new GridCreator(kh);
            Defragmentor f      = new Defragmentor();
            var          square = d.Generate("nbysizxe");

            // Part one
            Console.WriteLine(f.GetUsedSpace(square));

            // Part two
            Console.WriteLine(f.CountUsedGroups(square));
        }