The last C problem I need to do, and for me it's quite difficult and I'd like to learn how to do it. Thanks so much
Question 3: Juggl(ug)ing
A cookery set contains several jugs of different sizes, each of which has a known capacity in oz (fluid ounces).
There are no graduations on the jugs, so the only way to measure the liquid is by filling up a jug
completely, pouring as much liquid as possible from one jug into another or by emptying a jug. A step
consists of performing one of these three operations.
Initially all the jugs are empty. To measure n oz it is necessary to perform a sequence of steps and finish
with exactly n oz in one of the jugs.
For example, suppose we have two jugs: jug A holds 3 oz and jug B holds 5 oz.
• If we fill up jug B and then pour as much as possible from jug B into jug A, we would have (after 2
steps) 3 oz in jug A and 2 oz in jug B. This is one way to measure 2 oz.
• If we now empty jug A, pour the 2 oz from jug B into jug A, fill jug B and finally pour as much as
possible from jug B into jug A, we would finish (after 6 steps) with 3 oz in jug A and 4 oz in jug B.
We have now measured 4 oz.
3(a) [ 23 marks ]
Write a program that, given the capacities of several jugs, determines the shortest
number of steps necessary to measure n oz.
The input will consist of two lines. The first line will contain two integers j (1 " j " 3)
then n (1 " n " 250), indicating the number of jugs and the required amount to
measure respectively. The second line will contain j integers, each between 1 and
250 inclusive, indicating the capacity of the jugs.
You should output a single integer giving the minimum number of steps necessary to
measure n oz.
Your program will only be asked to measure amounts that are possible.

2. How about you do your own homework instead of coming here and expecting us to do it for you? If you have something you've already done, then post it in code tags.

C Board - Announcements in Forum : General Programming Boards

3. Originally Posted by rags_to_riches
How about you do your own homework instead of coming here and expecting us to do it for you? If you have something you've already done, then post it in code tags.

C Board - Announcements in Forum : General Programming Boards
I'm sorry but I am not asking ANYONE TO DO MY HOMEWORK, merely to help me and possibly point me in the right direction, SORRY if I am not as good as you but I am sure you were at the low level I am now at some point and would have been very grateful if someone helped you and explained something you do not understand to you. That is what I have understood this forum is for, and am seeking engaged and productive talk with experienced programmers who I am sure would enjoy helping an inexperienced and begginer programmer like myself who is willing to learn and get better. Thank you for your productive input

4. We're willing to help you with what YOU have put some effort into. We're NOT willing to do all the work for you. You've yet to show an effort except to cut and paste your assignment into as post with "I don't understand".

Ah, so this is the British Informatics Olympiad (warning: PDF) exam, which just came out today.

5. Your link is last year's paper and not an assignement I am doing it on my own and it is not compulsory since no one is asking me to do it, I am doing the 2011 one (current one nobody knows whats in it) in 2 weeks so am attempting to have a stab at past questions to somewhat prepare myself (although there is not much hope) and try to do at least 1 question in the actual thing... I am not trying to cheat merely preparing myself for the real thing whos content is unknown to me and my friend who is also preparing for it. I am working on it and shall post whatever non functioning code I have to show my attempts.

6. Originally Posted by alexbcg
Your link is last year's paper and not an assignement I am doing it on my own and it is not compulsory since no one is asking me to do it, I am doing the 2011 one (current one nobody knows whats in it) in 2 weeks so am attempting to have a stab at past questions to somewhat prepare myself (although there is not much hope) and try to do at least 1 question in the actual thing... I am not trying to cheat merely preparing myself for the real thing whos content is unknown to me and my friend who is also preparing for it. I am working on it and shall post whatever non functioning code I have to show my attempts.
We are looking forward to it. No really, I am not being ironic, that is the right attitude to have. And, if you happen to participate in the 2012 one, you may want to start preparing for it even earlier. I remember I used to go to the Olympiads in my high school years... ahhh the good times.

7. An interesting project. I don't know of any algorithm that would solve it to find the minimum sequence of moves. Therefore you're likely going to end up exploring all possible permutations of bucket[n] fills and empty to bucket[other than n]... and keeping track of how many oz in each bucket. If one of the buckets happens to contain the desired amount, you stop.

8. I would probably use a dynamic programming approach to this: Dynamic programming - Wikipedia, the free encyclopedia. It wont have to be exhaustive, but will nevertheless be computationally complex.