Einstein quiz: Difference between revisions

From Opasnet
Jump to navigation Jump to search
(links added)
(→‎Answer: added possibility graph)
Line 57: Line 57:
*        The man who smokes Blend has a neighbor who drinks water.
*        The man who smokes Blend has a neighbor who drinks water.


<rcode include="page:Opasnet_(R_library)|name:answer">
<rcode include="page:Opasnet_(R_library)|name:answer"
graphics="1">
library(reshape)
library(reshape)
library(ggplot2)
a <- data.frame(A = c("A", "B", "C", "D", "E"), B = c("a", "b", "c", "d", "e"), C = c("1", "2", "3", "4", "5"))
a <- data.frame(A = c("A", "B", "C", "D", "E"), B = c("a", "b", "c", "d", "e"), C = c("1", "2", "3", "4", "5"))
e <- data.frame(F = c("A", "a", 1), S = c("b", "2", "D"))
e <- data.frame(F = c("A", "a", 1), S = c("b", "2", "D"))
Line 100: Line 103:
print(xtable(d), type = 'html', html.table.attributes = "class='sortable'")
print(xtable(d), type = 'html', html.table.attributes = "class='sortable'")


ggplot(d, aes(Nationality, weight=1, fill=Pet)) + geom_bar(position="dodge") +
scale_x_discrete("Nationality") + scale_y_continuous("Frequency")
</rcode>
</rcode>



Revision as of 04:21, 13 August 2012

The Einstein quiz is a logic puzzle.

Question

How to solve the Einstein quiz [1] and similarly structured problems using R-tools?

Facts:

  • There are 5 houses in 5 different colors.
  • In each house lives a person with a different nationality.
  • These 5 owners drink a certain beverage, smoke a certain brand of cigar and keep a certain pet.
  • No owners have the same pet, smoke the same brand of cigar or drink the same drink.
  • Hints:
    • The Brit lives in a red house.
    • The Swede keeps dogs as pets.
    • The Dane drinks tea.
    • The green house is on the left of the white house.
    • The green house owner drinks coffee.
    • The person who smokes Pall Mall rears birds.
    • The owner of the yellow house smokes Dunhill.
    • The man living in the house right in the centre drinks milk.
    • The Norwegian lives in the first house.
    • The man who smokes Blend lives next to the one who keeps cats.
    • The man who keeps horses lives next to the man who smokes Dunhill.
    • The owner who smokes Blue Master drinks beer.
    • The German smokes Prince.
    • The Norwegian lives next to the blue house.
    • The man who smokes Blend has a neighbor who drinks water.

Question:

Can you determine who keeps fish?

Answer

The known relations as a table.

Einstein quiz: Difference between revisions(-)
ObsFirstSecond
1BritRed house
2SwedeDog
3DaneTea
4Green houseCoffee
5Pall MallBird
6Yellow houseDunhill
7House 3Milk
8NorwegianHouse 1
9Blue MasterBeer
10GermanPrince

These cannot be solved with this solver:

  • The green house is on the left of the white house.
  • The man who smokes Blend lives next to the one who keeps cats.
  • The man who keeps horses lives next to the man who smokes Dunhill.
  • The Norwegian lives next to the blue house.
  • The man who smokes Blend has a neighbor who drinks water.

+ Show code

Rationale

See also

References


Related files

<mfanonymousfilelist></mfanonymousfilelist>