Skip to content

Instantly share code, notes, and snippets.

@josgraha
Last active August 29, 2015 14:24
Show Gist options
  • Save josgraha/ca34676e53bc72dcbbca to your computer and use it in GitHub Desktop.
Save josgraha/ca34676e53bc72dcbbca to your computer and use it in GitHub Desktop.
Husband Wife Crossing Problem

solved by: @sprimerano

mv | cross | left | right | return | left | right --- | --- | --- | --- |--- | --- | --- | ---

| -> xy | {A,B,Cz} | {x,y} | <- x | {Ax,B,Cz} | {x}

| -> xz | {A,B,C} | {x,y,z} | <- x | {Ax,B,C} | {y,z}

| -> BC | {Ax} | {By,Cz} | <- By | {Ax,By} | {Cz}

| -> AB | {x,y} | {A,B,Cz} | <- z | {x,y,z} | {A,B,C}

| -> xy | {z} | {Ax,By,C} | <- x | {x,z} | {A,By,C}

| -> xz | {} | {Ax,By,Cz}

Three married couples, Al and Xenia, Bill and Yvette, and Carl and Zoe, are out for a hike when they come to a river. The good news is they find a boat; the bad news is the boat holds, at most, two people at a time. The problem is that the men are very amorous and will kiss any wife who is separated from her husband. The husbands are also very jealous, so how can the three couples cross the river without any illicit kissing occurring? Present your answer as a sequential list of the occupants of the boat as it makes multiple crossings of the river. To make grading easier, when there is an option for whom to put in the boat, choose the one or two eligible persons whose names come first alphabetically.

—The Chicken from Minsk by Yuri Chernyak and Robert Rose

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment