예제 #1
0
        static int GetLengthTravelled(Raindeer r, int seconds)
        {
            int cycles    = seconds / r.CycleSecs;
            int deltaSecs = seconds % r.CycleSecs;
            int flySecs   = cycles * r.activeSecs + Math.Min(deltaSecs, r.activeSecs);

            return(flySecs * r.activeSpeed);
        }
예제 #2
0
        static List <Raindeer> ReadInput()
        {
            string          path   = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"..\..\..\input.txt");
            StreamReader    reader = File.OpenText(path);
            List <Raindeer> list   = new List <Raindeer>();
            string          line;

            while ((line = reader.ReadLine()) != null)
            {
                Raindeer r = new Raindeer();
                string[] s = line.Split(' ').ToArray();
                r.name        = s[0];
                r.activeSpeed = int.Parse(s[3]);
                r.activeSecs  = int.Parse(s[6]);
                r.restingSecs = int.Parse(s[13]);
                list.Add(r);
            }
            return(list);
        }