Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void Main(string[] args)
- {
- using (var sr = new StreamReader(@"C:\Users\Chris\Desktop\AdventOfCode2019\adventinput2.txt"))
- {
- var myArray = sr.ReadToEnd()
- .Split('\n')
- .SelectMany(s => s.Split(',')
- .Select(x => int.Parse(x)))
- .ToArray<int>();
- for (; ; )
- {
- Console.WriteLine(index);
- if (myArray[index] == 1)
- {
- AddOps(myArray);
- }
- else if (myArray[index] == 2)
- {
- MultiplyOps(myArray);
- }
- else
- {
- Console.WriteLine(myArray[0]);
- Console.ReadLine();
- return;
- }
- }
- }
- }
- static void AddOps(int[] values)
- {
- values[index + 3] = values[values[index + 1]] + values[values[index + 2]];
- index += 4;
- Console.WriteLine(values[143]);
- return;
- }
- static void MultiplyOps(int[] values)
- {
- values[index + 3] = values[values[index + 1]] * values[values[index + 2]];
- index += 4;
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement