Docsity

logic building assignment, Assignments of Computer Programming

Toggle sidebar
bg1
Assignment # 1
For Logic Building Practice
Problem 1
1. You have 2 drums of capacity
-8 litter
-5 litter
And a resource of Oil, can you use these two drums to give 1 liter, 2litre, 3-liter, 4 liter, and 6 liters
and 7 liters to any customer. Note that there is no mark of liters on the drums.
2. Now you have to measure again the same question: But you have 9 liters and 6 liters drums. Can
you solve that same problem, if yes how? if no why?
Problem 2
On your first day at NAMAL, the teacher suggested that it would be a good idea for each student to
meet every other student in the class. The teacher said, "When you meet, please shake hands and
introduce yourself by name." If there were 20 students in the class, how many total handshakes were
there? What about if there are N students can you tell in terms of N what is the total count of shake-
hands.
Problem 3
If you were to construct a 8 x 8 chess board, how many squares (within that chess board) would there
be in total? (64 is not the answer). You remember the 8 balls problem, now you have N balls you have
to tell how many times you have to weigh at max to figure out which ball is the heavier one? Just a
direction: First try to figure out, 9, 16, 21, 27, 30, 50, 81 and then you will see what is the pattern!
Problem 4
You are given 2 eggs. You have access to a 100-story building. Eggs can be very hard or very fragile
means it may break if dropped from the first floor or may not even break if dropped from 100th floor.
Both eggs are identical. You need to figure out the highest floor of a 100-story building an egg can be
dropped without breaking. The question is how many drops you need to make. You are allowed to
break 2 eggs in the process.
Problem 5
Divide $277 (in whole $ increments) into a number of bags so that I can ask for any amount between
$1 and $277, and you can give me the proper amount by giving me a certain number of these bags
without opening them. What is the minimum number of bags you will require?
Problem 6
A corporate businessman has two cubes on his office desk. Every day he arranges both cubes so that
the front faces show the current day of the month. What numbers are on the faces of the cubes to allow
this?
Note: You can't represent the day "7" with a single cube with a side that says 7 on it. You have to use
both cubes all the time. So, the 7th day would be "07".
pf3

Partial preview of the text

Download logic building assignment and more Assignments Computer Programming in PDF only on Docsity!

Assignment # 1

For Logic Building Practice

Problem 1

  1. You have 2 drums of capacity
    • 8 litter
    • 5 litter And a resource of Oil, can you use these two drums to give 1 liter, 2litre, 3 - liter, 4 liter, and 6 liters and 7 liters to any customer. Note that there is no mark of liters on the drums.
  2. Now you have to measure again the same question: But you have 9 liters and 6 liters drums. Can you solve that same problem, if yes how? if no why? Problem 2 On your first day at NAMAL, the teacher suggested that it would be a good idea for each student to meet every other student in the class. The teacher said, "When you meet, please shake hands and introduce yourself by name." If there were 20 students in the class, how many total handshakes were there? What about if there are N students can you tell in terms of N what is the total count of shake- hands. Problem 3 If you were to construct a 8 x 8 chess board, how many squares (within that chess board) would there be in total? (64 is not the answer). You remember the 8 balls problem, now you have N balls you have to tell how many times you have to weigh at max to figure out which ball is the heavier one? Just a direction: First try to figure out, 9, 16, 21, 27, 30, 50, 81 and then you will see what is the pattern! Problem 4 You are given 2 eggs. You have access to a 100-story building. Eggs can be very hard or very fragile means it may break if dropped from the first floor or may not even break if dropped from 100th floor. Both eggs are identical. You need to figure out the highest floor of a 100-story building an egg can be dropped without breaking. The question is how many drops you need to make. You are allowed to break 2 eggs in the process. Problem 5 Divide $277 (in whole $ increments) into a number of bags so that I can ask for any amount between $1 and $277, and you can give me the proper amount by giving me a certain number of these bags without opening them. What is the minimum number of bags you will require? Problem 6 A corporate businessman has two cubes on his office desk. Every day he arranges both cubes so that the front faces show the current day of the month. What numbers are on the faces of the cubes to allow this? Note: You can't represent the day "7" with a single cube with a side that says 7 on it. You have to use both cubes all the time. So, the 7th day would be "07".

Problem 7 A pot contains 75 white beans and 150 black ones. Next to the pot is a large pile of black beans. A somewhat crazy cook removes the beans from the pot, one at a time, according to the following strange rule: He removes two beans from the pot at random. If at least one of the beans is black, he places it on the bean-pile and drops the other bean, no matter what color, back in the pot. If both beans are white, on the other hand, he discards both of them and removes one black bean from the pile and drops it in the pot. At each turn of this procedure, the pot has one less bean in it. Eventually, just one bean is left in the pot. What color is it? Problem 8 You wake up after your Titanic sank, and you find yourself on the bank of the sea, an island. Beside everything, what an island has (its natural beauty), there are people there too. You come to know that the people of this island are either liar (he may or may not lie) or trustworthy (always say the truth). You can ask them questions like who is a liar. And who is not? There are total of 100 people in this island. And you can ask as many questions as you want. The only information known is, that number of Trust-worthies is greater than liars. Any answer having greater than 500 questions is not worthy enough to be considered. Figure out who is a liar and who is a trustworthy person? Problem 9 So you have an infinite plane and lines, lines can intersect each other to make regions, e.g., 1 line will produce to regions, 2 lines 4. Can you tell with argument at maximum how many regions will be there if you have n lines? And why? (Any answer without why will be unacceptable). Problem 10

  • A duck is pursued by a fox, escapes to the center of a perfectly circular pond. The fox cannot swim and duck cannot take flight from the water. The fox is 4 times as faster than the duck. Assuming the fox and duck pursue optimal strategy, is it possible for the duck to reach the edge of the pond and fly away without being eaten? If so, how? (You can find its answer on the Internet very easily, you can use Internet but I would say first try for it and then go on finding it)
  • On what parameters (relation between their speeds) fox will always able to eat it, and on what factors duck will always escape. Problem 11 You have two strings, whose only known property is that when you light one either end of either string it takes exactly one hour to burn. The rate at which the strings will burn is completely random and each string is different. How do you measure 1.5 hours and 45 minutes? Problem 12 There are four numbers: 1, 2, 5, 10 that you have to carry in a boat across a river. Every time you may not carry more than two numbers, and the time of traveling is associated with the largest of two numbers. One number has to be in the boat during the return journey, which also defines the time for this trip. What is the minimum total time to carry all numbers from one bank to another?