PF_Assignment_1-1
PF_Assignment_1-1
How to submit
There are a total 10 questions in the assignment and each question carries equal marks i.e 10.You must
submit the hard copy of your own handwritten assignment in my office within the due date. Solve each
problem on a separate sheet of paper with neat and legible handwriting and diagrams using dark pencil or
pen.
On your marks…
Problem 1: Miles per hour to kilometers per seconds
This year olympics were held in Europe causing all sorts of problems for the Americans as they don’t use
the standard measures like meters and kilometers, grams and kilograms. For racing events the speeds are
measured in kilometers per seconds. Can you design a solution to convert kilometers per seconds to miles
per hour for US viewers of the Paris Olympics?
Input: Input:
● Height: 55 inches ● Height: 48 inches
● Age: 10 years ● Age: 9 years
● Ride: "The Carousel" ● Ride: "The Dragon Roller Coaster"
Expected Output: Expected Output:
"You meet the criteria for The Carousel." "Sorry, you do not meet the criteria for The Dragon
Roller Coaster."
E.g., 0110000 means only panel ‘B’ and ‘C’ are lit thus telling that this is the first
floor. Similarly, the number 1111110 tells that all panels are lit except panel ‘G’
displaying the number 0.
You need to design a program for a computer surveillance system to tell which floor the lift is on. The input
for the program is the 7-digit number comprising only 1s and 0s. The output should be a single digit number
0 to 9 telling which floor the lift is on.
Hint: You can get the last digit by using %10 and the remaining digits by using number division /10. Also,
you only need branching to do it.
Get set ...
Problem 8: Digit Sum
You are required to design a solution that takes as input a single number and prints out the sum of its
digits. Check the examples below for clarity.
Examples:
sumDigit(345) = 12 sumDigit(1) = 1 sumDigit(1600) = 7
sumDigit(55) = 10 sumDigit(400000000) = 4 sumDigit(0) = 0
Go Go Go !!!
Problem 10: Poor Mr. Bhoola bought a faulty keyboard
Imagine Mr. Bhoola's keyboard is a bit mischievous! Every time he types the number "9," the keyboard adds
an extra zero. So, if he types "9," it shows up as "90".
Your Mission:
Mr. Bhoola wrote down some numbers using his silly keyboard. But we know they're wrong because of the
extra zeroes. Your job is to fix them by taking away the extra zeroes whenever you see a "90" in the number.
Here are some examples:
100900: The keyboard typed "90" where there should be "9". So, it's really 10090.
1540090: The keyboard added an extra zero again. It's really 154009.
1290905: This one is tricky! There's a "90" where there should be a "9". It's really 12995.
Design a solution to fix the other numbers Mr. Bhoola wrote down!
Problem 11: No not optimus prime its Coprime..
Mr. Bhoola just found out about coprime numbers. Now he is obsessed with them and keeps checking two
numbers whether they are coprime or not. You are to design a solution to this problem and help Mr. Bhoola
with checking whether any two whole numbers greater than 0 are coprime or not.
A simplified definition of Coprime numbers is that their GCD is 1. You are encouraged to check wiki or other
resources for more information.
Examples:
8 and 9 are coprimes despite the fact that they are not prime numbers.
14 and 33 are coprimes.
Problem 13: The general N-M size die hard jug problem
Design a solution to solve the general form M-NL jugs of the above problem.
So instead of having just 3-5L jugs you can be given 3-9L jugs or 7-9L jugs. Can you extract any number of
liters of water less than the larger jug or only some quantities. Is there a formula for this? What amounts of
water can be extracted from M-NL jugs?
GOOD LUCK 🙂