Solving logic problems with Ruby

During my college days I experimented with a language called Prolog.
This language was suitable to solve logic problems.
Had anybody used Ruby to solve logic problems?

For example, a problem like the one below:

You have 12 bricks. They look and feel exactly the same
but one is different than the other 11. It is either slightly
heavier or slightly lighter. Using a balance scale, find
the odd brick and tell whether it is lighter or heavier than
a normal brick. Oh yes, I almost forgot to tell you. You
can only use the scale 3 times.

Thank you

Not that I venture a solution here, but you might
also want to read Piers Anthony’s “With a Tangled Skein”,
especially the last sections :slight_smile:

s.

···

On Tue, 04 Jun 2002 20:07:27 GMT, Victor Manuel Reyes Viloria vmreyes@us.ibm.com wrote:

During my college days I experimented with a language called Prolog.
This language was suitable to solve logic problems.
Had anybody used Ruby to solve logic problems?

For example, a problem like the one below:

You have 12 bricks. They look and feel exactly the same
but one is different than the other 11. It is either slightly
heavier or slightly lighter. Using a balance scale, find
the odd brick and tell whether it is lighter or heavier than
a normal brick. Oh yes, I almost forgot to tell you. You
can only use the scale 3 times.

Thank you

Victor Manuel Reyes Viloria wrote:

During my college days I experimented with a language called Prolog.
This language was suitable to solve logic problems.
Had anybody used Ruby to solve logic problems?

Take a look at the AI section in the RAA. Peter Hickman’s SIE, expert
system’s shell might be of interest.

http://www.ruby-lang.org/en/raa-list.rhtml?name=SIE

Prolog is a special case, since it intrinsically operates on as a
theorem proving engine. There is however no reason why one could not
implement a whole variety of specialized theorem engines in Ruby - just
as one does with Lisp or C.

Another approach that offers some interesting possibilities is to
implement hybrid applications where imperative languages like Ruby are
used to perform data manipulation & distribution tasks, under the
direction of a logic engine implemented in Prolog. A kind of body/brain
split. You write such a program quite easily on a Linux system. Install
swi-prolog, or a similar implementation, and drive it from Ruby.

Aidan