Beispiel #1
0
 public Track(Queue<int> queue, int capacity, Track nextTrack = null)
 {
     this._queue = queue;
     this.Capacity = capacity;
     this._balls = new Stack<int>(capacity);
     this._nextTrack = nextTrack;
 }
Beispiel #2
0
        public string Start()
        {
            Track minuteTrack, fiveTrack, hourTrack;

            hourTrack = new Track(this.Queue, 11);
            fiveTrack = new Track(this.Queue, 11, hourTrack);
            minuteTrack = new Track(this.Queue, 4, fiveTrack);

            var minutes = 0;
            while (true)
            {
                minuteTrack.AddBall(this.Queue.Dequeue());
                minutes += 1;
                if (this.AreQueuesEqual())
                    break;
            }

            return string.Format("{0} balls cycle after {1} days", _originalQueue.Count(), (minutes / 60) / 24);
        }