Can such Puzzle solve through UNIX script? if yes, what could be the code?
This has been solve in C language. we were trying to solve this through shell but could not because of not able to pass 1st argument with multiple value. we are not expert in unix scripting. Below is the puzzle
John is a papaya merchant. He visits different papaya orchards and collects papayas from farmers in the fruit containers. Each farmer could provide different quantity of papayas. John is smart and labels the number of papayas collected in each container. All the containers are of the same size and capacity.
At the end of the day, when John returns from this fruit collection tour, he has to ensure that all the containers carry same number of papayas so that they can be subsequently shipped to his various distribution channels. It is important to equi-distribute the number of papayas in each container for efficient logistics and keep his distributors happy.
The question is – Given n containers with different number of papayas say q1, q2,..qn in each container, how many papayas will John have to move and what is the least possible number of moves it will take him to ensure that papayas are equally distributed. Obviously, he is tired from his day long work and he would prefer to move minimum possible papayas in least number of moves. (one move consists of transferring any number of papayas from one container to another one)
The input consists of number of papayas in each container separated by space.
Expected Output : Number of papayas moved and number of moves. (if it is not possible to equally distribute the papayas, then the output should be -1)
I have a number, say 174. I need to write bash code that will find the first larger number that ends in 99. That would be 199 in this case. If the number were 1263, I would be looking for 1299, for 175438, I would want 175499, etc.
If the numbers were always three digit, I could just grab the... (11 Replies)
Hey everybody, I've been searching google and these forums and have found some solutions to the issues I've been having today within the OLD Bourne Shell. I am following chapter 6 of the Guide to Unix using Linux 4th Edition.
I am working on some basic calculations with variables in the BASH... (3 Replies)
Hi
I am trying to calculate the rate at which something is happening.
I have 2 files- a1 and b1.
I want to calculate something like this
((wc -l a1)/(wc -l a1 + wc -l b1))*100 over a loop for different a and b.
Is this possible, help me out fellas.
Thanks a lot :) (5 Replies)
Have a bit complicated math query ..
Basically i am given a number which is > 50 ..
I am suppose to find the calculation to get a number which is equal or more than the input number and is also a multiple of any number between 20 - 30 .
For example .
Input number is 60 .
Now 20x3 =60 ... (2 Replies)
Hi Gurus,
I'm currently using HP-UX B.11.23.
I've a simple calculation script which performs the task below.
-> echo "240021344 / 1024 /1024" | bc
Output: 228
240021344 is KB value.
When I tried to perform the same calculate in Ms Excel, it produces a different result: 228.9021912.... (12 Replies)
Develop a grade calculating program. This program will process all students in the file. This program should neatly display each field of each student's record *and* adds the following items: Course Average and Letter Grade. The course average is calculated by the following weights: 50% for quiz... (7 Replies)
Hi All ,
I'm trying to do a simple math expression ...but unsuccessfull :-(
Anyone can help me?
days=23
amount=`expr ${days} / 30 \* -125`
echo $amount
but as result i got 0 when i expect 95.833333
Another question...how i can limit only to two or three decimal fields?
Thanks in... (1 Reply)
hello:
First I know the rules on Homework related questions,
I wrote my script, but I cannot seem to figure out how to do one math problem.
How do I take a zip code and seperate the idvidual digits?
I used the modulus expression and divided the number by 10 ^ n
but that only worked... (9 Replies)