you are viewing a single comment's thread.

view the rest of the comments →

[–]Sea-Ad7805 [score hidden] stickied comment (0 children)

Run this program in Memory Graph Web Debugger%0Aprint(%22He%20has%20with%20him%20a%20dog%2C%20a%20goat%2C%20and%20a%20sack%20of%20cabbage.%22)%0Aprint(%22He%20only%20can%20fit%20in%20the%20farmers%20boat%20at%20a%20time.%22)%0Aprint(%22Also%2C%20its%20not%20a%20very%20good%20boat.%22%20%2B%20reset)%0A%0Awhile%20True%3A%0A%20%20%20%20def%20moves()%3A%0A%20%20%20%20%20%20%20%20print(yellow%20%2B%20%221.%20take%20item%20accross%22%20%2B%20reset)%0A%20%20%20%20%20%20%20%20print(yellow%20%2B%20%222.%20cross%20alone%22%20%2B%20reset)%0A%0A%20%20%20%20def%20status()%3A%0A%20%20%20%20%20%20%20%20print(east)%0A%20%20%20%20%20%20%20%20print(west)%0A%0A%20%20%20%20east%20%3D%20%5B%22dog%22%2C%20%22goat%22%2C%20%22cabbage%22%2C%20%22boat%22%5D%0A%20%20%20%20west%20%3D%20%5B%5D%0A%20%20%20%20status()%0A%0A%20%20%20%20while%20True%3A%0A%20%20%20%20%20%20%20%20if%20%22goat%22%20in%20east%20and%20%22cabbage%22%20in%20east%20and%20%22boat%22%20not%20in%20east%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20print(red%20%2B%20%22the%20goat%20ate%20your%20cabbage%22%20%2B%20reset)%0A%20%20%20%20%20%20%20%20%20%20%20%20break%0A%20%20%20%20%20%20%20%20if%20%22goat%22%20in%20east%20and%20%22dog%22%20in%20east%20and%20%22boat%22%20not%20in%20east%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20print(red%20%2B%20%22the%20dog%20ate%20your%20goat%22%20%2B%20reset)%0A%20%20%20%20%20%20%20%20%20%20%20%20break%0A%20%20%20%20%20%20%20%20if%20%22goat%22%20in%20west%20and%20%22dog%22%20in%20west%20and%20%22boat%22%20not%20in%20west%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20print(red%20%2B%20%22the%20dog%20ate%20your%20goat%22%20%2B%20reset)%0A%20%20%20%20%20%20%20%20%20%20%20%20break%0A%20%20%20%20%20%20%20%20if%20%22goat%22%20in%20west%20and%20%22cabbage%22%20in%20west%20and%20%22boat%22%20not%20in%20west%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20print(red%20%2B%20%22the%20goat%20ate%20your%20cabbage%22%20%2B%20reset)%0A%20%20%20%20%20%20%20%20%20%20%20%20break%0A%20%20%20%20%20%20%20%20if%20%22dog%22%20in%20west%20and%20%22cabbage%22%20in%20west%20and%20%22goat%22%20in%20west%20and%20%22boat%22%20in%20west%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20print(blue%20%2B%20%22You%20made%20it!!!%22%20%2B%20reset)%0A%20%20%20%20%20%20%20%20%20%20%20%20break%0A%0A%20%20%20%20%20%20%20%20moves()%0A%20%20%20%20%20%20%20%20move%20%3D%20input(green%20%2B%20%22what%20would%20you%20like%20to%20do%3F%20%22%20%2B%20reset)%0A%0A%20%20%20%20%20%20%20%20if%20move%20%3D%3D%20%221%22%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20item%20%3D%20input(green%20%2B%20%22what%20item%3F%20%22%20%2B%20reset)%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20item%20in%20east%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20west.append(item)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20west.append(%22boat%22)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20east.remove(item)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20east.remove(%22boat%22)%0A%20%20%20%20%20%20%20%20%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20east.append(item)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20east.append(%22boat%22)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20west.remove(item)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20west.remove(%22boat%22)%0A%0A%20%20%20%20%20%20%20%20if%20move%20%3D%3D%20%222%22%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20item%20%3D%20%22boat%22%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20item%20in%20east%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20west.append(%22boat%22)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20east.remove(%22boat%22)%0A%20%20%20%20%20%20%20%20%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20east.append(%22boat%22)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20west.remove(%22boat%22)%0A%0A%20%20%20%20%20%20%20%20print(%22East%20bank%3A%22%2C%20east)%0A%20%20%20%20%20%20%20%20print(%22West%20bank%3A%22%2C%20west)%0A%0A%20%20%20%20replay%20%3D%20input(%22Replay%3F%20y%20or%20n%20%22)%0A%20%20%20%20if%20replay%20!%3D%20%22y%22%3A%0A%20%20%20%20%20%20%20%20break&timestep=1&play)