|
|
|
|
Joined: Sep 2003
Posts: 120
Vogon poet
|
OP
Vogon poet
Joined: Sep 2003
Posts: 120 |
I was wondring, I am trying to get four number between 1-6 and want to drop the lowest number. Any hints on how I do this? I know how to get the random numbers, using the $rand thing, but how can I drop the lowest?
|
|
|
|
|
Joined: Jan 2003
Posts: 2,125
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 2,125 |
$deltok($sorttok($eval($str($!rand(1,6) $+ $chr(32),4),2),32,n),1,32)
|
|
|
|
|
Joined: Sep 2003
Posts: 120
Vogon poet
|
OP
Vogon poet
Joined: Sep 2003
Posts: 120 |
Thanks. Is there a way of presenting it in this fashion:
#1 + #2 + #3 + #4 = (sum of three highest #)
Is this possible?
|
|
|
|
|
Joined: Jan 2003
Posts: 2,125
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 2,125 |
I didn't really understand what you want. In any case, the key part of the solution is $sorttok() which allows you sort the numbers. Then you can drop the 1st number in the list, which is the lower too. So, something like: tokenize 32 $sorttok($eval($str($!rand(1,6) $+ $chr(32),4),2),32,n)
$1 + $2 + $3 + $4 = $calc($2 + $3 + $4)
|
|
|
|
|
Joined: Sep 2003
Posts: 120
Vogon poet
|
OP
Vogon poet
Joined: Sep 2003
Posts: 120 |
okay with this code: alias statbuy {
msg # $sorttok($eval($str($!rand(1,6) $+ $chr(32),4),2),32,n)$1 $2 $3 $4 = $calc($2 + $3 + $4)
}I got this in four tries: <Gararion> 1 2 3 4 = 0 <Gararion> 1 4 4 5 = 0 <Gararion> 1 4 4 6 = 0 <Gararion> 2 3 4 6 = 0 What I wanted was this: <Gararion> 1 2 3 4 = 9<Gararion> 1 4 4 5 = 13 <Gararion> 1 4 4 6 = 14 <Gararion> 2 3 4 6 = 13 Is this better explained? Note that my additons only add the last three numbers, those being the hieghest numbers.
|
|
|
|
|
|
DaveC
|
|
DaveC
|
try...
alias statbuy {
tokenize 32 $sorttok($eval($str($!rand(1,6) $+ $chr(32),4),2),32,n)
msg # $1 $2 $3 $4 = $calc($2 + $3 + $4)
}
My Personal ^5 to Querty for the great method of getting the 4 random numbers, ill use that myself for things from now on.
|
|
|
|
|
Joined: Sep 2003
Posts: 120
Vogon poet
|
OP
Vogon poet
Joined: Sep 2003
Posts: 120 |
|
|
|
|
|
|
|