150 likes | 272 Vues
Three jealous couples. Problem statement. Three couples (husband and wife) wish to cross a river. They have only one boat that can carry at most 2 people. The husbands are so jealous that none is willing to allow their wife to be with another man if they themselves are not present.
E N D
Problem statement • Three couples (husband and wife) wish to cross a river. They have only one boat that can carry at most 2 people. The husbands are so jealous that none is willing to allow their wife to be with another man if they themselves are not present. • How can all 3 couples get across the river.
Symmetries • There are a couple of symmetries that might help us solve the problem. • We could get each couple across individually. • We could get all the women across first. • We could get all the men across first.
Notation • We use H, W, C to denote husband, wife and couple (H+W). • 2H means two husbands • 1C, 2H means one couple and two husbands. • 1H, 1W mean a husband and wife who are not a couple. • Note we do not name people e.g. Alice, Bob, Clare… as it is only the number that is relevant
States • A state describes a situation where each person is on the left or right river bank. • 3H||3W means 3 husbands on left bank and 3 wives on right bank • 1C, 2H || 2W denotes one couple and two husbands on the left and two wives on the right.
Action • An action is a state transition (verb) • An action is a person(s) being transported across the river. • 3H|2W|1W means two wives are crossing the river. • Not that this does not say if the boat is going left or right • Is this abiguous.
Invalid States • This notation allows valid and invalid states to be identified easily. • 1C, 1W||1C, 1H is invalid, why? • 3H|3W| is invalid, why?
Problem statement • Start state 3C|| • Final state ||3C • A solution is sequence of actions from the start state to the final state. • {3C||} • S? • {||3C}
Sequence of actions • An action results in a state change. • If p and q denote states, and S is a sequence of actions • {p} • S • {q} • A sequence of actions S will take us from state p to state q.
Sequence of actions e.g. • {2C, 1H||1W} //state • 3H|2W|1W //action • {3H||3W} //state
Problem Decomposition • {3C||} S0 {||3C} //start • We can decompose this into the following. • {3C||} S1 {3H||3W}, • {3H||3W} S2 {3W||3H}, • {3W||3H}S3 {||3C} , • What do you notice about S1 and S3
S1 • {3C||} • 1C, 2H | 2W| • {1C, 2H||2W} • 1C, 2H|W|W • {2C, 1H||1W} • 3H|2W|1W • {3H||3W}
S2 • We can break S2 down into two parts • {3H||3W} • T1 • {1C|1C|1C} • T2 • {3W||3H} • What can we say about T1 and T2.
T1 • {3H||3W} • 3H|1W|2W • {1C, 2H||2W} • 1C|2H|2W • {1C||2C} • And T2 is just the reverse.