I didn't know this for a long time, but you can use strings to build ranges in Ruby as well, avoiding the need for any fancy padding with zeros!
pins = ("0000".."9999").to_a.shuffle.join("\n") File.open("pins.txt", "w") { |f| f << pins }
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I didn't know this for a long time, but you can use strings to build ranges in Ruby as well, avoiding the need for any fancy padding with zeros!