House 2: Mrs. Chandler, serving toast to the blackbird
House 4: Mrs. Dennis, serving bread to the sparrow
House 6: Mrs. Allison, serving birdseed to the thrush
House 8: Mrs. Emery, serving cake to the cardinal
House 10: Mrs. Brewer, serving suet to the robin
Logic Solution
Birdseed was not eaten by the robin (3), the cardinal (4), or the sparrow (4); it was not in a house on either end (4) and thus was not eaten by the blackbird (5). The thrush ate the birdseed.
Mrs. Allison lives next door to the sparrow (4) and the cardinal (4); she does not live next to the blackbird in house two (5), nor can she live in either of the end houses two and ten (4) or in house eight (2).
Mrs. Allison lives in house six, where she put out birdseed for the thrush.
House ten was not visited by the sparrow (4), the cardinal (4), the thrush (above), or the blackbird (5); it was visited by the robin.
If the cake was served in house two, Mrs. Brewer would live next door in house four (1), with Mrs. Allison in house six (above) and Mrs. Emery in eight (2). Mrs. Dennis is not in ten (2), so she would be in two and Mrs. Chandler would be in ten. However, Mrs. Chandler put out toast (1) but the robin ate suet (3); this contradiction means the cake must not have been served at house two.
House two did not serve cake (above), suet (3), birdseed (above), or bread (5).
The bird feeder at house two was filled with toast, served by Mrs. Chandler (1) and eaten by the blackbird (5).
The next-door neighbors to house four serve toast and birdseed (above); Mrs. Brewer does not live in house four (1). Mrs. Brewer does not live in house two (above), six (above) or eight (2).
Mrs. Brewer lives in house ten, where she served suet to the robin
The sparrow ate next to house six (4) but not in house eight (2); the sparrow visited house four while the cardinal visited eight (4).
Cake was served at house eight (1) by Mrs. Emery (2) and eaten by the cardinal (above).
Finally, by elimination:
Number four is the home of Mrs. Dennis, who put out bread for the sparrow.
Programmatic Solution (written in Alloy)
abstract sig object {}
abstract sig Lady extends object {}
abstract sig Food extends object {}
abstract sig Bird extends object {}
abstract sig House { v: set object, n: set House }
one sig Allison,Brewer,Chandler,Dennis,Emery extends Lady {}
one sig blackbird,cardinal,robin,sparrow,thrush extends Bird {}
one sig bread,birdseed,cake,suet,toast extends Food {}
one sig two,four,six,eight,ten extends House {}
fun h[o:object]: one House { { house:House | o in house.v } }
pred n[a,b:object] { a.h in b.h.n }
pred n[o:object, i:House] { o.h in i.n }
pred s[a,b:object] { a.h = b.h }
pred s[o:object, i:House] { o in i.v }
fact houses {
all o:object | some i:House | o in i.v
all i:House | one i.v&Lady && one i.v&Food && one i.v&Bird
all x:House, y:House-x | no x.v&y.v
}
fact neighbors {
two.n = four
four.n = two+six
six.n = four+eight
eight.n = six+ten
ten.n = eight
}
pred clues {
// clue 1
cake.n[Brewer]
Chandler.s[toast]
// clue 2
not Emery.s[sparrow]
Emery.s[eight]
not Dennis.s[ten]
// clue 3
Allison.s[thrush]
robin.s[suet]
// clue 4
birdseed.n[cardinal]
birdseed.n[sparrow]
// clue 5
blackbird.s[two]
not bread.s[two]
}
run clues for 5 |