Created
October 5, 2011 16:21
-
-
Save quad/1264899 to your computer and use it in GitHub Desktop.
Inspired by _why c1-5
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 | |
class String | |
def shuffle | |
chars.to_a.shuffle.join | |
end | |
end | |
me = File.basename __FILE__ | |
where_am_i = File.dirname __FILE__ | |
10.times do | |
to_go = Dir.open where_am_i | |
places = to_go.map { |n| File.join to_go.path, n }.select { |d| File.directory? d } | |
whence = places.shuffle.first | |
begin | |
File.rename File.join(where_am_i, me), File.join(whence, me) | |
rescue Errno::EACCES | |
next | |
else | |
where_am_i = whence | |
end | |
end | |
puts where_am_i.shuffle |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment