A large apple farm distributes their apples in boxes that they can source from any one of a number of nearby box manufacturers. Each box manufacturer makes only one box type that holds a specific number of apples - so a box from one manufacturer might hold 24 apples, while a box from another might hold 13. The apple farm can only choose one box supplier each year (a decision they make each year based on price), but they can then order an unlimited number of boxes of that type. The farm likes to be prepared, and creates large batches of apples to pack before the decision about which box type to use has been made. The farm also likes to limit waste, and tries to set the number of apples in these large batches such that they can fill an integer number of boxes perfectly with no apples left over. In creating these batches, although the farm doesn't yet know the exact capacity of the boxes they will buy, they know a list of possible values the box capacity will take. For example, if the list of possible box capacities is [13,24,25,32], then a batch size of 31200 apples will completely fill an integer number of any of these boxes. As a further example, a batch size of 18810 apples would completely fill an integer number of boxes chosen from the list: [5,9,33,57,66]. Write a function called Q10 that takes a row vector of positive integers (corresponding to the possible box capacities) as an input argument, and returns a single output argument (either a double or uint64 data type) corresponding to the smallest batch size that would completely fill an integer number of any of the boxes selected from the input list. You may assume that the input vector contains between 1 and 15 integers (sorted in ascending order), with values between 1 and 99. Your code should only take a few seconds (at most) to run, even for larger input vectors. Submissions that take too long to run will be marked as incorrect.
A large apple farm distributes their apples in boxes that they can source from any one of a number of nearby box manufacturers. Each box manufacturer makes only one box type that holds a specific number of apples - so a box from one manufacturer might hold 24 apples, while a box from another might hold 13. The apple farm can only choose one box supplier each year (a decision they make each year based on price), but they can then order an unlimited number of boxes of that type. The farm likes to be prepared, and creates large batches of apples to pack before the decision about which box type to use has been made. The farm also likes to limit waste, and tries to set the number of apples in these large batches such that they can fill an integer number of boxes perfectly with no apples left over. In creating these batches, although the farm doesn't yet know the exact capacity of the boxes they will buy, they know a list of possible values the box capacity will take. For example, if the list of possible box capacities is [13,24,25,32], then a batch size of 31200 apples will completely fill an integer number of any of these boxes. As a further example, a batch size of 18810 apples would completely fill an integer number of boxes chosen from the list: [5,9,33,57,66]. Write a function called Q10 that takes a row vector of positive integers (corresponding to the possible box capacities) as an input argument, and returns a single output argument (either a double or uint64 data type) corresponding to the smallest batch size that would completely fill an integer number of any of the boxes selected from the input list. You may assume that the input vector contains between 1 and 15 integers (sorted in ascending order), with values between 1 and 99. Your code should only take a few seconds (at most) to run, even for larger input vectors. Submissions that take too long to run will be marked as incorrect.
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 4 steps with 1 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education