------art_8096_3979425.1141178336849
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

An answer just for the fun of it, showing that you write as obscure and
unmaintainable code in Ruby as in Perl. The challenge was to get all the
functionality in a one liner, in order to see how far you can stretch ruby
expressions. They seem to stretch pretty well:-)

It uses Google, so it supports only zip codes as input.

require 'net/http'
puts ((ARGV.length != 1) ? "Usage: #$0 <zip code>" :  (["The temperature
in"] + (/Weather<\/b> for <b>(.*)<\/b>.*\D(\d+)&deg;F/.match(Net::HTTP.get(
URI.parse("http://www.google.com/search?hl=en&q=temperature+#{ARGV[0]}")))[1,2].collect!
{|x| " is " + x})).to_s.gsub!(/in is /, "in ") + " degree F")

./temp.rb 94117
The temperature in San Francisco, CA is 57 degree F
./temp.rb
Usage: ./temp.rb <zip code>


On 2/24/06, Ruby Quiz <james / grayproductions.net> wrote:
>
> The three rules of Ruby Quiz:
>
> 1.  Please do not post any solutions or spoiler discussion for this quiz
> until
> 48 hours have passed from the time on this message.
>
> 2.  Support Ruby Quiz by submitting ideas as often as you can:
>
> http://www.rubyquiz.com/
>
> 3.  Enjoy!
>
> Suggestion:  A [QUIZ] in the subject of emails about the problem helps
> everyone
> on Ruby Talk follow the discussion.
>
>
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>
> by Caleb Tennis
>
> Write a Ruby program such that given a certain argument to the program it
> will return the current temperature of that location.  People living in
> the United States may be interested in temperature by ZIP code:
>
>         $ ruby current_temp.rb 47201
>         The temperature in Columbus, Indiana is 32 degrees F.
>
> Other locales may want to use their own mailing codes, or city names:
>
>         $ ruby current_temp.rb madrid
>         The temperature in Madrid, Spain is 12 degrees C.
>
> Which arguments you support is up to you.
>
>


--
Patrick Chanezon, AdWords API evangelist
http://blog.chanezon.com/
http://www.google.com/apis/adwords/

------art_8096_3979425.1141178336849--