Sponsored Content
Top Forums Shell Programming and Scripting How to write program that find winner who choose the smallest number. UNIX process? Post 302998567 by dantesma on Sunday 4th of June 2017 05:22:06 AM
Old 06-04-2017
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:

Code:
$ ./game 5
Game starts with 5 players
Player 3312 choose 4
Player 3314 choose 3
Player 3313 choose 2
Player 3315 choose 1
Player 3316 choose 5
Player 3315 win!

Please help me, to write a code because I am totally new in shell programming


Moderator's Comments:
Mod Comment Please use CODE tags as required by forum rules!

Last edited by RudiC; 06-04-2017 at 07:08 AM.. Reason: Added CODE tags.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Write a shell program to find the sum of alternate digits in a given 5-digit number

Hi Can any one please post the answer for the above program.................. (4 Replies)
Discussion started by: banta
4 Replies

2. Shell Programming and Scripting

checking the smallest and largest number

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)
Discussion started by: subin_bala
4 Replies

3. UNIX for Dummies Questions & Answers

How to print largest and smallest number.

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)
Discussion started by: amp10388
2 Replies

4. UNIX for Dummies Questions & Answers

Find what process on port number

Hi, I am on a Sun Solaris and I want to find out which process is allocated on a certain port. How can I do that? BR Andreas (4 Replies)
Discussion started by: mr_andrew
4 Replies

5. Shell Programming and Scripting

Find port number being used by a given process id

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)
Discussion started by: sunpraveen
3 Replies

6. Shell Programming and Scripting

Shell Script to Kill Process(number of process) Unix/Solaris

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)
Discussion started by: jonnyvic
2 Replies

7. Programming

Help with find highest and smallest number in a file with c

Input file: #data_1 AGDG #data_2 ADG #data_3 ASDDG DG #data_4 A Desired result: Highest 7 Slowest 1 code that I try but failed to archive my goal :( #include <stdio.h> (2 Replies)
Discussion started by: cpp_beginner
2 Replies

8. Shell Programming and Scripting

Print smallest negative number with corresponding index from a column

considering the following table: ID col1 col2 col3 col4 1 -16.06801249 13.49785832 -56.57087607 -27.00500526 2 -1.53315720 0.71731735 -42.03602078 -39.78554623 3 -1.53315190 0.71731587 -42.03601548 ... (3 Replies)
Discussion started by: Birda
3 Replies

9. Shell Programming and Scripting

Problem to print out record got smallest number in specific column

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)
Discussion started by: cpp_beginner
4 Replies

10. Shell Programming and Scripting

Problem facing to compare different column and print out record with smallest number

Hi, Input file 1 : 37170 37196 77 51 37174 37195 73 52 37174 37194 73 53 Desired Output file 1 : 37170 37196 77 51 Input file 2 : 37174 37195 73 0 37170 37196 77 0 Desired Output file 2 : 37174 37195 73 0 (1 Reply)
Discussion started by: cpp_beginner
1 Replies
between(6)							       Games								between(6)

NAME
between - a game about consciousness and isolation SYNOPSIS
between DESCRIPTION
Between is a video game written by Jason Rohrer about consciousness and isolation. Between is a multiplayer-only art game. As a result, some people like it, many people do not get it and some people hate it. Search the internet for the author's name and the game title to find some discussion about the game before dismissing it. Some sample discussions and reactions are listed below. You can play Between with a friend or stranger over the Internet. Both players will see a field, sky, clouds, a square structure and a shimmering tower. The interface reveals the initial controls (reference below). The players place red-green-blue blocks on the field and pile them upwards. Placing blocks over the shimmering tower causes pleasant tones while the colours match. Soon enough the players will not be able to match any more blocks with the complex patterns and colour variety in the tower. To the left is a bed indicating sleep. To the right is a bright room indicating wakefulness. Cycling through the dream and wakefulness states gives players three different realities in which to build the shimmering tower. Eventually in the state between dream and reality, mysterious interactions between the two players block placements and reality cycling patterns will result in blocks with new colours and patterns appearing on the field. These new blocks can then be used to match more and more of the shimmering tower over time... The most interesting part about this game is the emotions it evokes within the player of the game. The ultra-low-res pixel art helps here, by not being too distracting and by leaving plenty room for viewer interpretation. USAGE
Between has no command-line options. The left and right arrow keys move left and right. The spacebar is used to place or grab blocks. The b/n keys are used to change the colour of the placed blocks. The s/w keys are used to sleep/wake the player. The Esc key is used to quit the game. The game resolution and use of fullscreen or a window can be set by editing the files in /etc/between. SEE ALSO
The website: http://www.esquire.com/features/best-and-brightest-2008/rohrer-game http://www.destructoid.com/jason-rohrer-s-new-game-between-is-out-111382.phtml http://mile222.com/2008/11/jason-rohrers-latest-game-between-leaves-me-unenthused/ http://www.gamasutra.com/view/feature/3853/persuasive_games_disjunctive_play.php http://www.gamerswithjobs.com/node/42515 http://kotaku.com/5096755/disjunctive-play-and-otherness-between December 2010 between(6)
All times are GMT -4. The time now is 01:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy