Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

hma.lua [PART II]

Name: Anonymous 2010-10-07 22:14


hma = math.random(1, 1000)
if hma < 500 then
   print "HAX MY ANUS!"
else
   print "HAX MY ANUS!"
end

Name: Anonymous 2010-10-17 13:48

>>9 is probably more comfortable with languages like Python, where ranges are half-inclusive (e.g. Python's range(1, 5) returns [1, 2, 3, 4] and notably not 5). Lua isn't one of these languages, so >>1's code will return 1000 values, and not 999 as >>9 seems to expect. As for the actual range and odds of each branch, the split is between values 1...499 and 500...1000, which are respectively 499 and 501 elements. Therefore, the two branches have (assuming a completely fair random algorithm) 49.9% and 50.1% execution probability.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List