| 1234567891011121314151617181920212223242526 |
- using System;
- using System.IO;
- using System.Linq;
- namespace D03._2
- {
- class Program
- {
- static void Main(string[] args)
- {
- if (args.Length < 1) throw new ArgumentException();
- if (File.Exists(args[0]) == false) throw new FileNotFoundException();
- int answer = 0;
- var all = File.ReadAllText(args[0]).Split('\n', StringSplitOptions.RemoveEmptyEntries)
- .Select(a => a.Split(' ', StringSplitOptions.RemoveEmptyEntries).Select(s => int.Parse(s)).ToArray());
- var lines = all.Select(a => a[0]).Concat(all.Select(a => a[1])).Concat(all.Select(a => a[2])).ToList();
- for (int i = 0; i < lines.Count; i += 3)
- answer += lines[i] + lines[i + 1] > lines[i + 2] && lines[i] + lines[i + 2] > lines[i + 1] && lines[i + 1] + lines[i + 2] > lines[i] ? 1 : 0;
- Console.WriteLine($"The answer is : {answer}");
- }
- }
- }
|