Wednesday, August 21, 2019

day 2



PROBLM NO :1
An Armstrong number of three digits is an integer such that the sum of the cubes of its digits is equal to the number itself. For example, 371 is an Armstrong number since 3**3 + 7**3 + 1**3 = 371.
Write a program to find all Armstrong number in the range of 0 and 999.


PROBLM NO :2
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:
5
2
Sample Output 1:
Winter Wheat

Sample Input 2:
2
3
Sample Output 2:
Left Fallow

Sample Input 3:
2
2
Sample Output 3:
Beans
PROBLEM NO : 3
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 further. 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
3
1
Sample Output:
2


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.

No comments:

 https://meet.google.com/ydq-hfwq-gdf