Example #1
0
        public static LibraryViewModel Create(LibraryResult result, string tabId, int parentId, int?filterFileTypeId, bool allowUpload, LibraryMode mode)
        {
            var model = Create <LibraryViewModel>(tabId, parentId);

            model.Mode             = mode;
            model.RootFolder       = result.Folder;
            model.FilterFileTypeId = filterFileTypeId;
            model.AllowUpload      = allowUpload;
            return(model);
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="daysOfScanning"></param>
        /// <param name="scoresOfBooks"></param>
        /// <param name="libraries"></param>
        /// <returns></returns>
        public static List <LibraryResult> SolveProblem(int daysOfScanning, int[] scoresOfBooks, Library[] libraries)
        {
            int remainingDays = 0;

            List <LibraryResult> result = new List <LibraryResult>();

            foreach (Library library in libraries)
            {
                LibraryResult libraryResult = new LibraryResult();

                int numberOfBooks = daysOfScanning - remainingDays - library.signUpDays;

                numberOfBooks = Math.Min(numberOfBooks, library.numberOfBooks);

                if (numberOfBooks > 0)
                {
                    libraryResult.id = library.id;

                    List <int> books = new List <int>();

                    for (int i = 0; i < Math.Min(numberOfBooks * library.booksPerDay, library.books.Length); i++)
                    {
                        books.Add(library.books[i]);
                    }

                    libraryResult.bookNumbers = books.ToArray();
                    libraryResult.numberOfBooksForScanning = books.Count;
                }
                else
                {
                    break;
                }

                remainingDays += library.signUpDays;

                result.Add(libraryResult);
            }


            return(result);
        }