Solutions for the coding assignments, IEM CSE Dept., 5th Semester.
DAY 1 : Vessel filling problem
Given two vessels, one of which can accommodate 'a' liters of water and the other which can accommodate 'b' liters of water, determine the number of steps required to obtain exactly 'c' liters of water in one of the vessels.
At the beginning both the vessels are empty. The following operations are counted as 'steps':
- Emptying a vessel
- Filling a vessel completely
- Pouring water from one vessel to the other, without spilling, until one of the vessels is either full or empty.
DAY 2 : Bit Pairs
Given N three-digit numbers, your task is to find the bit score of all N numbers and then print the number of pairs possible based on these calculated bit scores.
-
Rule for calculating bit score from three digit number: From the 3-digit number, extract largest digit and multiply by 11 then extract smallest digit multiply by 7 then add both the result for getting bit pairs. Note: - Bit score should be of 2-digits, if above results in a 3-digit bit score, simply ignore most significant digit.
-
Rules for making pairs from above calculated bit scores Condition for making pairs are Both bit scores should be in either odd position or even position to be eligible to form a pair. Pairs can be only made if most significant digits are the same and at most two pairs can be made for a given significant digit.
DAY 3 : Strings and length counts
Q.1. Given a string of words separated by spaces. The task is to find the first maximum length, even word, from the string. Eg: “You are given an array of n numbers” The answer would be “an” and not “of” because “an” comes before “of”.
(a) Now modify your code to display n th even length word (where n is given as user input).
(b) Modify your code to find the m th maximum length word.