daily pastebin goal
65%
SHARE
TWEET

Untitled

a guest Mar 21st, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @packages = ["2", ["4", "2", "1"], "4", ["4","2"], ["5", "6"]]
  2.      
  3. @packages = ["2", ["4", "2", "1"], "4", ["4","2"], ["3", "2"]]
  4. @opposites = ["2", "4"]
  5.  
  6. @packages.reject! { |p| p.is_a?(Array) && (@opposites & p).size >= 2 }
  7.      
  8. @packages.reject { |a| a.is_a?(Array) && (a & [ '2', '4' ]).length == 2 }
  9.      
  10. >> @packages = ["2", ["4", "2", "1"], "4", ["4","2"], ["5", "6"], ["1", "2"], ["4", "11"], ["2", "2", "4"]]
  11. => ["2", ["4", "2", "1"], "4", ["4", "2"], ["5", "6"], ["1", "2"], ["4", "11"], ["2", "2", "4"]]
  12. >> @packages.reject { |a| a.is_a?(Array) && (a & [ '2', '4' ]).length == 2 }
  13. => ["2", "4", ["5", "6"], ["1", "2"], ["4", "11"]]
  14.      
  15. rejects = %w(2 4)
  16. @packages.reject { |a| a.is_a?(Array) && (a & rejects).length == rejects.length }
  17.      
  18. @packages.reject{|element| element.is_a?(Array)}
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top