Equd

AdventOfCode2017 Day05

Dec 5th, 2017
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.75 KB | None | 0 0
  1.             var arr = Properties.Resources.TextFile1.Split('\n').Select(x => int.Parse(x.Trim())).ToArray();
  2.            
  3.             int i = 0;
  4.             int steps = 0;
  5.             while(i >= 0 && i < arr.Length)
  6.             {
  7.  
  8.                 i += arr[i]++;
  9.                 steps++;
  10.             }
  11.  
  12.             int answerA = steps;
  13.             steps = 0;
  14.             i = 0;
  15.  
  16.             arr = arr = Properties.Resources.TextFile1.Split('\n').Select(x => int.Parse(x.Trim())).ToArray();
  17.             while (i >= 0 && i < arr.Length)
  18.             {
  19.                 if(arr[i] >= 3)
  20.                     i += arr[i]--;
  21.                 else
  22.                     i += arr[i]++;
  23.                 steps++;
  24.             }
  25.  
  26.             int AnswerB = steps;
Advertisement
Add Comment
Please, Sign In to add comment