Advertisement
Guest User

Untitled

a guest
Dec 2nd, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. static void Main(string[] args)
  2. {
  3. using (var sr = new StreamReader(@"C:\Users\Chris\Desktop\AdventOfCode2019\adventinput2.txt"))
  4. {
  5. var myArray = sr.ReadToEnd()
  6. .Split('\n')
  7. .SelectMany(s => s.Split(',')
  8. .Select(x => int.Parse(x)))
  9. .ToArray<int>();
  10.  
  11. for (; ; )
  12. {
  13. Console.WriteLine(index);
  14. if (myArray[index] == 1)
  15. {
  16. AddOps(myArray);
  17. }
  18. else if (myArray[index] == 2)
  19. {
  20. MultiplyOps(myArray);
  21. }
  22. else
  23. {
  24. Console.WriteLine(myArray[0]);
  25. Console.ReadLine();
  26. return;
  27. }
  28. }
  29. }
  30. }
  31.  
  32. static void AddOps(int[] values)
  33. {
  34. values[index + 3] = values[values[index + 1]] + values[values[index + 2]];
  35. index += 4;
  36. Console.WriteLine(values[143]);
  37. return;
  38. }
  39.  
  40. static void MultiplyOps(int[] values)
  41. {
  42. values[index + 3] = values[values[index + 1]] * values[values[index + 2]];
  43. index += 4;
  44. return;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement