Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void Day3Part2()
- {
- string input = File.ReadAllText("C:/input.txt");
- string[] lines = input.Split("\n".ToCharArray(), System.StringSplitOptions.RemoveEmptyEntries);
- int output = 0;
- int count = 0;
- int[] triangle = new int[3];
- for(int j = 0; j < 3; j++)
- {
- for(int i = 0; i < lines.Length; i++)
- {
- string[] line = lines[i].Split(" ".ToCharArray(), System.StringSplitOptions.RemoveEmptyEntries);
- triangle[count] = int.Parse(line[j]);
- count++;
- if(count == 3)
- {
- count = 0;
- if(IsTriangle(triangle[0], triangle[1], triangle[2]))
- {
- output++;
- }
- }
- }
- }
- Debug.Log(output);
- }
- private bool IsTriangle(int a, int b, int c)
- {
- return(a + b > c && a + c > b && b + c > a);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement