P204-Python Assignment1
P204-Python Assignment1
**you can type the assignment and upload the document or you can write it in a notebook,
take the photos of it and make a pdf file and upload it.
Algorithm:
A sequence of unambiguous instructions for solving a problem, i.e., for obtaining a
required output for any legitimate input in a finite amount of time.
The word “algorithm” is derived from the ninth-century Arab mathematician, Al-Khwarizmi.
Flowchart:
A flowchart is a visual diagram that represents a process or an algorithm step-by-step
using symbols and arrows. It is used to break down complex tasks into simple,
easy-to-understand steps, helping people to understand the logic behind a process or
workflow.
Symbols:
1. The Merchant’s Dilemma
In a bustling market town, a merchant is preparing for a long journey to a distant city to
sell valuable goods. He owns a sturdy cart that can hold a maximum of 50 units of
weight. The merchant wants to maximize his profits from the trip, but he has a limited
amount of space.
Here’s the challenge: the merchant can only bring a limited number of items on his cart,
and each item has a different weight and value.
3. Gold Rod
An employee works for an employer for 7 days. The employer has a gold rod of 7 units.
How does the employer pay to the employee, so that the number of employee’s rod units
increases by one at the end of each day? The employer can make at most 2 cuts in the
rod.
(Hint- after the end of the day employee’s can’t spend any part of rod)
4. Contaminated Pills
You have 5 jars of pills. Each pill weighs 10 grams, except for contaminated pills
contained in one jar, where each pill weighs 9 grams. Given a scale, how could you tell
which jar had the contaminated pills in just one measurement?