[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Fwd: Please Forward: Ruby Quiz Submission

James Gray

10/15/2007 9:55:00 PM

Begin forwarded message:

> From: Pusztai Tibor <kondi@inf.elte.hu>
> Date: October 15, 2007 4:09:41 PM CDT
> To: submission@rubyquiz.com
> Cc: gbence@cs.bme.hu
> Subject: Please Forward: Ruby Quiz Submission
>
> Hello,
>
> Please forward my solution to the Ruby Talk mailing list!
>
> Thanks,
> Tibor
> # This solution is my homework for a ruby lesson
> # Pusztai Tibor (PUTNAAI.ELTE)
>
> MAX_REPEAT = 3
> DOT_MATCH = /[a-zA-Z\d\.,;\^\- ]/
>
> class Concatenate < Array
>
> def multiIndex indexes
> n = -1
> indexes.map { |index|
> at(n += 1).at(index)
> }
> end
>
> def cartesian
> indexes = Array.new length, 0
> out = Select.new
> while true
> out << multiIndex(indexes).join
> n = length - 1
> while (indexes[n] += 1) >= at(n).length
> indexes[n] = 0
> if (n -= 1) < 0
> return out
> end
> end
> end
> end
>
> def unfold
> if length == 0
> return Select.new(1, "")
> end
> map! { |item|
> if item.is_a? String
> Select.new 1, item
> else
> item.unfold
> end
> }
> cartesian
> end
>
> def simplify
> genSimplify self
> self
> end
>
> end
>
> class Select < Array
>
> def to_a
> map { |item| item }
> end
>
> def unfold
> out = Select.new
> each { |item|
> if item.is_a? String
> out << item
> else
> out.concat item.unfold
> end
> }
> out
> end
>
> def simplify
> genSimplify self
> self
> end
>
> end
>
> def genSimplify x
> if x.is_a? String
> x
> elsif x.length == 1
> genSimplify x[0]
> else
> x.map! { |y|
> genSimplify y
> }
> end
> end
>
> def toTree source
> stack = Concatenate.new
> dotMatch = nil
> source.scan(/(\.)|\[(.*?[^\\])\]|\{([\d,]+)\}|([\(\)\|\?\+\*])|((\
> \.|[^\.\(\)\|\[\]\?\+\*\{\}])+)/) {
> |dot, charClass, nTimes, control, s|
> if dot
> charClass = DOT_MATCH.inspect[2..-3]
> end
> if s
> stack << s.gsub(/\\(.)/, "\\1")
> elsif charClass
> charClass.gsub!(/(^|[^\\])\\d/, "\\10-9")
> charClass.gsub!(/\\([^-])/, "\\1")
> charClass.gsub!(/([^\\])-(.)/) {
> ($1..$2).to_a.join
> }
> charClass.gsub!(/\\-/, "-")
> select = Select.new
> if charClass[0..0] == '^'
> if !dotMatch
> dotMatch = DOT_MATCH.generate.join
> end
> charClass = dotMatch.delete charClass[1..-1].gsub(/[\^\-]/, "\\\
> \\\0")
> end
> charClass.scan(/./m) { |ch|
> select << ch
> }
> stack << select
> elsif control
> case control
> when "("
> stack << :select_open
> when "|"
> stack << :select_pipe
> when ")"
> select = Select.new
> conc = Concatenate.new
> while (elem = stack.pop) != :select_open
> if (elem == :select_pipe)
> select.unshift conc
> conc = Concatenate.new
> else
> conc.unshift elem
> end
> end
> select.unshift conc
> stack << select
> when "?"
> nTimes = "0,1"
> when "*"
> nTimes = "0," + MAX_REPEAT.to_s
> when "+"
> nTimes = "1," + MAX_REPEAT.to_s
> end
> end
> if nTimes
> if nTimes.include? ','
> from, to = nTimes.split(',').map { |x| x.to_i }
> if !to
> to = MAX_REPEAT
> end
> else
> from = to = nTimes.to_i
> end
> last = stack.pop
> if last.is_a? String
> stack << last.chop
> last = last[-1..-1]
> end
> stack << Select.new(
> (from..to).map { |n|
> Concatenate.new n, last
> }
> )
> end
> }
> stack
> end
>
> class Regexp
>
> def generate
> toTree("("+self.inspect[1..-2]+")").simplify.unfold.to_a.uniq
> end
>
> end


5 Answers

rfischer

6/16/2011 5:34:00 PM

0

Steve <stevencanyon@yahooooo.com> wrote:
>On Thu, 16 Jun 2011 16:26:57 +0000 (UTC), "6075 Dead, 1218 since
>1/20/09" <dead@gone.com> wrote:
>
>>On Thu, 16 Jun 2011 11:57:03 -0400, Mr.B1ack wrote:
>>
>>> "6075 Dead, 1218 since 1/20/09" <dead@gone.com> wrote:
>>>
>>>>http://crooksandliars.com/john-amato/tea-party-child-indoc...
>>camps
>>>>
>>>>Tea Party Child Indoctrination "Camps" 62 comments
>>>>By John Amato
>>>>
>>>>How many times have you heard Glenn Beck tell his audience that Liberals
>>>>and public schools are indoctrinating America to become socialists,
>>>>Marxists, radical Muslims?
>>>>
>>>>Well, now there's this from the Tampa912 Project.
>>>>
>>>> TAMPA ? Here's another option now that the kids are out of school:
>>a
>>>>weeklong seminar about our nation's founding principles, courtesy of the
>>>>Tampa 912 Project.
>>>>
>>>> The organization, which falls under the tea party umbrella, hopes to
>>>>introduce kids ages 8 to 12 to principles that include "America is
>>>>good," "I believe in God," and "I work hard for what I have and I will
>>>>share it with who I want to. Government cannot force me to be
>>>>charitable."
>>>
>>>
>>> Of course when America-hating 'liberals' try to drill THEIR crap into
>>> the kiddies ... THAT'S perfectly OK ...... :-)
>>
>>Tell us about the indoctrination camps.
>>
>>Try to avoid quoting Glenn Beck or prison planet, m'k?
>
>I think it's quite telling that Jamieson is apparently insisting that
>parents not be allowed to teach their children what they want...

It's quite telling that the leech steve has to lie about people in
order to justify his greed.

--
Ray Fischer | Mendocracy (n.) government by lying
rfischer@sonic.net | The new GOP ideal

Blackwater

6/16/2011 7:01:00 PM

0

"6075 Dead, 1218 since 1/20/09" <dead@gone.com> wrote:

>On Thu, 16 Jun 2011 11:57:03 -0400, Mr.B1ack wrote:
>
>> "6075 Dead, 1218 since 1/20/09" <dead@gone.com> wrote:
>>
>>>http://crooksandliars.com/john-amato/tea-party-child-indoc...
>camps
>>>
>>>Tea Party Child Indoctrination "Camps" 62 comments
>>>By John Amato
>>>
>>>How many times have you heard Glenn Beck tell his audience that Liberals
>>>and public schools are indoctrinating America to become socialists,
>>>Marxists, radical Muslims?
>>>
>>>Well, now there's this from the Tampa912 Project.
>>>
>>> TAMPA ? Here's another option now that the kids are out of school:
>a
>>>weeklong seminar about our nation's founding principles, courtesy of the
>>>Tampa 912 Project.
>>>
>>> The organization, which falls under the tea party umbrella, hopes to
>>>introduce kids ages 8 to 12 to principles that include "America is
>>>good," "I believe in God," and "I work hard for what I have and I will
>>>share it with who I want to. Government cannot force me to be
>>>charitable."
>>
>>
>> Of course when America-hating 'liberals' try to drill THEIR crap into
>> the kiddies ... THAT'S perfectly OK ...... :-)
>
>Tell us about the indoctrination camps.


They're big, dismal, usually brick. Typically have
names ending in "__ Public School" :-)


liberal

6/20/2011 5:47:00 PM

0

On Jun 16, 3:01 pm, Mr.B1ack <b...@barrk.net> wrote:
> "6075 Dead, 1218 since 1/20/09" <d...@gone.com> wrote:
>
>
>
>
>
> >On Thu, 16 Jun 2011 11:57:03 -0400, Mr.B1ack wrote:
>
> >> "6075 Dead, 1218 since 1/20/09" <d...@gone.com> wrote:
>
> >>>http://crooksandliars.com/john-amato/tea-party-child-indoc...
> >camps
>
> >>>Tea Party Child Indoctrination "Camps" 62 comments
> >>>By John Amato
>
> >>>How many times have you heard Glenn Beck tell his audience that Liberals
> >>>and public schools are indoctrinating America to become socialists,
> >>>Marxists, radical Muslims?
>
> >>>Well, now there's this from the Tampa912 Project.
>
> >>>    TAMPA ? Here's another option now that the kids are out of school:
> >a
> >>>weeklong seminar about our nation's founding principles, courtesy of the
> >>>Tampa 912 Project.
>
> >>>    The organization, which falls under the tea party umbrella, hopes to
> >>>introduce kids ages 8 to 12 to principles that include "America is
> >>>good," "I believe in God," and "I work hard for what I have and I will
> >>>share it with who I want to. Government cannot force me to be
> >>>charitable."
>
> >>    Of course when America-hating 'liberals' try to drill THEIR crap into
> >>    the kiddies ... THAT'S perfectly OK ......   :-)
>
> >Tell us about the indoctrination camps.
>
>    They're big, dismal, usually brick. Typically have
>    names ending in "__ Public School"   :-)

Yeah, and the two really, really mean liberal courses taught are
history and logic. I understand your anger.

Falstaff

6/20/2011 10:24:00 PM

0

On Jun 16, 2:01 pm, Mr.B1ack <b...@barrk.net> wrote:
> "6075 Dead, 1218 since 1/20/09" <d...@gone.com> wrote:
>
>
>
>
>
> >On Thu, 16 Jun 2011 11:57:03 -0400, Mr.B1ack wrote:
>
> >> "6075 Dead, 1218 since 1/20/09" <d...@gone.com> wrote:
>
> >>>http://crooksandliars.com/john-amato/tea-party-child-indoc...
> >camps
>
> >>>Tea Party Child Indoctrination "Camps" 62 comments
> >>>By John Amato
>
> >>>How many times have you heard Glenn Beck tell his audience that Liberals
> >>>and public schools are indoctrinating America to become socialists,
> >>>Marxists, radical Muslims?
>
> >>>Well, now there's this from the Tampa912 Project.
>
> >>>    TAMPA ? Here's another option now that the kids are out of school:
> >a
> >>>weeklong seminar about our nation's founding principles, courtesy of the
> >>>Tampa 912 Project.
>
> >>>    The organization, which falls under the tea party umbrella, hopes to
> >>>introduce kids ages 8 to 12 to principles that include "America is
> >>>good," "I believe in God," and "I work hard for what I have and I will
> >>>share it with who I want to. Government cannot force me to be
> >>>charitable."
>
> >>    Of course when America-hating 'liberals' try to drill THEIR crap into
> >>    the kiddies ... THAT'S perfectly OK ......   :-)
>
> >Tell us about the indoctrination camps.
>
>    They're big, dismal, usually brick. Typically have
>    names ending in "__ Public School"   :-)

What 8-year old wants to play outside all summer when they can spend
it discussing the gold standard and the Laffer Curve instead?

Neoconis_Ignoramus

6/20/2011 10:38:00 PM

0

On Jun 20, 3:24 pm, Falstaff <jaxfalst...@yahoo.com> wrote:
> On Jun 16, 2:01 pm, Mr.B1ack <b...@barrk.net> wrote:
>
>
>
>
>
> > "6075 Dead, 1218 since 1/20/09" <d...@gone.com> wrote:
>
> > >On Thu, 16 Jun 2011 11:57:03 -0400, Mr.B1ack wrote:
>
> > >> "6075 Dead, 1218 since 1/20/09" <d...@gone.com> wrote:
>
> > >>>http://crooksandliars.com/john-amato/tea-party-child-indoc...
> > >camps
>
> > >>>Tea Party Child Indoctrination "Camps" 62 comments
> > >>>By John Amato
>
> > >>>How many times have you heard Glenn Beck tell his audience that Liberals
> > >>>and public schools are indoctrinating America to become socialists,
> > >>>Marxists, radical Muslims?
>
> > >>>Well, now there's this from the Tampa912 Project.
>
> > >>>    TAMPA ? Here's another option now that the kids are out of school:
> > >a
> > >>>weeklong seminar about our nation's founding principles, courtesy of the
> > >>>Tampa 912 Project.
>
> > >>>    The organization, which falls under the tea party umbrella, hopes to
> > >>>introduce kids ages 8 to 12 to principles that include "America is
> > >>>good," "I believe in God," and "I work hard for what I have and I will
> > >>>share it with who I want to. Government cannot force me to be
> > >>>charitable."
>
> > >>    Of course when America-hating 'liberals' try to drill THEIR crap into
> > >>    the kiddies ... THAT'S perfectly OK ......   :-)
>
> > >Tell us about the indoctrination camps.
>
> >    They're big, dismal, usually brick. Typically have
> >    names ending in "__ Public School"   :-)
>
> What 8-year old wants to play outside all summer when they can spend
> it discussing the gold standard and the Laffer Curve instead?- Hide quoted text -
>
> - Show quoted text -

You kidding? What kid would pass up the opportunity to learn about
Von Mises, Ayn Rand, and reserve currencies by choosing to be out
playing baseball or hoops or some other kid game?

Oh wait, it's fat, stupid, unathletic republican kids spawned from
fat, stupid, unathletic parents. In Florida for god's sake. No
wonder these little turds will be getting indoctrinated ERRRRR
learning.