Kane is a Twitter employee and a fitness freak. But, it is tough to say no...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Kane is a Twitter employee and a fitness freak. But, it is tough to say no to the culinary delights of the Twitter chefs. Twitter chefs also mention the calorie value of a meal they are going to prepare for the coming days in advance. So, Kane came up with a plan to be on fast some days and eat on the other days. When he is on fast, he consumes no calories, but on the day he eats, he consumes the amount of calories mentioned in the chart by the chef. His fitness goal is the total amount of calories intake over a certain days of time, that is , he wants to consume a total of X number of calories EXACTLY. Let's say there is an array of positive integers representing calorie counts for each day, help Kane to decide if it's possible to eat the exact number of calories according to his fitness goal Example - 1: Input calCounts : (2, 9, 5, 1, 6), requiredCals : 12 Calories Output = True Because, he can eat on days - 0,1,3 (2 + 9 +1 = 12) OR he can eat on days - 2,3,4 (5 + 1+ 6) Example - 2: Input = calCounts : {2, 3, 15, 1, 16), requiredCals : 8 Calories Output = False Because, the target of 8 cannot be met by adding any of the subset of the values. Limits : Size of the Array <= 30 0< Values in the Array <= 1000000000 O< requiredCals <= 1000000000 def isPossible(calCounts, requiredCals): if _name_ '_main__': fptr = open(os.environ['OUTPUT_PATH'], 'w') calCounts_count = int(input ().strip()) calCounts = [ for - in range (calCounts count): calCounts item = int (input ().strip()) calCounts.append (calCounts_item) | requiredcals = int(input ().strip()) result = isPossible(calCounts, requiredCals) fptr.write(str (int (result)) + 'In') fptr.close () Kane is a Twitter employee and a fitness freak. But, it is tough to say no to the culinary delights of the Twitter chefs. Twitter chefs also mention the calorie value of a meal they are going to prepare for the coming days in advance. So, Kane came up with a plan to be on fast some days and eat on the other days. When he is on fast, he consumes no calories, but on the day he eats, he consumes the amount of calories mentioned in the chart by the chef. His fitness goal is the total amount of calories intake over a certain days of time, that is , he wants to consume a total of X number of calories EXACTLY. Let's say there is an array of positive integers representing calorie counts for each day, help Kane to decide if it's possible to eat the exact number of calories according to his fitness goal Example - 1: Input calCounts : (2, 9, 5, 1, 6), requiredCals : 12 Calories Output = True Because, he can eat on days - 0,1,3 (2 + 9 +1 = 12) OR he can eat on days - 2,3,4 (5 + 1+ 6) Example - 2: Input = calCounts : {2, 3, 15, 1, 16), requiredCals : 8 Calories Output = False Because, the target of 8 cannot be met by adding any of the subset of the values. Limits : Size of the Array <= 30 0< Values in the Array <= 1000000000 O< requiredCals <= 1000000000 def isPossible(calCounts, requiredCals): if _name_ '_main__': fptr = open(os.environ['OUTPUT_PATH'], 'w') calCounts_count = int(input ().strip()) calCounts = [ for - in range (calCounts count): calCounts item = int (input ().strip()) calCounts.append (calCounts_item) | requiredcals = int(input ().strip()) result = isPossible(calCounts, requiredCals) fptr.write(str (int (result)) + 'In') fptr.close ()
Expert Answer:
Answer rating: 100% (QA)
Python program def isPossiblecalCountsrequiredCals if requiredCals 0 return True if len... View the full answer
Related Book For
Entrepreneurship Successfully Launching New Ventures
ISBN: 978-0133797190
5th edition
Authors: Bruce R. Barringer, R. Duane Ireland
Posted Date:
Students also viewed these accounting questions
-
The meal plan at University A lets students eat as much as they like for a fixed fee of $500 per semester. The average student there eats 250 lb of food per semester. University B charges students...
-
Let X be F distributed with 9 numerator and 12 denominator degrees of freedom. Find (a) P(X 3.87), (b) P(X 0.196), (c) The value of a and b such that P (a < Y < b) = 0.95.
-
The meal plan at university A lets students eat as much as they like for a fixed fee of $500 per semester. The average student there eats 250 pounds of food per semester. University B charges $500...
-
1. Suppose that a stoichiometric mixture of isooctane (C8H18) and air is burned in an engine and then the fuel is changed to 10% (by liquid volume) ethanol and 90% by liquid volume isooctane. If the...
-
It is said that the equityholders of a levered firm can be thought of as holding a call option on the firms assets. Explain what is meant by this statement.
-
Going Places, Inc., manufactures a variety of luggage for airline passengers. The company has several luggage production divisions, including the Suitable Cases Division, as well as a wholly owned...
-
The Moose Wings Cooperative Flight Club owns a number of airplanes and gliders. It serves fewer than 2,000 members, who are numbered sequentially from the founder, Tom Eagle (0001), to the newest...
-
An engine system consists of three main components in a series, all having the same reliability. Determine the level of reliability required for each of the components if the engine is to have a...
-
Bartlett Car Wash Company is considering the purchase of a new facility. It would allow Bartlett to increase its net income by $90,321 per year. Other information about this proposed project follows:...
-
Suppose that Coke and Pepsi are fighting for the cola market. Each week each person in the market buys one case of Coke or Pepsi. If the persons last purchase was Coke, there is a 0.90 probability...
-
On December 3 1 , Jarden Company's Allowance for Doubtful Accounts has an unadjusted credit balance of $ 1 5 , 0 0 0 . Jarden prepares a schedule of its December 3 1 accounts receivable by age....
-
When a multi-stage booster is fired into space, the mass of the booster changes as the fuel is burned during flight. Discuss how the change in mass influences the acceleration of the booster. When...
-
Last year, the State Board of Education in the State of Jefferson made some changes in the prescribed history curriculum in its public schools. In the "New History Curriculum," all American history...
-
Nissan Company estimated direct labor hours for 2015 to be 117,000 hours with budgeted overhead of P2,340,000. The company applies factory overhead on the basis of direct labor hours. During the...
-
Your client was charged with arson. You find one precedent on point. That court articulated a four-part test for arson. That test requires: 1) the intentional or reckless disregard of an apparent...
-
George is playing a lottery game where he selects a marble out of bag and then replaces it after each pick. There are 6 blue marbles and 9 red marbles. With replacement, what is the probability that...
-
Given: From the Balance Sheet Raw materials inventory Beginning $1,337,000 $ 1,751,000 Ending Work in process inventory Finished goods inventory 1,605,000 655,000 1,342,000 1,072,000 From the Cost...
-
The following selected information was taken from Sun Valley Citys general fund statement of revenues, expenditures, and changes in fund balance for the year ended December 31, 2019: Revenues:...
-
Find an example of a start-up incubator or accelerator at the college or university you are attending or in the town you live in or a nearby city. Describe the program. Which one of the Austin,...
-
What are the guidelines to follow when establishing a board of advisors?
-
Toward the beginning of this case, the following statement appears: Almost all small businesses experience cash flow shortfalls. What is cash flow? Why is cash flow so critical to an entrepreneurial...
-
Consider the problem of generating samples from \(Y \sim \operatorname{Gamma}(2,10)\). (a) Direct simulation: Let \(U_{1}, U_{2} \sim\) idd \(\mathscr{U}(0,1)\). Show that \(-\ln \left(U_{1} ight) /...
-
Let \(U, V \sim_{\text {iid }} \mathscr{U}(0,1)\). The reason why in Example 3. 7 the sample mean and sample median behave very differently is that \(\mathbb{E}[U / V]=\infty\), while the median of...
-
As a generalization of Example C.9, consider a random walk on an arbitrary undirected connected graph with a finite vertex set \(\mathscr{V}\). For any vertex \(v \in \mathscr{V}\), let \(d(v)\) be...
Study smarter with the SolutionInn App