Math Is Fun Forum

  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#1 2012-09-02 00:28:30

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

Zebra Puzzles and Computers

I am looking for a way by which we can solve a Zebra Puzzle using programming where Inputs are given in the form of properties and conditions.

Any help is appreciated


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.

Offline

#2 2012-09-02 03:32:11

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Zebra Puzzles and Computers

Hi Agnishom;

Some logic problems can be solved very easily by using boolean variables and a couple of loops.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#3 2012-09-03 00:27:29

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

Re: Zebra Puzzles and Computers

What about these ones?


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.

Offline

#4 2012-09-03 01:21:48

anonimnystefy
Real Member
From: Harlan's World
Registered: 2011-05-23
Posts: 16,049

Re: Zebra Puzzles and Computers

Hi bobbym

What would be the input form?


“Here lies the reader who will never open this book. He is forever dead.
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment
The knowledge of some things as a function of age is a delta function.

Offline

#5 2012-09-03 02:33:45

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Zebra Puzzles and Computers

Hi Agnishom;

What about these ones?

I never worked on one that big with that method.

anonimnystefy wrote:

What would be the input form?

Input form?

I only remember the technique from having read a paper on it in a journal. I could copy their results and two problems and maybe one of you guys can apply it to a larger problem...


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#6 2012-09-04 23:31:41

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

Re: Zebra Puzzles and Computers

Hmm I decided to do it with loops
.
.
Then I wrote the full code
.
.
Then I found the program is taking a loooooong time
.
.
Then I remembered that there are 24883200000 possible permutations. So it will take forever -_-"

However, there are some constraint programming solutions to this one


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.

Offline

#7 2012-09-05 00:15:18

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Zebra Puzzles and Computers

Hi;

Since the variables are of type boolean they can only take two values of 0 and 1. You should adjust your loops for 0 to 1.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#8 2012-09-05 16:43:34

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

Re: Zebra Puzzles and Computers

But I am talking about Zebra Puzzles which have so many possible permutations.

How can I do that with them?


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.

Offline

#9 2012-09-05 21:31:30

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Zebra Puzzles and Computers

Hi Agnishom;

How can I do that with them?

I do not know how to apply the idea to a larger problem or even a smaller one. I never really understood what the guy was doing.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#10 2012-09-06 01:43:42

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

Re: Zebra Puzzles and Computers

Which guy?

By the way, how does constraint programming do it so easily?


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.

Offline

#11 2012-09-06 01:51:33

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Zebra Puzzles and Computers

I am not sure you can say that it is done easily. It just is a method that can be done by a computer.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#12 2012-09-06 03:07:04

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

Re: Zebra Puzzles and Computers

Sorry, I mean it is done very fast


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.

Offline

#13 2012-09-06 03:09:58

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Zebra Puzzles and Computers

Hi Agnishom;

When I find the paper I will post how he does a simple logic problem. Then maybe someone will figure out a way.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#14 2012-12-23 07:02:44

muxdemux
Member
Registered: 2012-12-23
Posts: 80

Re: Zebra Puzzles and Computers

I think the Zebra puzzle can be formulated as a constraint satisfaction problem and solved that way.

It can also be solved very easily using logic programming. If you search for "Prolog zebra puzzle" (or similar) in Google, you should be able to find a 15-liner to solve it. Prolog's special trick is to use something called "backtracking," though that's a separate topic.

Edit: My bad. There's a 15-line Sudoku solver. I was about to post in a different thread about a Sudoku solver and got confused. hmm

Last edited by muxdemux (2012-12-23 07:42:37)

Offline

#15 2012-12-23 07:18:53

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Zebra Puzzles and Computers

Hi;

Seems like a good error. There is a prolog program that can be found.

http://en.literateprograms.org/index.ph … ldid=18673

http://en.literateprograms.org/Zebra_Pu … 8Prolog%29

Here are implementations in several languages.

http://rosettacode.org/wiki/Zebra_puzzle


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#16 2012-12-26 15:18:52

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

Re: Zebra Puzzles and Computers

Thanks for the links


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.

Offline

#17 2012-12-26 20:03:23

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Zebra Puzzles and Computers

How have you come with your date and days of the week?


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#18 2012-12-27 22:33:23

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

Re: Zebra Puzzles and Computers

I will talk about that once I return home. I am back to that remote village where its tough to get connected.


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.

Offline

#19 2012-12-28 07:05:47

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Zebra Puzzles and Computers

Hi;

Enjoy your solitude then. We will talk then.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

Board footer

Powered by FluxBB