ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> ruby-talk
ruby-talk
Re: [QUIZ] Price Ranges (#164)
by Harry Kakueki other posts by this author
Jun 3 2008 7:20AM messages near this date
Re: [QUIZ] Price Ranges (#164) | Re: Price Ranges (#164)
> 
=begin

Here is my solution.
It accepts input like this:
2500_5000  #lower_upper
2500_      #lower only
_5000      #upper only

=end

min,max = ARGV[0].split(/_/)
a,b,c = (1000..3000).to_a,(6000..10000).to_a,(500..2500).to_a
l,u = min.to_i,max.to_i
u = [a,b,c].flatten.max if max == nil
l = 0 if min == ""
cust = (l..u).to_a
p "a" unless (cust & a).empty?
p "b" unless (cust & b).empty?
p "c" unless (cust & c).empty?

Harry

-- 
A Look into Japanese Ruby List in English
http://www.kakueki.com/ruby/list.html
Thread:
Matthew Moss
Sharon and Dave
Matthew Rudy Jacobs
Sharon and Dave
Steven Hahn
Harry Kakueki
Toby O'Rourke
jgabrielygalan
Steven Hahn
Andrea Fazzi
S2
Matthew Moss
Matthew Moss
Robert Dober

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved