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...
-
You are buying a car. No Better Deals will give you $500 off the list price on a $10,000 car. a. You can get the same car from Best Deals if you pay $4,000 down and the rest at the end of two years....
-
Refer to E3-12. Data From in E3-12 At January 1 (beginning of its fiscal year), Freeman Inc., a financial services consulting firm, reported the following account balances (in thousands, except for...
-
Suppose that we want to estimate what percentage of all bearings wears out due to friction within a year of installation. How large a sample will we need to be at least \(90 \%\) confident that the...
-
The balance sheet and income statement for Chico Electronics are reproduced below (tax rate is 40%). Required: Compute and interpret the following financial ratios of the company for Year 5: a....
-
Suppose you invest $1,100 for seven years at an annual percentage rate of 8 percent. a. What is the future value if interest is compounded annually? (Do not round intermediate calculations and round...
-
Jakes Cabins is a small motel chain with locations near the national parks of Utah, Wyoming, and Montana. The chain has a total of 500 guest rooms. The following operating data are available for...
-
List and describe the three strategies used to reduce uncertainty, according to the Uncertainty Reduction Theory. What are the nine statements created by the national communication association to...
-
Contrast SCM systems with ERP systems. Which do you suspect are larger and more costly?
-
How might the concept of a facilitating good alter the way we perceive a product? A service?
-
Kyra buys an iPhone for $240 and gets consumer surplus of $160. a. What is her willingness to pay? b. If she had bought the iPhone on sale for $180, what would her consumer surplus have been? c. If...
-
What appears to be the primary secret of successful supply chain management?
-
Outline the four-stage process of change in the audit expectationperformance gap identified as an outcome of reviewing changes in the gap in New Zealand and the UK between 1989 and 2008.
-
7. The circuit in the figure has 5 resistors and 2 ideal batteries. What is the magnitude of the current in the 4-ohm resistor? Show the solution on the other side of the sheet! A. 1.2 A D.2.6 A B....
-
Sheldon and Leonard had a million-dollar idea. In order to make it happen, they have to do special research first. Only Kripke can help them in this matter. But Kripke is known to be the first-class...
-
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...
-
How did the Fed hit its target for the federal funds rate in the pre-2008 scarce-reserves regime?
-
Draw a demand and supply graph for the federal funds market to show the demand and supply of reserves in the current ample-reserves regime. How can the Fed increase the federal funds rate? Show the...
-
What is the zero lower bound in monetary policy? What tools can the Fed use if it wants to implement an expansionary monetary policy at the zero lower bound?
Study smarter with the SolutionInn App