Write a method intersection that takes two ranges

How do I write a method intersection(range1, range2) that takes two
ranges (a pair of start and stop coordinates on a line) and returns (a)
an array of subranges of range1 which are not contained in range2, (b)
an array of subranges of range2 that are not contained in range1, and
(c) the subrange common to both range1 and range2?

Thank you

···

--
Posted via http://www.ruby-forum.com/.

These all sound like homework assignments and as a teacher I think you should try these on your own first or you will learn nothing.

Dave

···

Sent from my iPhone

On Jun 7, 2013, at 7:46 PM, "Tario C." <lists@ruby-forum.com> wrote:

How do I write a method intersection(range1, range2) that takes two
ranges (a pair of start and stop coordinates on a line) and returns (a)
an array of subranges of range1 which are not contained in range2, (b)
an array of subranges of range2 that are not contained in range1, and
(c) the subrange common to both range1 and range2?

Thank you

--
Posted via http://www.ruby-forum.com/\.

Hello,

How do I write a method intersection(range1, range2) that takes two
ranges (a pair of start and stop coordinates on a line) and returns (a)
an array of subranges of range1 which are not contained in range2, (b)
an array of subranges of range2 that are not contained in range1, and
(c) the subrange common to both range1 and range2?

Do it on paper first, write every step. Then it would be easy to create a 1st version that works :slight_smile:

Thank you

--
Posted via http://www.ruby-forum.com/\.

Panagiotis (atmosx) Atmatzidis

email: atma@convalesco.org
URL: http://www.convalesco.org
GnuPG ID: 0x1A7BFEC5
gpg --keyserver pgp.mit.edu --recv-keys 1A7BFEC5

···

On 8 Ιουν 2013, at 04:46 , "Tario C." <lists@ruby-forum.com> wrote:
--
The wise man said: "Never argue with an idiot. They bring you down to their level and beat you with experience."

These all sound like homework problems...

Hi,

Is there a good reference website of message functionalities?

Thank you

···

--
Posted via http://www.ruby-forum.com/.

How about thinking of an algorithm _yourself_?

Regards

robert

···

On Sun, Jun 9, 2013 at 2:41 AM, Tario C. <lists@ruby-forum.com> wrote:

Is there a good reference website of message functionalities?

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/