[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Fwd: [SOLUTION] Please Forward: Ruby Quiz Subumission

James Gray

5/6/2005 12:52:00 AM

Begin forwarded message:

> From: Pedro <pedro.wotan@mundo-r.com>
> Date: May 5, 2005 7:48:36 PM CDT
> To: submission@rubyquiz.com
> Subject: [SOLUTION] Please Forward: Ruby Quiz Subumission
>
>
> This is my very first Ruby script, and I supose it could be
> terrific, but I enjoyed it very much :).
>
> Bye
> class Song
> def initialize(author, title, duration)
> @author=author
> @title=title
> @duration=duration
> end
>
> def to_s
> return "#{@title} - #{@author} - #{@duration/1000} ms"
> end
>
> attr_reader :author, :title, :duration
> end
>
> def parse(name)
> list = Hash.new
> artist = Regexp.new('<Artist name=\"([^>]+)\">')
> song = Regexp.new('<Song name=\"([^>]+)\" id=\'(\d+)\' duration=
> \'(\d+)\'/>')
> a, t, d = '', '', 0
> i=0
> File.open(name) do |file|
> file.each_line do |line|
> i+=1
> if ar=artist.match(line)
> a = ar[1]
> elsif ar=song.match(line)
> t = ar[1]
> d = ar[3].to_i
> key = getFirst(t)
> list[key] = Array.new unless list[key]
> list[key] << Song.new(a, t, d)
> end
> end
> end
> return list
> end
>
> def getFirst(name)
> return name[0, 1].capitalize
> end
>
> def getLast(name)
> return name[-1, 1].capitalize
> end
>
> def duration(seq)
> total=0
> seq.each { |c| total+=c.duration }
> return total
> end
>
> def search(songs, first, last)
> posibles = Array.new
> if songs.key?(getLast(first.title))
> if(songs[getLast(first.title)].find {|c|
> c.title==last.title})
> return [last]
> end
> sig = songs.delete(getLast(first.title))
> for i in sig
> if v=search(songs, i, last)
> posibles << (v << i)
> end
> end
> # what do you choose?
> unless posibles.empty?
> return yield(posibles) if block_given?
> return posibles[0]
> end
> end
> return nil
> end
>
> ## SELECTION METHODS
> min_dur = proc do |list|
> min = list[0]
> list.each do |i|
> min=i if duration(i)<duration(min)
> end
> min
> end
>
> min_len = proc do |list|
> min = list[0]
> list.each do |i|
> min=i if i.length<min.length
> end
> min
> end
>
> def exact_len(dur)
> return proc do |list|
> min = list[0]
> list.each do |i|
> min=i if (duration(i)-dur).abs<(duration(min)-
> dur).abs
> end
> min
> end
> end
>
> songs = parse('SongLibrary.xml')
>
> ## PREDEFINED LIST
> #title1, title2 = '21st Century Army', 'Deconstruction'
> #v1, v2 = songs[getFirst(title1)], songs[getFirst(title2)]
> #first = v1.find {|c| c.title == title1}
> #last = v2.find {|c| c.title == title2}
>
> ## RANDOM LIST
> v1 = songs[songs.keys[rand(songs.length)]]
> v2 = songs[songs.keys[rand(songs.length)]]
> first, last = v1[rand(v1.length)], v2[rand(v2.length)]
>
> puts first.to_s + ' ===> ' + last.to_s
>
> result=search(songs, first, last, &min_len)
>
> if result
> result.push(first)
> puts result.reverse
> else
> puts 'There is no way!'
> end
>



20 Answers

skm1942

6/12/2012 6:05:00 PM

0

On Jun 12, 7:58 am, plainolamerican <plainolameri...@gmail.com> wrote:
> On Jun 12, 9:00 am, "Ramon F. Herrera" <ra...@conexus.net> wrote:
>
> > On Jun 12, 8:15 am, TaxPayer <bettymar...@gmail.com> wrote:
>
> > > Please people! It's time to secure our borders!http://www.examiner.com/article/the-children-of-illegal-ali......
>
> > (1) It is not a transgression (much less a crime) to have children. It
> > is Universal Human Right.
>
> > (2) Those children are -at least- as American as you are.
>
> > -Ramon
>
> It is not a transgression (much less a crime) to have children
> --
> it's a transgression to come to the US just so they can can steal
> social services and 'make' their children American.

Yes, it is against the law for the parents of these anchors to come
here in violation of our immigration laws. Giving birth on our soil
just adds insult to injury. Our citizenship is being given away like
candy and then we have to pay for their births and welfare for
years.

Ramon F Herrera

6/12/2012 6:24:00 PM

0

On Jun 12, 1:05 pm, chicagonut <skm1...@msn.com> wrote:
> On Jun 12, 7:58 am, plainolamerican <plainolameri...@gmail.com> wrote:
>
>
>
>
>
>
>
>
>
> > On Jun 12, 9:00 am, "Ramon F. Herrera" <ra...@conexus.net> wrote:
>
> > > On Jun 12, 8:15 am, TaxPayer <bettymar...@gmail.com> wrote:
>
> > > > Please people! It's time to secure our borders!http://www.examiner.com/article/the-children-of-illegal-ali......
>
> > > (1) It is not a transgression (much less a crime) to have children. It
> > > is Universal Human Right.
>
> > > (2) Those children are -at least- as American as you are.
>
> > > -Ramon
>
> > It is not a transgression (much less a crime) to have children
> > --
> > it's a transgression to come to the US just so they can can steal
> > social services and 'make' their children American.
>

> Yes,  it is against the law for the parents of these anchors to come
> here in violation of our immigration laws.

> Giving birth on our soil just adds insult to injury.

Please show us in the US Code where it says that said "insult" is a
violation:

http://www.law.cornell.edu/u...

-Ramon

skm1942

6/12/2012 6:35:00 PM

0

On Jun 12, 11:24 am, "Ramon F. Herrera" <ra...@conexus.net> wrote:
> On Jun 12, 1:05 pm, chicagonut <skm1...@msn.com> wrote:
>
>
>
>
>
> > On Jun 12, 7:58 am, plainolamerican <plainolameri...@gmail.com> wrote:
>
> > > On Jun 12, 9:00 am, "Ramon F. Herrera" <ra...@conexus.net> wrote:
>
> > > > On Jun 12, 8:15 am, TaxPayer <bettymar...@gmail.com> wrote:
>
> > > > > Please people! It's time to secure our borders!http://www.examiner.com/article/the-children-of-illegal-ali......
>
> > > > (1) It is not a transgression (much less a crime) to have children. It
> > > > is Universal Human Right.
>
> > > > (2) Those children are -at least- as American as you are.
>
> > > > -Ramon
>
> > > It is not a transgression (much less a crime) to have children
> > > --
> > > it's a transgression to come to the US just so they can can steal
> > > social services and 'make' their children American.
>
> > Yes,  it is against the law for the parents of these anchors to come
> > here in violation of our immigration laws.
>
>  > Giving birth on our soil just adds insult to injury.
>
> Please show us in the US Code where it says that said "insult" is a
> violation:
>
> http://www.law.cornell.edu/u...
>
> -Ramon- Hide quoted text -
>
> - Show quoted text -

For the last time I ask please leave me alone!!!!!!!!!!!!!!!! WTF is
wrong with you?

BR549

6/12/2012 7:52:00 PM

0

On Jun 12, 1:24 pm, "Ramon F. Herrera" <ra...@conexus.net> wrote:
> On Jun 12, 1:05 pm, chicagonut <skm1...@msn.com> wrote:
>
>
>
>
>
> > On Jun 12, 7:58 am, plainolamerican <plainolameri...@gmail.com> wrote:
>
> > > On Jun 12, 9:00 am, "Ramon F. Herrera" <ra...@conexus.net> wrote:
>
> > > > On Jun 12, 8:15 am, TaxPayer <bettymar...@gmail.com> wrote:
>
> > > > > Please people! It's time to secure our borders!http://www.examiner.com/article/the-children-of-illegal-ali......
>
> > > > (1) It is not a transgression (much less a crime) to have children. It
> > > > is Universal Human Right.
>
> > > > (2) Those children are -at least- as American as you are.
>
> > > > -Ramon
>
> > > It is not a transgression (much less a crime) to have children
> > > --
> > > it's a transgression to come to the US just so they can can steal
> > > social services and 'make' their children American.
>
> > Yes,  it is against the law for the parents of these anchors to come
> > here in violation of our immigration laws.
>
>  > Giving birth on our soil just adds insult to injury.
>
> Please show us in the US Code where it says that said "insult" is a
> violation:
>
> http://www.law.cornell.edu/u...
>
> -Ramon- Hide quoted text -
>
> - Show quoted text -

According to some people you can be arrested for dissing the Messiah:

http://www.huffingtonpost.com/2012/05/21/north-rowan-high-school-disrespecting-obama_n_15...

Ramon F Herrera

6/12/2012 8:19:00 PM

0

On Jun 12, 1:34 pm, chicagonut <skm1...@msn.com> wrote:
> On Jun 12, 11:24 am, "Ramon F. Herrera" <ra...@conexus.net> wrote:
>
>
>
>
>
>
>
>
>
> > On Jun 12, 1:05 pm, chicagonut <skm1...@msn.com> wrote:
>
> > > On Jun 12, 7:58 am, plainolamerican <plainolameri...@gmail.com> wrote:
>
> > > > On Jun 12, 9:00 am, "Ramon F. Herrera" <ra...@conexus.net> wrote:
>
> > > > > On Jun 12, 8:15 am, TaxPayer <bettymar...@gmail.com> wrote:
>
> > > > > > Please people! It's time to secure our borders!http://www.examiner.com/article/the-children-of-illegal-ali......
>
> > > > > (1) It is not a transgression (much less a crime) to have children. It
> > > > > is Universal Human Right.
>
> > > > > (2) Those children are -at least- as American as you are.
>
> > > > > -Ramon
>
> > > > It is not a transgression (much less a crime) to have children
> > > > --
> > > > it's a transgression to come to the US just so they can can steal
> > > > social services and 'make' their children American.
>
> > > Yes,  it is against the law for the parents of these anchors to come
> > > here in violation of our immigration laws.
>
> >  > Giving birth on our soil just adds insult to injury.
>
> > Please show us in the US Code where it says that said "insult" is a
> > violation:
>
> >http://www.law.cornell.edu/u...
>
> > -Ramon- Hide quoted text -
>
> > - Show quoted text -
>

> For the last time I ask please leave me alone!!!!!!!!!!
> WTF is wrong with you?

"There's no crying in baseball!!"
-Tom Cruise to Madonna

http://www.imdb.com/title/...

Ramon's Corollary: "The gender card has no effect in Usenet"

max headroom

6/12/2012 9:14:00 PM

0

Ramon F. Herrera <ramon@conexus.net> wrote in
news:323df668-9a91-4d96-986b-a620cc6fa3fc@t8g2000yqd.googlegroups.com:

> "There's no crying in baseball!!"
> -Tom Cruise to Madonna

Tom Cruise?

Tom Hanks?

> Ramon's Corollary: "The gender card has no effect in Usenet"

Max's Corollary: "Neither does the race card."



Mr.Sandman

6/12/2012 10:31:00 PM

0

On 6/12/2012 2:05 PM, chicagonut wrote:

> Yes, it is against the law for the parents of these anchors to come
> here in violation of our immigration laws. Giving birth on our soil
> just adds insult to injury. Our citizenship is being given away like
> candy and then we have to pay for their births and welfare for
> years.

A baby born in the U.S. has all the rights and privileges as any other
citizen of the U.S. and is no less an American than any other American.
There is not going to be a solution to this situation until the U.S.
offers a pathway to legal residency for migrant workers who want it.

Ramon F Herrera

6/13/2012 11:17:00 AM

0

On Jun 12, 4:14 pm, "max headroom" <maxheadr...@localnet.com> wrote:
> Ramon F. Herrera <ra...@conexus.net> wrote innews:323df668-9a91-4d96-986b-a620cc6fa3fc@t8g2000yqd.googlegroups.com:
>
> > "There's no crying in baseball!!"
> > -Tom Cruise to Madonna
>
> Tom Cruise?
>
> Tom Hanks?
>

The crying girl was not Madonna, either.

-Ramon

Ramon F Herrera

6/13/2012 11:21:00 AM

0

On Jun 12, 4:14 pm, "max headroom" <maxheadr...@localnet.com> wrote:

> Max's Corollary: "Neither does the race card."

There are 54 valid cards in a full deck. Exactly who authorized you to
decide that one of them is not valid?

YOU use whatever argument you desire while *I* will decide what
argument I use.

Why should your "race-card" card be valid while my race card is not?

Your argument can be used to justify racism (it is often used), and it
is therefore invalid.

-Ramon

plainolamerican

6/13/2012 2:31:00 PM

0

On Jun 12, 3:19 pm, "Ramon F. Herrera" <ra...@conexus.net> wrote:
> On Jun 12, 1:34 pm, chicagonut <skm1...@msn.com> wrote:
>
>
>
>
>
>
>
>
>
> > On Jun 12, 11:24 am, "Ramon F. Herrera" <ra...@conexus.net> wrote:
>
> > > On Jun 12, 1:05 pm, chicagonut <skm1...@msn.com> wrote:
>
> > > > On Jun 12, 7:58 am, plainolamerican <plainolameri...@gmail.com> wrote:
>
> > > > > On Jun 12, 9:00 am, "Ramon F. Herrera" <ra...@conexus.net> wrote:
>
> > > > > > On Jun 12, 8:15 am, TaxPayer <bettymar...@gmail.com> wrote:
>
> > > > > > > Please people! It's time to secure our borders!http://www.examiner.com/article/the-children-of-illegal-ali......
>
> > > > > > (1) It is not a transgression (much less a crime) to have children. It
> > > > > > is Universal Human Right.
>
> > > > > > (2) Those children are -at least- as American as you are.
>
> > > > > > -Ramon
>
> > > > > It is not a transgression (much less a crime) to have children
> > > > > --
> > > > > it's a transgression to come to the US just so they can can steal
> > > > > social services and 'make' their children American.
>
> > > > Yes,  it is against the law for the parents of these anchors to come
> > > > here in violation of our immigration laws.
>
> > >  > Giving birth on our soil just adds insult to injury.
>
> > > Please show us in the US Code where it says that said "insult" is a
> > > violation:
>
> > >http://www.law.cornell.edu/u...
>
> > > -Ramon- Hide quoted text -
>
> > > - Show quoted text -
>
>  > For the last time I ask please leave me alone!!!!!!!!!!
>  > WTF is wrong with you?
>
> "There's no crying in baseball!!"
> -Tom Cruise to Madonna
>
> http://www.imdb.com/title/...
>
> Ramon's Corollary: "The gender card has no effect in Usenet"

"There's no crying in baseball!!"
---
and there's no way anyone can condone illegal immigration