How to write program that find winner who choose the smallest number. UNIX process?
In the game of “Unique”, multiple players privately choose an integer. They then reveal
their choice. The winner is the player who chose the smallest unique number. The
game is considered a draw if no unique integer was chosen.
You would write a program that simulate such a game according to the followings
1. The parent process fork player (child) processes (up to maximum of 10
players). It then waits for each of the child processes to return an integer.
2. The players (child processes) will randomly pick an integer between 1 to 5, and
return the choices to the parent.
3. Parent process determines the winner based on the choice returned by the
players (child processes). Parent process then print out the winner’s PID and
inform all child processes to terminate, before it terminates. If it is a draw, parent
process shall inform all the child processes (players) to choose another integer.
4. Repeat steps 2 and 3 as many times as required until a winner can be
determined.
Example of output:
Please help me, to write a code because I am totally new in shell programming
Moderator's Comments:
Please use CODE tags as required by forum rules!
Last edited by RudiC; 06-04-2017 at 07:08 AM..
Reason: Added CODE tags.
Do not post classroom or homework problems in the main forums. Homework and coursework questions can only be posted in this forum under special homework rules.
Please review the rules, which you agreed to when you registered, if you have not already done so.
More-than-likely, posting homework in the main forums has resulting in a forum infraction. If you did not post homework, please explain the company you work for and the nature of the problem you are working on.
Hi,
Anybody know how to print out the record that shown smallest number among column 3 and column 4
Case 1 Input :
37170 37196 77 51
37174 37195 73 52
37174 37194 73 53
Case 1 Output :
37170 37196 77 51
Case 2 Input :
469613 469660 73 ... (4 Replies)
Hi Experts, we do have a shell script for Unix Solaris, which will kill all the process manullay, it used to work in my previous env, but now it is throwing this error.. could some one please help me to resolve it
This is how we execute the script (and this is the requirement) ... (2 Replies)
Unix gurus,
I have a requirement wherein I want to find the port number for a given process id.
Is it possible? If so how?
TIA,
Regards,
Praveen (3 Replies)
Hey. This is pretty easy stuff but I'm learning the basics of Unix at the moment so keep that in mind. I have to:
1) Write a C-shell script to monitor user activity on the server for 13 minutes.
2) Then print the smallest and largest number of users during these 13 minutes.
I have this:
1)... (2 Replies)
Hi All,
My script is reading a log file line by line
log file is like ;
19:40:22 :INFO Total time taken to Service External Request---115ms
19:40:25 DEBUG : Batch processed libdaemon.x86_64 0-0.10-5.el5 - u
19:40:22 INFO Total time taken to Service External Request---20ms
19:40:24... (4 Replies)