using System; using System.Collections.Generic; using System.IO; namespace D03._1 { class Program { static void Main(string[] args) { if (args.Length < 1) throw new ArgumentException(); if (File.Exists(args[0]) == false) throw new FileNotFoundException(); string text = ""; using (var file = File.OpenText(args[0])) { text = file.ReadToEnd(); } (int x, int y) pos = (0, 0); var visited = new HashSet<(int, int)> { pos }; foreach (var c in text) { switch (c) { case '>': pos.x++; break; case '<': pos.x--; break; case '^': pos.y--; break; case 'v': case 'V': pos.y++; break; default: continue; } visited.Add(pos); } Console.WriteLine($"Answer is : {visited.Count}"); } } }