Sponsored Content
Top Forums Shell Programming and Scripting comparing two arrays or strings in bash Post 302205977 by new2Linux on Monday 16th of June 2008 04:36:14 PM
Old 06-16-2008
comparing two arrays

actually i need to do all what you have mentioned,

- user 1 enter a word
- user2 try to guess by entering a character,
- checking if this character matches any character in the word entered by
player1.
- in case matches any of the characters it displays the character in the
right place.
for example:
player one enter a word:
hello
player two try to guess a word from 5 characters, enter a letter:
-----
player two enters h

output: h----
player 2 enters L :
output : h-ll-

so forth. im having trouble checking comparing what player 2 enters with every single character in the word entered by player 1.
Thanks again.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Comparing Arrays?

Is there anyway that I can compare two Arrays to see if any new strings have been added in them? eg: Array 1: Joe Bob Jane Array 2: Joe Bob Jane Greg It would then output a new array with the changes: Array 3: Greg I'm not very good at shell scripting, and my google and forum searches... (4 Replies)
Discussion started by: blckleprd
4 Replies

2. Shell Programming and Scripting

Comparing arrays in perl

Hi all, I am trying to compare two arrays in perl using the following code. foreach $item (@arrayA){ push(@arrayC, $item) unless grep(/$item/, @arrayB); ... (1 Reply)
Discussion started by: chriss_58
1 Replies

3. Shell Programming and Scripting

PERL: simple comparing arrays question

Hi there, i have been trying different methods and i wonder if somebody could explain to me how i would perform a comparison on two arrays for example my @array1 = ("gary" ,"peter", "paul"); my @array2 = ("gary" ,"peter", "joe"); I have two arrays above, and i want to something like this... (5 Replies)
Discussion started by: hcclnoodles
5 Replies

4. UNIX for Dummies Questions & Answers

Strings in arrays

Hi There, Code: Number=10 i=1 while do echo "$i" Check=`find $viewing -name $File_Pattern -type f -Print` i=`expr ${i} + 1` done Unable to store the values in variable 'Check', when i display i am getting Check nothing... (1 Reply)
Discussion started by: Naveen_5960
1 Replies

5. Shell Programming and Scripting

How to make arrays from strings in bash?

Hey all, This is my first post, and I am relatively new to linux/unix scripts. I am writing a bash script in which I am trying to extract one line from another file and parse specific words from the line into an array. So for example, I have a file called SortScans in which the first 5 lines... (9 Replies)
Discussion started by: camocazi
9 Replies

6. UNIX for Dummies Questions & Answers

Comparing lists.. Arrays maybe?

Problem Part 1. Gather data from linux server and output to a file named data_DDMMYY Output file must contain the file name and size Part 2. Compare todays data_DDMMYY to yesterdays data_DDMMYY and output results to a file named difference_DDMMYY Output file must show the difference in... (3 Replies)
Discussion started by: Aussiemick
3 Replies

7. Shell Programming and Scripting

Using arrays in bash using strings to bash built-in true

I have the following code and for some reason when I call the program using /home/tcdata/tatsh/trunk/hstmy/bin/bash/raytrac.bash --cmod=jcdint.cmod I get hasArgument = hasArgument = true Somehow the array element is returning even though I have not chosen the option. ... (41 Replies)
Discussion started by: kristinu
41 Replies

8. Shell Programming and Scripting

Comparing 2 arrays but ignoring certain patterns

I'm trying to compare 2 array and print the difference at a 3rd file. However how am i going to compare this 2 arrays by ignoring certain patterns: For example: 1st array contains: ctahci cptcsa0 ctsata:25:seed cptcsa1:50:seed ctsata_1:25:seed 2nd array contains: cptcsa0 ctsata... (0 Replies)
Discussion started by: hongping
0 Replies

9. Shell Programming and Scripting

awk arrays comparing multiple columns across two files.

Hi, I'm trying to use awk arrays to compare values across two files based on multiple columns. I've attempted to load file 2 into an array and compare with values in file 1, but success has been absent. If anyone has any suggestions (and I'm not even sure if my script so far is on the right lines)... (4 Replies)
Discussion started by: hubleo
4 Replies

10. Shell Programming and Scripting

Bash - Comparing 2 xml strings masking certain fields

Would like to compare 2 XML Strings which has certain known fields changed. For example, Date field will always have differences. When comparing both strings, skip/mask all the occurring Date Field's `DtField1` and `DtField2` Note: these are not formatted xml format. File1: ... (1 Reply)
Discussion started by: Sajjadmehdi
1 Replies
NASH(1) 							   lrslib 0.42b 							   NASH(1)

NAME
nash - find nash equilibria of two person noncooperative games SYNOPSIS
setupnash input game1.ine game2.ine setupnash2 input game1.ine game2.ine nash game1.ine game2.ine 2nash game1.ine game2.ine DESCRIPTION
All Nash equilibria (NE) for a two person noncooperative game are computed using two interleaved reverse search vertex enumeration steps. The input for the problem are two m by n matrices A,B of integers or rationals. The first player is the row player, the second is the column player. If row i and column j are played, player 1 receives Ai,j and player 2 receives Bi,j. If you have two or more cpus available run 2nash instead of nash as the order of the input games is immaterial. It runs in parallel with the games in each order. (If you use nash, the program usually runs faster if m is <= n , see below.) The easiest way to use the program nash or 2nash is to first run setupnash or ( setupnash2 see below ) on a file containing: m n matrix A matrix B eg. the file game is for a game with m=3 n=2: 3 2 0 6 2 5 3 3 1 0 0 2 4 3 % setupnash game game1 game2 produces two H-representations, game1 and game2, one for each player. To get the equilibria, run % nash game1 game2 or % 2nash game1 game2 Each row beginning 1 is a strategy for the row player yielding a NE with each row beginning 2 listed immediately above it.The payoff for player 2 is the last number on the line beginning 1, and vice versa. Eg: first two lines of output: player 1 uses row probabilities 2/3 2/3 0 resulting in a payoff of 2/3 to player 2.Player 2 uses column probabilities 1/3 2/3 yielding a payoff of 4 to player 1. If both matrices are nonnegative and have no zero columns, you may instead use setupnash2: % setupnash2 game game1 game2 Now the polyhedra produced are polytopes. The output of nash in this case is a list of unscaled probability vectors x and y. To normalize, divide each vector by v = 1^T x and u=1^T y.u and v are the payoffs to players 1 and 2 respectively. In this case, lower bounds on the payoff functions to either or both players may be included. To give a lower bound of r on the payoff for player 1 add the options to file game2 (yes that is correct!)To give a lower bound of r on the payoff for player 2 add the options to file game1 minimize 0 1 1 ... 1 (n entries to begiven) bound 1/r; ( note: reciprocal of r) If you do not wish to use the 2-cpu program 2nash, please read the following. If m is greater than n then nash usually runs faster by transposing the players. This is achieved by running: % nash game2 game1 If you wish to construct the game1 and game2 files by hand, see the lrslib user manual[1] SEE ALSO
For information on H-representation file formats, see the man page for lrslib or the lrslib user manual[2] NOTES
1. lrslib user manual http://cgm.cs.mcgill.ca/%7Eavis/C/lrslib/USERGUIDE.html#Nash%20Equilibria 2. lrslib user manual http://cgm.cs.mcgill.ca/%7Eavis/C/lrslib/USERGUIDE.html#File%20Formats July 2009 03/30/2011 NASH(1)
All times are GMT -4. The time now is 11:14 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy