This question was originally from a DB course, people were supposed to solve it by means of Petrinetz: Say we have a mum elephant, baby elephant, mum tiger, baby tiger, mum lion and baby lion, they six are initially all at one bank of the river. There's a boat with capicity of 2 animals( no matter the animal is an adult or a baby ). A baby without its mum would be eaten by other adult. Say if you transport a baby tiger and baby lion to the other bank, but there's only a mum tiger waiting at the other bank, so the baby lion would be eaten by the mum tiger. Now try to transport all the animals safely to the other bank.
ME = Mommy Elephant BE = Baby Elephant ML = Mommy Lion BL = Baby Lion MT = Mommy Tiger BT = Baby Tiger Left Bank In Boat Right Bank ___________________________________________ ME BE MT BT ML BL MT BT ML BL ME BE -> MT BT ML BL <- ME BE ME ML MT BT BL -> BE ME ML MT <- BT BE BL MT BT ME MT -> BE BT MT BT <- ML BL ME BE BT BL ML MT -> ME BE BT BL <- BE ME ML MT BE BT BL -> ME ML MT BE <- BL ME ML MT BT BE BL -> ME ML MT BT ME BE ML BL MT BT
posted 15 years ago
ME BE MT BT ML BL MT BT ML BL ME BE -> MT BT ML BL <- ME BE ME ML MT BT BL -> BE ME ML MT <- BT BE BL MT BT ME MT -> BE BT MT BT <- ML BL ME BE BT BL ML MT -> ME BE BT BL <- BE ME ML MT BE BT BL -> ME ML MT BE <- BL ME ML MT BT BE BL -> ME ML MT BT ME BE ML BL MT BT Wow my formatting didn't work. 1) Send ME BE 2) Return ME (leave BE) 3) Send BL BT (leave BE BL) 4) Return BT 5) Send ME ML (leave ME BE) 6) Return ML BL 7) Send ML MT (leave ME ML MT) 8) Return BE 9) Send BT BE (leave ME ML MT BE) 10) Return BT 11) Send BT BL (all across)
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database