Skip to content

Instantly share code, notes, and snippets.

@soul0592
Created July 1, 2013 08:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save soul0592/5899380 to your computer and use it in GitHub Desktop.
Save soul0592/5899380 to your computer and use it in GitHub Desktop.
Generador de numeros pseudoaleatorios.
def aleatorio(largo,renglon)
a = open('keyrb.dat','w')
uno = 0
cero = 0
for i in 1..renglon
for l in 1..largo
random = rand(2)
a.write(random)
if random == 1
uno += 1
else
cero += 1
end
end
a.write("\n")
end
a.write("Cero: "+cero.to_s+"\n")
a.write("Uno: "+uno.to_s+"\n")
a.close()
end
largo = ARGV[0].to_i
renglon = ARGV[1].to_i
aleatorio(largo, renglon)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment