Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace AoC2022;
- internal class Program
- {
- static void Main(string[] args)
- {
- Day1();
- Console.WriteLine("\nready");
- Console.Read();
- }
- static void Day1()
- {
- List<int> cal = new();
- int i = 0;
- foreach (var line in File.ReadLines("input_1.txt"))
- {
- if (int.TryParse(line, out var n))
- i += n;
- else
- {
- cal.Add(i);
- i = 0;
- }
- }
- cal.Sort();
- Console.WriteLine(cal.Max()); //part 1
- Console.WriteLine(cal.TakeLast(3).Sum()); //part 2
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement