Wednesday, November 14, 2018

problem 10

Crop cultivation strategy 
 
If a crop is grown for once, the fertility of the soil reduces by 30. After cultivation, if the land is left free for one month, the fertility increases by a factor of 2. If the fertility becomes 0, the crop cannot be grown futher. Write a program to get the initial fertility and get the number of months the land is left free after every cultivation and find the number of times the crops are successfully grown, before the fertility becomes 0. 
  
Note 1: If the fertility becomes 0 in the middle of the growth of crop, the crop stops growing. 
Note 2: Stop getting the input if the fertility becomes 0. 

Input Format: 
First input is an integer that corresponds to the initial fertility of the soil. 
Next inputs are number of months the land is left free after every cultivation. 
Output Format: 
Number of times the crops are grown successfully. 
  
Sample Input: 
35 


Sample Output: 

  
  
Explanation
35->after first cultivation fertility become 5 
3-> after 3 months the fertility becomes 40( 5*2 = 10, 10*2 = 20, 20*2 = 40); After second cultivation the fertility becomes 10 
1-> after 1 month the fertility becomes 20; In the middle of the crop growth the fertility becomes 0, so stop. 
So the total number of successful cultivations = 2.

problem 9

Plants under shade

There are certain plants that needs to be grown under the shade of huge trees and the dead leaves from the trees become the natural manure for the plants. So willow trees are planted throughout the village at certain positions.

The position(distance from the first tree) follows the following series 
0 6 10 17 22 30 36.... 

Input format: 
Input is an integer which corresponds to number of willow trees, n. 

Output format: 
Output is the series that contains 'n' numbers. 

Sample Input 1: 

Sample Output 1: 
0 6 10 17 22 30 36 

Sample Input 2: 

Sample Output 2: 
0 6 10 17 22

problem 8

Planting Crop
A farmer who wants to follow the companion planting method for crops, it would better when they are implementing in gardening and agriculture is the planting of different crops in proximity for pest control, pollination, providing habitat for beneficial creatures, maximizing use of space, and to otherwise increase crop productivity. Companion planting is a form of polyculture.

In the Companion planting method, the crops are planted in the following pattern. 
For n = 5, the pattern should be as follows, 
XXXXXXXXX 
XX - XXX -XX 
X - X - X -X -X 
XX -XXX - XX 
XXXXXXXXX 
XX - XXX- XX 
X- X- X - X - X 
XX - XXX -XX 
XXXXXXXXX 

Hint: Number of rows = 2*n - 1 

Write a program to print the pattern for the given ‘n’ value. 

Input format:
Input is an integer which corresponds to the n.

Output format:
Refer the sample output.

Sample Intput 1:
5
Sample Output 1:
XXXXXXXXX
XX - XXX -XX
X - X - X -X -X
XX -XXX - XX
XXXXXXXXX
XX - XXX- XX
X- X- X - X - X
XX - XXX -XX
XXXXXXXXX

Sample Input 2:
9
Sample Output 2:
XXXXXXXXXXXXXXXXX
XX-----XXX-----XX
X-X---X-X-X---X-X
X--X-X--X--X-X--X
X---X---X---X---X
X--X-X--X--X-X--X
X-X---X-X-X---X-X
XX-----XXX-----XX
XXXXXXXXXXXXXXXXX
XX-----XXX-----XX
X-X---X-X-X---X-X
X--X-X--X--X-X--X
X---X---X---X---X
X--X-X--X--X-X--X
X-X---X-X-X---X-X
XX-----XXX-----XX
XXXXXXXXXXXXXXXXX

problem 7

Fencing the ground

Two non-overlapping fields need to be fenced together to guard from cattle. The fence is always a single rectangle, which cover the two fields exactly.

Given the left bottom coordinate, length and width of the two fields, write a program to find dimension of the fence. Print “Invalid Input” if the fields overlap. 
  
Input Format:
The 1st line of the input consists of 4 integers separated by a space that correspond to x, y, l and w of the first rectangle.
The 2nd line of the input consists of 4 integers separated by a space that correspond to x, y, l and w of the second rectangle.
Output Format:
Output consists of 4 integers that correspond to x, y, l and w of the Union rectangle.

Sample Input 1: 
0 2 4 3 
4 0 2 8 
Sample Output 1: 
0 0 6 8 
  
Sample Input 2: 
0 2 4 3 
3 0 2 8 
Sample Output 2: 
Invalid Input

problem 6

Area Split

Pandu, the farmer, has three sons named, Bhima, Arjuna and Nakula. He has also planed for Three field crop rotation and hand over each field to his three sons.


His sons are fond of even numbers. So they wanted to split the field only if he is able to split it into 3 even number(wrt area) fields. Pandu was so particular that the difference in area of the fields should be minimum because he equally like his three sons. He would split the field only if it is possible, else he would do the normal farming. 
Note that it is possible to split only if all three land have positive area. 
Write a program to help Pandu in spliting the land. 
Input Format:
The first (and the only) input line contains integer that corresponds to the area of the field.
Note: Assume input are positive.

Output Format:
In the first line of the output, print "Yes", if the field can be divided into three parts as per the requirements of Pandu, else print "No".
 
If the first line of the output is "Yes", the next line of the output consists of 3 integers separated by a space, which corresponds to the areas of the divided field. In case of distinct integers, the smallest number should appear first. 

Sample Input 1: 

Sample Output 1: 
Yes 
2 2 2 
  
Sample Input 2: 

Sample Output 2: 
No

problem 5

Project predictor
In the three-field system the sequence of field use involved an autumn planting of grain (wheat, barley or rye) and a spring planting of peas, beans, oats or barley. The third was left fallow, in order to allow the soil of that field to regain its nutrients.

The 3 durations(4 months each) are, 
Duration 1: 1-4 (all inclusive) 
Duration 2: 5-8 (all inclusive) 
Duration 3: 9-12 (all inclusive) 

The 2 crops that were used are,  
Crop 1: Winter Wheat 
Crop 2: Beans 

The initial crops in three fields at month 1are, 
Field 1: Winter Wheat 
Field 2: Beans 
Field 3: Left Fallow 

Given the month number and field number, write a program to print the crop name. 

Input Format: 
The first input is an integer corresponds to month number. 
The second input is an integer corresponds to field number. 

Output Format: 
The output is the string. 

Sample Input 1: 
Sample Output 1: 
Winter Wheat 
  
Sample Input 2: 
Sample Output 2: 
Left Fallow 
  
Sample Input 3: 
Sample Output 3: 
Beans

problem 4

Tillage

Reduced tillage or conservation tillage is a practice of minimising soil disturbance and allowing crop residue or stubble to remain on the ground instead of being thrown away or incorporated into the soil. 30 % of the residue becomes natural manure.

Given the total weight of the residue and the total amount of manure needed for the next crop, write a program to determine the amount of manure needed extra. 


Input Format: 
The first line of the input is an integer that corresponds to the total weight of the residue. 
The second line of the input is an integer that corresponds to the total amount of manure needed. 
 
Output Format: 
An output is a float value that corresponds to the amount of manure needed extra, rounded off to 2 decimal places. 

Sample Input:
100
100
Sample Output:
70.00

problem 3

Demand for organic food

The demand for organic food is growing so fast that consumer demand is outstripping some domestic supplies. 


The demand for organic food increases every year by 8.9%. 
Write a program to find the increase in revenue after 3 years. Given the revenue in the first year is ‘x’ crores. 

Input Format: 
The first line of the input is an integer that corresponds to the ‘x’ value. 

Output Format: 
Output is a float value that corresponds to the revenue after 3 years, rounded off to 2 decimal places. 

Sample Input: 

Sample Output: 
5.17

problem - 2

Crop Rotation
Crop rotation is the practice of growing a series of dissimilar or different types of crops in the same area in sequenced seasons. It is done so that the soil of farms is not used for only one set of nutrients. It helps in reducing soil erosion and increases soil fertility and crop yield. 

In crop rotation technique, there are four strategies. Out of those, 
          1) Two field system 
          2) Three field system 
are popularly followed.       

Two Field System:
Under a two-field rotation, half the land was planted in a year, while the other half lay fallow. Then, in the next year, the two fields were reversed.



Three-field system: 
Dividing available lands into three parts. One section was planted in the autumn with rye or winter wheat, followed by spring oats or barley; the second section grew crops such as peas, lentils, or beans; and the third field was left fallow. The three fields were rotated in this manner so that every three years, a field would rest and be fallow. 



Write a program to find the productivity area for two field system and three field system. 

Input Format: 
Input is an integer that corresponds to the area of the farm. 

Output Format: 
The first line of the output is a float value that corresponds to the production area in two field system. 
The second line of the output is a float value that corresponds to the production area in three field system. 

Note: Format the output with 2 decimal points. 
  
Sample Input: 
600 
Sample Output: 
300.00 
400.00

problem -1

Plantation
A certain crop grown in a sunny and hot climate needs more water per day than the same crop grown in a cloudy and cooler climate. There are, however, apart from sunshine and temperature, other climatic factors which influence the crop water need. These factors are humidity and wind speed. When it is dry, the crop water needs are higher than when it is humid. In windy climates, the crops will use more water than in calm climates.
The highest crop water needs are thus found in areas which are hot, dry, windy and sunny. The lowest values are found when it is cool, humid and cloudy with little or no wind. 

Given 3 crops along with the range of the amount of water required and the temperature range.
Crop 1: Rice – 5 to 10 cm , 20 to 27 degree celcius, all  inclusive.
Crop 2: Wheat – 12 to 15 cm, 21 to 24 degree celcius, all inclusive.
Crop 3: Cotton – 6 to 13 am, 18 to 30 degree celcius, all inclusive.
  Note: Follow the above crops order.

Determine what all crops can be planted, given the rainfall and temperature. 

Input format: 
The first input is an integer which corresponds to the water required. 
The second input is an integer which corresponds to the temperature. 

Output format: 
Output is a string or a list of strings. 
If there are multiple strings in the output, the order to be followed is Rice, Wheat, Cotton. 

Sample Input 1: 
6 
20 
Sample Output 1: 
Rice 
Cotton 

Sample Input 2: 
15 
21 
Sample Output 2: 
Wheat





 DBMS class materials click here to join the class room  click here  https://www.youtube.com/channel/UC93Sqlk_tv9A9cFv-QjZFAQ