7 kyu

What's a beet farmer to do?

30 of 104cliffstamp

Description:

Story

Dwight, sitting in his comfortable rocking chair, over looking his latest beet crop is suddenly interrupted by Mos :

"You know, if we planted more beets, we would make more money." Mos interjects, ruining what was once a peaceful Sunday morning.

Dwight strolls out across the field and stops and tastes the soil, "There is not enough Nitrogen for all of this to be beets ..." he muses outloud.

Heading back to Lotus 1-2-3, he quickly crunches the numbers and determines that for every new crop of beets he plants, he loses a fixed amount from each crop due to the strain on the Nitrogen in the soil.

Can you help Dwight figure out the maximum beetage?

Task

You are given the size of a crop and the loss from each crop if an additional crop is planted. The challenge is to figure out the maximum beets that can be harvested, noting of course you can only plant full crops.

As well, being an astute beeter, Dwight will not exceed the number of crops which would produce the maximum, if he did the the entire harvest would fail due to nitrogen depletion.

(i.e., if 185.9 crops would give the maximum, he would only plant 185 as 186 causes total crop failure)

Ex :

A crop has 10 beets, and each additional crop loses 2 beets from each crop. A maximum of 18 is obtained with two additional crops, as two additional crops cause a loss of 4 from each giving a total of 3x6 or 18 beets.

Note Dwight has a LOT of land (thousands of acres) and there are many beets in a crop, and there might only be a small change per additional crop. However both the number of beets and the loss will be positive (non-zero) numbers.

Mathematics
Fundamentals

More By Author:

Check out these other kata created by cliffstamp

Stats:

CreatedAug 26, 2018
PublishedAug 27, 2018
Warriors Trained586
Total Skips11
Total Code Submissions1638
Total Times Completed104
Haskell Completions30
JavaScript Completions81
Total Stars4
% of votes with a positive feedback rating71% of 40
Total "Very Satisfied" Votes24
Total "Somewhat Satisfied" Votes9
Total "Not Satisfied" Votes7
Total Rank Assessments3
Average Assessed Rank
7 kyu
Highest Assessed Rank
7 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • cliffstamp Avatar
  • Unnamed Avatar
  • JohanWiltink Avatar
  • user8751232 Avatar
  • dfhwze Avatar
Ad