
Just for Fun - Lottery Numbers
k, this won't give you the next winning numbers for the lottery so forget that.
What you need is a text list of the numbers (in this case PowerBall) that has 5 regular numbers and 1 "hot ball" number per line. The script will output the number of times a number has been hit from the list. Up to you if you want to pick the highest numbers hit, or the lowest in hope that it is their "turn".
Code:
# setup two static arrays of size of 60, you could use dynamic arrays if you wanted to
setArray $number 60
setArray $hot 60
:begin
setVar $nextLine 1
# read the first line of our data file
read "lottery.txt" $line 1
# setup while/end loop to detect the file EOF
while ($line <> EOF)
# setup counter for parsing the line read from a file
setVar $i 1
# we know there are 6 numbers in the line so while $i <= 6
while ($i <=6)
# get the $i position word of the line
getword $line $num $i
# if $i = 6 we know it is the "hot ball" so store it in that array
if ($i = 6)
add $hot[$num] 1
else
# wasn't the "hot ball" so it is one of the "regular" numbers and store in that array
add $number[$num] 1
end
# increment our counter for parsing the line
add $i 1
end
# add 1 to our file line counter
add $nextLine 1
# read the new line
read "lottery.txt" $line $nextLine
end
# reset $i to 1 so we can output our results
setVar $i 1
while ($i <= 60)
# write our results to a new file
write "loteryResults.txt" $i & "," & $number[$i] & "," & $hot[$i]
add $i 1
end
# win the lottery and send Promethius 5% (I'm not greedy)
If you want to extend this a bit, you could add a sort routine to sort the output base on the number of hits and split out the "normal" vs "hot ball" numbers. Add a timer to the start and end of the sort and get some information on performance although an array of 60 should be fairly quick to sort.
[Edit] The pre /pre codes I was using made it hard to read so I've switch to the code /code tags. [/edit]
_________________
/ Promethius / Enigma / Wolfen /
"A man who has no skills can be taught, a man who has no honor has nothing."