[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Programming challenge

unknown

5/15/2006 5:46:00 PM

Hi all!

I came across a very cool hardware design challenge in a magazine
and the author summarized the whole thing at this website:

http://www.pldesignline.com/howto/showArticle.jhtml;?articleID...

I was thinking that there must be an excellent way to write a
program that solves this problem using Ruby, but I haven't been
able to do so yet.

Does anyone want to try coming up with a Ruby solution? Or maybe
this should be a Ruby Quiz?

Thanks!
-- Glenn
6 Answers

Jeff Schwab

5/15/2006 6:51:00 PM

0

Glenn M. Lewis wrote:

> http://www.pldesignline.com/howto/showArticle.jhtml;?articleID...
>
> I was thinking that there must be an excellent way to write a
> program that solves this problem using Ruby, but I haven't been
> able to do so yet.
>
> Does anyone want to try coming up with a Ruby solution? Or maybe
> this should be a Ruby Quiz?


I'm not sure I understood the problem. This seems really
straight-forward to me:

http://schwabcenter.com/clr/bl...

What am I missing?

Jeff Schwab

5/15/2006 7:00:00 PM

0

Jeffrey Schwab wrote:
> Glenn M. Lewis wrote:
>
>> http://www.pldesignline.com/howto/showArticle.jhtml;?articleID...
>>
>> I was thinking that there must be an excellent way to write a
>> program that solves this problem using Ruby, but I haven't been
>> able to do so yet.
>>
>> Does anyone want to try coming up with a Ruby solution? Or maybe
>> this should be a Ruby Quiz?
>
>
> I'm not sure I understood the problem. This seems really
> straight-forward to me:
>
> http://schwabcenter.com/clr/bl...
>
> What am I missing?

OK, now I see that the article doesn't want us to use any XOR gates.
Though the original problem statement (from the Logically Speaking link)
says we can use as many XORs as we want...

unknown

5/15/2006 7:40:00 PM

0

Right... no XOR's... but not only that... I was hoping to come up
with a Ruby program that would actually *solve* (find a working
solution to) the problem... not just verify that *your* solution
actually works. See what I mean?

I would like it to pump out an equation that solves the problem.
It sounds like an application for genetic programming... I can't
think of any other way.

-- Glenn

Jeffrey Schwab wrote:

> Jeffrey Schwab wrote:
>
>> Glenn M. Lewis wrote:
>>
>>> http://www.pldesignline.com/howto/showArticle.jhtml;?articleID...
>>>
>>> I was thinking that there must be an excellent way to write a
>>> program that solves this problem using Ruby, but I haven't been
>>> able to do so yet.
>>>
>>> Does anyone want to try coming up with a Ruby solution? Or maybe
>>> this should be a Ruby Quiz?
>>
>>
>>
>> I'm not sure I understood the problem. This seems really
>> straight-forward to me:
>>
>> http://schwabcenter.com/clr/bl...
>>
>> What am I missing?
>
>
> OK, now I see that the article doesn't want us to use any XOR gates.
> Though the original problem statement (from the Logically Speaking link)
> says we can use as many XORs as we want...

Robert Klemme

5/15/2006 8:01:00 PM

0

Glenn M. Lewis wrote:
> Right... no XOR's... but not only that... I was hoping to come up
> with a Ruby program that would actually *solve* (find a working
> solution to) the problem... not just verify that *your* solution
> actually works. See what I mean?
>
> I would like it to pump out an equation that solves the problem.
> It sounds like an application for genetic programming... I can't
> think of any other way.

My first thought went rather into the direction of constraint solver -
but I don't have the program either. (It's a one liner with #inject
btw. - naa, just kidding :-))

robert

ptkwt

5/15/2006 8:38:00 PM

0

In article <XN4ag.3507$uM4.2223@tornado.socal.rr.com>,
Glenn M. Lewis <noSpam@noSpam.com> wrote:
>Right... no XOR's... but not only that... I was hoping to come up
>with a Ruby program that would actually *solve* (find a working
>solution to) the problem... not just verify that *your* solution
>actually works. See what I mean?
>
>I would like it to pump out an equation that solves the problem.
>It sounds like an application for genetic programming... I can't
>think of any other way.
>

GP would be an interesting way to solve it. There are no GP frameworks
for Ruby (yet).... I've been thinking about starting to work on one,
though.

Phil

Jeff Schwab

5/15/2006 9:21:00 PM

0

Glenn M. Lewis wrote:
> Right... no XOR's... but not only that... I was hoping to come up
> with a Ruby program that would actually *solve* (find a working
> solution to) the problem... not just verify that *your* solution
> actually works. See what I mean?
>
> I would like it to pump out an equation that solves the problem.
> It sounds like an application for genetic programming... I can't
> think of any other way.
>
> -- Glenn

Here's a solution with no XORs:

http://schwabcenter.com/clr/black_box...

Harder than it looks.

As to having Ruby solve the problem, I don't see why it couldn't be done
by brute force. You would have to start with some finite number N of
gates, and try every possible way of hooking them up to each other. If
you didn't have a solution yet, you would have to increase by one and
try again. And so on...