मोड्युल:Random

मैथिली विकिपिडियासँ, एक मुक्त विश्वकोश
Jump to navigation Jump to search
मोड्यूल परिचयपृष्ठ[निर्मित करी]
local p = {}
local q = {}
local r = {}
local s = {}
local t = {}
local u = {}
local v = {}
local x = {}
local multiplier = 179
local minnumber = 19
local maxnumber = 28

local idp = 3

function p.round(p, idp)
math.randomseed(os.time())
p = (math.random()*multiplier*8/8)
if p <=maxnumber then p = (maxnumber - p) + p + 14 end
  local mult = 10^(idp or 0)
  return math.floor(p * mult + 0.5) / mult
  end

function p.round1(q, idp)
math.randomseed(os.time())
q = (math.random()*multiplier*7/8)
if q <=maxnumber then q = (maxnumber - q) + q + 12 end
  local mult = 10^(idp or 0)
  return math.floor(q * mult + 0.5) / mult
  end

function p.round2(r, idp)
math.randomseed(os.time())
r = (math.random()*multiplier*6/8)
if r <=minnumber then r = (minnumber - r) + r + 10 end
if r == q then q = q + 1 end
  local mult = 10^(idp or 0)
  return math.floor(r * mult + 0.5) / mult
end

function p.round3(s, idp)
math.randomseed(os.time())
s = (math.random()*multiplier*5/8)
if s <=minnumber then s = (minnumber - s) + s + 8 end
if s == r then r = r + 1 end
  local mult = 10^(idp or 0)
  return math.floor(s * mult + 0.5) / mult
end

function p.round4(t, idp)
math.randomseed(os.time())
t = (math.random()*multiplier*4/8)
if t <=minnumber then t = (minnumber - t) + t + 6 end
if t == s  then s = s + 1 end
  local mult = 10^(idp or 0)
  return math.floor(t * mult + 0.5) / mult
end

function p.round5(u, idp)
math.randomseed(os.time())
u = (math.random()*multiplier*3/8)
if u <=minnumber then u = (minnumber - u) + u + 4 end
if u == t  then t = t + (minnumber/2) end
  local mult = 10^(idp or 0)
  return math.floor(u * mult + 0.5) / mult
end

function p.round6(v, idp)
math.randomseed(os.time())
v = (math.random()*multiplier*2/8)
if v <=minnumber then v = (minnumber - v) + v + 2 end
if v == u  then u = u + (minnumber/2) end
  local mult = 10^(idp or 0)
  return math.floor(v * mult + 0.5) / mult
end

function p.round7(x, idp)
math.randomseed(os.time())
x = (math.random()*multiplier*1/8)
if x <=1 or x >=minnumber then x = 6 or 8 or 10 end
  local mult = 10^(idp or 0)
  return math.floor(x * mult + 0.5) / mult
  end

return p, q, r, s, t, u, v, x