Here's my quick attempt
Cheers,
Dave
-----------------------------
def select_shops shops, wanted_min, wanted_max
shops.select do |shop|
(wanted_max ? wanted_max>= shop[:prices].min : true) &&
(wanted_min ? wanted_min<= shop[:prices].max : true)
end
end
shops= [{:name=> 'Company A', :prices=> 1_000.. 3_000},
{:name=> 'Company B', :prices=> 6_000..10_000},
{:name=> 'Company C', :prices=> 500.. 2_500}]
select_shops(shops, 2_500, 4_000).each do |shop|
puts shop[:name]
end