Skip to content

Instantly share code, notes, and snippets.

@bastengao
Last active December 17, 2015 06:18
Show Gist options
  • Save bastengao/5564082 to your computer and use it in GitHub Desktop.
Save bastengao/5564082 to your computer and use it in GitHub Desktop.
双色球机选
#encoding:utf-8
def gen_balls
final_balls = []
red_ball_poll = (1..33).to_a
6.times do
index = rand(red_ball_poll.length)
red_ball = red_ball_poll.delete_at(index)
final_balls << red_ball
end
final_balls.sort!
final_balls << Randomw.new.rand(1..16)
final_balls
end
def print_balls final_balls
printf("%-16s|%s\n","红球", " 蓝球")
puts("-" * 30)
final_balls[0..5].each do |redBall|
printf("%02d ", redBall)
end
print("|")
printf(" %02d \n", final_balls[6])
end
puts print_balls(gen_balls())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment