Ruby Array - Selection

Sort by

recency

|

52 Discussions

|

  • + 0 comments
    • arr.select{|a| a.odd?}
    • arr.reject {|a| a % 3 == 0}
    • arr.delete_if {|a| a.negative?}
    • arr.keep_if {|a| a >= 0}
  • + 0 comments
        arr.select {|a| a.odd? }
    		
        arr.reject {|a| a % 3 == 0 } 
    
        arr.delete_if {|a| a.negative?}
    
        arr.keep_if {|a| a.positive?}
    
  • + 0 comments

    If you enjoy survival games, the Frostborn Mod APK is a well-built platform with many developed characters that you will undoubtedly enjoy. Everybody will discover many methods to amuse themselves in Frostborn, a new kind of smartphone survival game.

  • + 0 comments
    def select_arr(arr)
      # select and return all odd numbers from the Array variable `arr`
        return arr.select{|a| (a%2 != 0)}
    end
    
    def reject_arr(arr)
      # reject all elements which are divisible by 3
        return arr.delete_if{|a| (a%3 == 0)}
    end
    
    def delete_arr(arr)
      # delete all negative elements
        return arr.delete_if{|a| a < 0}
    end
    
    def keep_arr(arr)
      # keep all non negative elements ( >= 0)
        return arr.keep_if{|a| a >= 0}
    end
    
  • + 0 comments

    Here is ruby array selection problem solution - https://www.gyangav.com/2022/10/hackerrank-ruby-array-selection-problem-solution.html