Пример #1
0
        private static void Main(string[] args)
        {
            var rawClaims = File.ReadAllLines("input.txt");

            var allRectangleClaims = new List <ClaimRectangle>();

            foreach (var rawClaim in rawClaims)
            {
                var claimParams = rawClaim.Split(' ');
                var claimId     = claimParams[0];
                var edgeLengths = claimParams[2].TrimEnd(':').Split(',');
                var dimensions  = claimParams[3].Split('x');
                var newClaim    =
                    new ClaimRectangle(edgeLengths[0], edgeLengths[1], claimId, dimensions[0], dimensions[1]);
                allRectangleClaims.Add(newClaim);
            }

            //Now we have all of our claim data out of the input file, so lets begin adding it to our fabric
            var mainFabric = new Fabric(1000, 1000);

            foreach (var rect in allRectangleClaims)
            {
                mainFabric.AddClaim(rect);
            }

            var overlap = mainFabric.Overlap();

            mainFabric.FindNoOverlap();
            Console.ReadLine();
        }
Пример #2
0
        public void AddClaim(ClaimRectangle claim)
        {
            var leftStart = claim.LeftEdgeLength;
            var topStart  = claim.TopEdgeLength;

            for (var i = 0; i < claim.Width; i++)
            {
                for (var j = 0; j < claim.Length; j++)
                {
                    Grid[leftStart + i][topStart + j].AddClaim(claim.ID);
                }
            }

            if (!AllClaimIds.Contains(claim.ID))
            {
                AllClaimIds.Add(claim.ID);
            }
        }