Questions tagged [zebra-puzzle]

A Zebra-puzzle is a combinatorial logic puzzle. Also known as Einstein's riddle, Caliban's problem, Five Houses Puzzle.

A Zebra-puzzle is a combinatorial logic puzzle. Also known as Einstein's riddle, Caliban's problem, Five Houses Puzzle.

112 questions
129
votes
15 answers

Solving "Who owns the Zebra" programmatically?

Edit: this puzzle is also known as "Einstein's Riddle" The Who owns the Zebra (you can try the online version here) is an example of a classic set of puzzles and I bet that most people on Stack Overflow can solve it with pen and paper. But what…
23
votes
6 answers

Algorithmically generate a Zebra/Einstein puzzle

Firstly I'm not necessarily looking for a complete algorithm I can just copy and paste, then call it a day. Any "general approach" solutions would be fine for me! This entire post was spurred by a slow day at work, and stumbling upon this site and…
Weaver
  • 619
  • 1
  • 4
  • 12
14
votes
3 answers

Einsteins Riddle Prolog

I need some help with a prolog homework for my AI class. The question is to write prolog code for einstein's puzzle. I know how to write it down in my own but there are some constraints in the homework. there are 5 houses the Englishman lives in…
Gasim
  • 7,615
  • 14
  • 64
  • 131
6
votes
2 answers

Mrs. Rosencrantz' Jess query (a Zebra Puzzle) expressed in Prolog

In the book Jess in Action - Rule-Based Systems in Java (written more than 10 years back; I think Drools is the system to use today?), Ernest Friedman-Hill solves the constraint problem given below using Jess, an OPS5-style forward-chaining…
David Tonhofer
  • 14,559
  • 5
  • 55
  • 51
6
votes
2 answers

Solving the Zebra puzzle (aka. Einstein puzzle) using the clpfd Prolog library

I have been given an exercise to solve the zebra puzzle using a constraint solver of my choice, and I tried it using the Prolog clpfd library. I am aware that there are other more idiomatic ways to solve this problem in Prolog, but this question is…
fresskoma
  • 25,481
  • 10
  • 85
  • 128
5
votes
2 answers

Solving logic puzzle in Prolog

I am reading "Learn Prolog Now" and one of its exercises I haven't been able to solve myself is the following: There is a street with three neighboring houses that all have a different color. They are red, blue, and green. People of…
nunos
  • 20,479
  • 50
  • 119
  • 154
5
votes
1 answer

Unique elements in list (Prolog)

I'm implementing a variation on Einstein's Riddle and i'm having some trouble. When trying to calculate the solution i try this: solve(Street) :- Street = [_House1,_House2,_House3,_House4,_House5], %hint one goes here %hint two goes here %etc. I…
Aerus
  • 4,332
  • 5
  • 43
  • 62
5
votes
0 answers

Einstein's Riddle solution using F#

I'm looking for Einstein's Riddle solution using F# and I've found only Einstein meets F#. Is F# suitable for this problem and are there any other implementations?
Pavel Hodek
  • 14,319
  • 3
  • 32
  • 37
4
votes
2 answers

Prolog Logic Puzzle not working?

I have been working on this Prolog logic problem for awhile. It is getting incorrect results and it is taking awhile to run the program itself which is what concerns me more. The logic problem goes as follows: Alex, Bret, Chris, Derek, Eddie,…
MasterYork42
  • 228
  • 2
  • 11
4
votes
1 answer

Solving Einstein Riddle in Prolog

I am trying to solve Einstein Riddle in Prolog. I am having a difficulty with the program I wrote, the basic method was to add all constraints and let Prolog figure out the only possible solutions. The problem is that Prolog finds 0 solutions. I…
Belgi
  • 14,542
  • 22
  • 58
  • 68
4
votes
5 answers

Prolog if else syntax

I can't seem to get my if else statement to work. John, Fred and Harry are men, Mary, Julie, Susan and Anne are women. John has blonde hair while Fred and Harry have dark hair. Julie and Susan are blonde, Mary and Anne are brunette. Rich is each…
SuperCell
  • 241
  • 1
  • 12
3
votes
1 answer

Why cant i get the answer to the zebra puzzle in prolog?

this is my code currently, I am trying to solve the zebra…
Heidi
  • 249
  • 1
  • 3
  • 9
3
votes
1 answer

Prolog Room Adjacency Puzzle

I am working on an assignment and I have to write a prolog program to solve a puzzle where there are 5 rooms and there are five people, Hunter, Laura, Arnie, Addiley and Ramey. Hunter cannot be in room 5, Laura cannot be in room 1, Arnie cannot be…
Nic Ceccanti
  • 163
  • 1
  • 1
  • 7
3
votes
1 answer

Python: print n random items from a list but output must satify multiple rules

In python, I want to print a smaller list of randomly selected strings from a larger list of strings, returning n items. However, the resulting smaller list must have conditions applied to it so that certain items can't exist together in the new…
Theo F
  • 1,197
  • 1
  • 11
  • 18
3
votes
1 answer

python logic puzzle relationships

Attempting to use Logic to solve the following in python: from kanren import run, eq, membero, var, conde from kanren.constraints import neq, isinstanceo rules = (eq, (var(), var(), var(), var()), people), (membero, (4, x, ('Steve' ,…
1
2 3 4 5 6 7 8