DEV Community

Discussion on: Write a simple but impactful script

Collapse
 
rpalo profile image
Ryan Palo

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 }