James Gray <james / grayproductions.net> wrote:
> On Sep 19, 2008, at 9:32 PM, Bill Kelly wrote:
> 
>> --------------
>> NEW CHALLENGE:
>> --------------
>>
>> # Given one or more input filenames on the command line, # report  
>> the number of unique IP addresses found in all the
>> # data.
>> #
>> # (For our purposes, an IP address may simply be considered
>> # four integerers separated by dots, e.g.: 6.54.123.9 )
>> #
>> # Optionally, the solution should read stdin if no filenames
>> # were specified.
>> #
>> # Preferably, the solution should be expressed in the form of
>> # a ruby command-line invocation. (Optional.)
> 
> ruby -e 'p ARGF.read.scan(/\d{1,3}(\.\d{1,3}){3}/).uniq.size'
> 
> New puzzle:  Provide a one-liner that can wrap a body of text at a  
> requested maximum length.

Hey, you posed that one already in Ruby Quiz 113

class String; def wrap length
   scan(/.{1,#{length}}\s+/).join(" \n")
end; end

New challange:

Starting with an array, find the first permutation of the elements of
that array that is lexicographically greater than (i.e. sorts after)
the given array.

-- 
Chanoch (Ken) Bloom. PhD candidate. Linguistic Cognition Laboratory.
Department of Computer Science. Illinois Institute of Technology.
http://www.iit.edu/~kbloom1/