re: AoC Day 1: Chronal Calibration VIEW POST

FULL DISCUSSION
 

C#

Part 1

Console.WriteLine(File.ReadAllLines(@".\day1_input.txt").Sum(s => int.Parse(s)));

Part 2

int[] input = File.ReadAllLines(@".\day1_input.txt").Select(s => int.Parse(s)).ToArray();
HashSet<int> set = new HashSet<int>();
int freq = 0;
for (int i = 0; set.Add(freq = freq + input[i % input.Length]); i++) ;
Console.WriteLine(freq);
code of conduct - report abuse