Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var input = await File.ReadAllTextAsync("input.txt");
- var blocks = input.Split($"{Environment.NewLine}{Environment.NewLine}");
- var shapes = new int[6];
- for (var i = 0; i < 6; i++)
- {
- var block = blocks[..^1][i];
- shapes[i] = block.Count(c => c == '#');
- }
- var sections = blocks[^1].Split(Environment.NewLine).Select(s => s.Split(": ")).ToArray();
- var part1 = 0;
- foreach (var section in sections)
- {
- var area = section[0].Split('x').Select(int.Parse).Aggregate(1, (a, b) => a * b);
- var coveredArea = 0;
- var requiredShapes = section[1].Split(" ").Select(int.Parse).ToArray();
- for (var j = 0; j < 6; j++)
- {
- coveredArea += requiredShapes[j] * shapes[j];
- }
- if (coveredArea <= area)
- {
- part1++;
- }
- }
- Console.WriteLine($"Part 1: {part1}");
Advertisement
Add Comment
Please, Sign In to add comment