Created
March 26, 2015 16:31
-
-
Save danott/a1a3cbd8d0b1f7176266 to your computer and use it in GitHub Desktop.
Randomize the digits, uniq for each line of each run.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
s = gets | |
while s | |
map_old_to_new = {} | |
available_digits = %w(0 1 2 3 4 5 6 7 8 9) | |
(0..9).each do |old| | |
new = available_digits.sample | |
available_digits -= [new] | |
map_old_to_new["#{old}"] = new | |
end | |
puts s.gsub(/\d/) { |old| map_old_to_new[old] } | |
s = gets | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment