Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- my_hash = {a: 'qwe', b: 'zcx', c: 'dss', d: 'ccc', e: 'www' }
- my_hash = {a: 'qwe', b: 'zcx', c: 'dss', d: 'ccc' }
- my_hash = {a: 'qwe', b: 'zcx', c: 'dss', e: 'www' }
- my_hash.to_a.combination(4).to_a.sample.to_h
- # => {:a=>"qwe", :b=>"zcx", :c=>"dss", :e=>"www"}
- my_hash.to_a.combination(4).to_a.sample.to_h
- # => {:a=>"qwe", :c=>"dss", :d=>"ccc", :e=>"www"}
- my_hash.keys.combination(4).map { |keys| Hash[keys.map { |k| [k, my_hash[k]] }] }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement