Poker: calc profit in tournaments


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Poker: calc profit in tournaments
# 1  
Old 03-31-2010
Poker: calc profit in tournaments

Imagine that you play poker and the file 1.txt is your buy-in, and in 2.txt is your gains. I want to know the tournament that have more proffit and less proffit.

1.txt
Code:
aa:1000
bb:2000
cc:3000
dd:4000
ee:5000

2.txt
Code:
aa:0
bb:1000
cc:1500
dd:3000
ee:2000

Result: dd more profit; aa less profit

Last edited by vgersh99; 03-31-2010 at 12:57 PM.. Reason: code tags, PLEASE!
# 2  
Old 03-31-2010
Is this homework?

Assuming the files always have identical lines, i.e. same games in the same order:

Code:
#!/bin/bash

# open files
exec 5<1.txt
exec 6<2.txt

while true
do
        read -d ':' GAME PROFITA <&5 || break
        read -d ':' GAME PROFITB <&6 || break

        echo "${GAME}:  profit $((PROFITB-PROFITA))"
done

# close files
exec 5>&-
exec 6>&-


Last edited by Corona688; 03-31-2010 at 01:04 PM..
# 3  
Old 03-31-2010
No. Iam only trying to calc easy my profit when I make bets online in bwin and I give the example of poker that is more easy to understand i think
# 4  
Old 03-31-2010
Sorry, then. That set off all my homework alarms for some reason. Smilie Did my solution work for you?
# 5  
Old 04-01-2010
Lately, i was working with 2 files but i was thinking and, why iam I working with 2 files??? Lets take to one file only.

Code:
aa:1000:0
bb:2000:1000
cc:3000:1500
dd:40003000
ee:5000:2000

so.. to maake my profit is only the math the $2-$3. isnt?

Last edited by zaxxon; 04-01-2010 at 08:03 AM.. Reason: use code tags please, ty. last warning
# 6  
Old 04-12-2010
Sorry, didn't see your reply. Yes, one file makes it much easier and gets rid of many potential errors.

Code:
#!/bin/bash

while IFS=":" read NAME A B
do
        echo "Profit for ${NAME}:$((A-B))"
done < filename

Login or Register to Ask a Question

Previous Thread | Next Thread

2 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

date calc

Hi, I need subtract two date values (which are in day of the year format) and the output would give the remaining days. using the command date +"%j" i would get today's 'day of the year' i.e., > date +"%j" 256 Next, i need to take input of a previous date in the format 09/05/2012 and then... (4 Replies)
Discussion started by: sam_bd
4 Replies

2. Post Here to Contact Site Administrators and Moderators

Non Profit UNIX Foundation

I'm considering asking Silk Road to pay an attorney to set up a non-profit public UNIX foundation (and perhaps asking the trustee to donate this domain to that non-profit foundation). A public foundation could receive tax deductable contributions and we could use the funds to build some of the... (5 Replies)
Discussion started by: Neo
5 Replies
Login or Register to Ask a Question