Script to divide

J

Jeff

Ok gang. Here is what I have. I am using asp with Access DB on a microsoft
server.

I don't know if a premade script exists out there, but I couldn't find it.
I am looking for a script to use for my golf team. We have In-House Tourneys
that we play, and I want to show earnings won for the tourney, kind of like
the PGA golf does. What this script would have to do, is see how many
players finished the tourney, and divide the total (which would be
$1,000,000 cyberbucks) per event. I would need it to give first the most,
second less, and so on. But the thing that I am unable to do, is determine
the breakdown with different amount of finishers.

If 4 finished all the time, the formula would be easy, but sometimes there
are as many as 20 that finish.

Does this make sense? If someone wants to email me about this they can. It
is kind of hard to describe what I need. (e-mail address removed)--- (take out
the -- on both ends) is my email.
Thanks
Bam
 
L

Larry Bud

the PGA golf does. What this script would have to do, is see how many
players finished the tourney, and divide the total (which would be
$1,000,000 cyberbucks) per event. I would need it to give first the most,
second less, and so on. But the thing that I am unable to do, is determine
the breakdown with different amount of finishers.

If 4 finished all the time, the formula would be easy, but sometimes there
are as many as 20 that finish.

This really isn't an ASP question, but I'll give it a go.

It really depends on how you want to divide the pot up. Do you want to
give the winner half the pot, 1/3 of the pot, 1/4 of the pot??

You would always go in halves, no matter how many people are "in the
money".

Winner gets 1/2, 2nd place gets half of what's left (so really, 1/4),
3rd place gets have of what's left after that, (1/8), etc. The last
guy gets whatever is remaining.

If two or more people tie, those places that they finished have the
money averaged out for those places.
 
B

Bob Barrows [MVP]

Jeff said:
Ok gang. Here is what I have. I am using asp with Access DB on a
microsoft server.

I don't know if a premade script exists out there, but I couldn't
find it. I am looking for a script to use for my golf team. We have
In-House Tourneys that we play, and I want to show earnings won for
the tourney, kind of like the PGA golf does. What this script would
have to do, is see how many players finished the tourney, and divide
the total (which would be $1,000,000 cyberbucks) per event. I would
need it to give first the most, second less, and so on. But the thing
that I am unable to do, is determine the breakdown with different
amount of finishers.

If 4 finished all the time, the formula would be easy, but sometimes
there are as many as 20 that finish.

Does this make sense? If someone wants to email me about this they
can. It is kind of hard to describe what I need.
(e-mail address removed)--- (take out the -- on both ends) is my email.
Thanks
Bam
We don't do email support. What you need to do is describe the structures of
the relevant tables (datatypes, fieldnames - only show the relevant fields),
show us some sample data in tabular format, and show us the results you wish
to retrieve from that sample data - also in tabular format.

Bob Barrows
 
E

Evertjan.

Jeff wrote on 06 dec 2005 in microsoft.public.inetserver.asp.general:
Ok gang. Here is what I have. I am using asp with Access DB on a
microsoft server.

I don't know if a premade script exists out there, but I couldn't find
it. I am looking for a script to use for my golf team. We have
In-House Tourneys that we play, and I want to show earnings won for
the tourney, kind of like the PGA golf does. What this script would
have to do, is see how many players finished the tourney, and divide
the total (which would be $1,000,000 cyberbucks) per event. I would
need it to give first the most, second less, and so on. But the thing
that I am unable to do, is determine the breakdown with different
amount of finishers.

If 4 finished all the time, the formula would be easy, but sometimes
there are as many as 20 that finish.

Does this make sense? If someone wants to email me about this they
can. It is kind of hard to describe what I need.
(e-mail address removed)--- (take out the -- on both ends) is my email.

For that amount of money,
you could easily spend 1% for a professional programmer?
 
L

Larry Bud

Evertjan. said:
Jeff wrote on 06 dec 2005 in microsoft.public.inetserver.asp.general:


For that amount of money,
you could easily spend 1% for a professional programmer?

They're "cyberbucks", not greenbacks!
 
L

Larry Bud

Jeff said:
Ok gang. Here is what I have. I am using asp with Access DB on a microsoft
server.

I don't know if a premade script exists out there, but I couldn't find it.
I am looking for a script to use for my golf team. We have In-House Tourneys
that we play, and I want to show earnings won for the tourney, kind of like
the PGA golf does. What this script would have to do, is see how many
players finished the tourney, and divide the total (which would be
$1,000,000 cyberbucks) per event.

Here's some code I whipped up that you can adapt for database use.

Note the line:
place_pot=int(ra*2/3)
You can change the ratio to suit your needs, but 2/3 seems to be pretty
fair.

<%
num_players=request.form("num_players")
total_pot=request.form("total_pot")
%> <html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<title>Purse</title>
<meta name="Microsoft Theme" content="tacnet-blue 110, default">
</head>

<body>

<%if num_players="" then%>
<form method="POST" action="--WEBBOT-SELF--" name="theform1">
<p># of players: <input type="text" name="num_players" size="20"></p>
<p>Total pot: <input type="text" name="total_pot" size="20">
<input type="submit" value="Submit" name="B1"></p>
</form>
<%else%>
<table cellspacing="0" cellpadding="3">
<tr>
<td><b>Place</b></td>
<td><b>Player</b></td>
<td><b>Amount</b></td>
</tr>
<%
ra=total_pot
for i=1 to num_players-1
place_pot=int(ra*2/3)
ra=ra-place_pot
%>
<tr>
<td><%=i%></td>
<td><%=chr(i+64)%></td>
<td align="right"><%=place_pot%></td>
</tr>
<%next%>
<tr>
<td><%=i%></td>
<td><%=chr(i+64)%></td>
<td align="right"><%=ra%></td>
</tr>
</table>
<%end if%>

</body>

</html>
 
J

Jeff

LOL. Surely I wouldn't actually PAY that amount. And yes, I will stop
calling you shirley.

Anyway, thanks Larry, this gives me a great starting point to go by.
Bam
 
L

Larry Bud

Jeff said:
Ok. I am using 2/5, which is 40%. However, the last place person keeps
coming up with more than next to last. Test it here:
http://www.gig-golf.com/purse.asp
Is weird
I guess maybe it is giving the remaining amount to the guy in last place?

Right, that's what it's doing.

Anything less than 1/2 ratio will give the last place guy more than the
2nd to last.

I suppose you could do it differently. For example, let's say there
are 10 "in the money "places.

1+2+3...+10=55

For easy math, lets say the pot is 1000

1000/55=18.181818. Call this finalplace

Take the place # of places+1-finish place * final place

1st=$182
2nd=$164
3rd=$145
4th=127

etc.

You need to decide how you want the money divided up in the first
place, then develop a formula based on that. I've never studied the
PGA money THAT closely to see if they have a set formula, but it could
be a tournament by tournament decision. It certainly is for non-pga
events such as the Masters or the US Open.
 
L

Larry Bud

Jeff said:
Ok. I am using 2/5, which is 40%. However, the last place person keeps
coming up with more than next to last. Test it here:
http://www.gig-golf.com/purse.asp
Is weird
I guess maybe it is giving the remaining amount to the guy in last place?

You know what you could also do, is keep the ratio going all the way
through last place, then whatever is left over, give it to the first
place guy, or spread it equally to all the other players.

Like this:

<%
num_players=request.form("num_players")
total_pot=request.form("total_pot")
%>
<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<title>New Page 1</title>
<meta name="Microsoft Theme" content="tacnet-blue 110, default">
</head>

<body>
<%if num_players="" then%>
<form method="POST" action="--WEBBOT-SELF--" name="theform1">
<p># of players: <input type="text" name="num_players" size="20"></p>
<p>Total pot: <input type="text" name="total_pot" size="20">
<input type="submit" value="Submit" name="B1"></p>
</form>
<%else%>
<table cellspacing="0" cellpadding="3">
<tr><td><b>Place</b></td><td><b>Player</b></td><td><b>Amount</b></td></tr>
<%
ra=total_pot
for i=1 to num_players
place_pot=int(ra*2/5)
ra=ra-place_pot
%>
<tr><td><%=i%></td><td><%=chr(i+64)%></td><td
align="right"><%=place_pot%></td></tr>

<%next%>

</table>
Amount left over: <%=ra%>
<%end if%>

</body>

</html>
 
L

Larry Bud

Jeff said:
LOL. Surely I wouldn't actually PAY that amount. And yes, I will stop
calling you shirley.

Anyway, thanks Larry, this gives me a great starting point to go by.

Also, for ties, you're going to have to tweak the code a bit.
 
E

Evertjan.

Larry Bud wrote on 06 dec 2005 in
microsoft.public.inetserver.asp.general:
Right, that's what it's doing.
Anything less than 1/2 ratio will give the last place guy more than
the 2nd to last.

I suppose you could do it differently. For example, let's say there
1+2+3...+10=55
For easy math, lets say the pot is 1000
1000/55=18.181818. Call this finalplace
Take the place # of places+1-finish place * final place

1st=$182
2nd=$164
3rd=$145
4th=127

You need to decide how you want the money divided up in the first
place, then develop a formula based on that. I've never studied the
PGA money THAT closely to see if they have a set formula, but it could
be a tournament by tournament decision. It certainly is for non-pga
events such as the Masters or the US Open.


<script type='text/vbscript'>

set response = document ' Using IE-vbs as ASP-vbs

function calculate (numberOfWinners,amountToBeDevided)
parts = 0
for n=1 to numberOfWinners
parts = parts + n^2
next
partAmount = amountToBeDevided/parts
for n=1 to numberOfWinners
t = "Number "&n&" gets $ "
t=t&formatnumber((numberOfWinners-n+1)^2*partAmount,2)
response.write t & "<br>"
next
response.write "=====================<br>"
end function

calculate 1, 1000
calculate 2, 1000
calculate 6, 140000
calculate 30, 100000

</script>
 
J

Jeff

I kind of like the idea of giving it to the first place winner. Good idea.
Thanks again for the reply bud

Bam
 
L

Larry Bud

set response = document ' Using IE-vbs as ASP-vbs

function calculate (numberOfWinners,amountToBeDevided)
parts = 0
for n=1 to numberOfWinners
parts = parts + n^2
next
partAmount = amountToBeDevided/parts
for n=1 to numberOfWinners
t = "Number "&n&" gets $ "
t=t&formatnumber((numberOfWinners-n+1)^2*partAmount,2)
response.write t & "<br>"
next
response.write "=====================<br>"
end function

calculate 1, 1000
calculate 2, 1000
calculate 6, 140000
calculate 30, 100000

</script>


Now you're talkin'. And one could change the power of the function
from ^2, to ^3 or higher if they want to front load the prize money to
the higher places.
 
E

Evertjan.

Larry Bud wrote on 06 dec 2005 in
microsoft.public.inetserver.asp.general:
Now you're talkin'. And one could change the power of the function
from ^2, to ^3 or higher if they want to front load the prize money to
the higher places.

I felt obliged, after teasing you. ;-}


function calculate (numberOfWinners, amountToBeDevided, power)
parts = 0
for n=1 to numberOfWinners
parts = parts + n^power
next
partAmount = amountToBeDevided/parts
for n=1 to numberOfWinners
t = "Number "&n&" gets $ "
t=t&formatnumber((numberOfWinners-n+1)^power*partAmount,2)
response.write t & "<br>"
next
response.write "=====================<br>"
end function

calculate 10, 1000, 3
 
C

Chris Hohmann

Jeff said:
Ok gang. Here is what I have. I am using asp with Access DB on a microsoft
server.

I don't know if a premade script exists out there, but I couldn't find it.
I am looking for a script to use for my golf team. We have In-House
Tourneys that we play, and I want to show earnings won for the tourney,
kind of like the PGA golf does. What this script would have to do, is see
how many players finished the tourney, and divide the total (which would
be $1,000,000 cyberbucks) per event. I would need it to give first the
most, second less, and so on. But the thing that I am unable to do, is
determine the breakdown with different amount of finishers.

If 4 finished all the time, the formula would be easy, but sometimes there
are as many as 20 that finish.

Does this make sense? If someone wants to email me about this they can. It
is kind of hard to describe what I need. (e-mail address removed)--- (take out
the -- on both ends) is my email.
Thanks
Bam
Here's a proof of concept that makes use of the formula for geometric
series.

<%
Sub ShowPayouts (pot, places, step)
Dim n : n = places - 1
Dim x : x = 1 + step
Dim sum : sum = (1.0 - x ^ (n + 1))/(1.0 - x)
Dim i
For i = n to 0 step -1
Response.Write places - i & " : " & pot * x ^ i / sum & "<br>"
Next
End Sub
ShowPayouts 1000000, 20, .4
%>

Notes:
1. I got the formula from this page:
http://en.wikipedia.org/wiki/Geometric_series

2. You weren't clear about what 40% means. I assumed it to mean a 40% bump
in payout from place to place, i.e.. 1st place pays 40% more than 2nd place,
2nd place pays 40% more than 3rd place, etc...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top