Example #1
0
        static void LoadFile()
        {
            string strReadFile = @"C:\input.txt";

            string[] separator = { ">, r=" };

            //pos=<-63146556,43584945,33395491>, r=79347912

            var fileLines = File.ReadAllLines(strReadFile).ToList();

            nanobots = new List <nanobot>();
            foreach (string line in fileLines)
            {
                string[] temp = line.Substring(5).Split(separator, StringSplitOptions.RemoveEmptyEntries);
                string[] pos  = temp[0].Split(',');

                if (temp.Length >= 2)
                {
                    nanobot bot = new nanobot();
                    bot.x = double.Parse(pos[0]);
                    bot.y = double.Parse(pos[1]);
                    bot.z = double.Parse(pos[2]);
                    bot.r = double.Parse(temp[1]);
                    nanobots.Add(bot);
                }
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            LoadFile();
            largestradius = nanobots.Max(x => x.r);

            biggestbot = nanobots.FirstOrDefault(x => x.r == largestradius);

            foreach (nanobot bot in nanobots)
            {
                if (calcdistance(bot, biggestbot) <= largestradius)
                {
                    counter++;
                }
            }

            Console.WriteLine("Largest Radius: " + largestradius.ToString());
            Console.WriteLine("Amount of bots in range: " + counter.ToString());
            Console.ReadLine();
        }
Example #3
0
 static double calcdistance(nanobot origin, nanobot otherone)
 {
     return(Math.Abs(origin.x - otherone.x) + Math.Abs(origin.y - otherone.y) + Math.Abs(origin.z - otherone.z));
 }