Ruby
def get_strength(num) strength=0 while !num.odd? num /= 2 strength += 1 end strength end def get_num_of_lowest_strength(nums) strength=Array.new nums.each do |x| strength.push [x, get_strength(x)] end strength.sort_by{|k,v| [v,k]}.reverse end nums=[5..10,48..56,129..193] nums.each do |num| x= get_num_of_lowest_strength(num) p x[0][0] end
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Ruby