]/[Prolog], this problem would be [trivial] to solve.\r\n\r\n

4.6 The [standard approach].

\r\n\r\n

We know what a Lion is from [ISO] 4711/X.123. Since [CCITT] have specified a Lion to be a [particular option] of a [cat] we will have to wait for a [harmonized standard] to appear. $20,000,000 have been [fund]ed for [initial investigations] into this [standard development].\r\n\r\n

[linear search|4.7 Linear search.]

\r\n\r\n

Stand in the top left hand [corner] of the Sahara Desert. Take one [step] east. Repeat until you have found the lion, or you reach the right hand edge. If you reach the right hand [edge], take one step southwards, and proceed towards the left hand edge. When you finally reach the lion, put it the cage. If the lion should happen to eat you before you manage to get it in the cage, press the [reset button], and try again.\r\n

Optionally, [experienced programmer]s will place a [pink elephant] in [Johannesburg] as a [sentinel value]. (thanks [ariels])\r\n \r\n

[Dijkstra's algorithm |4.8 The Dijkstra approach:]

\r\n\r\n

The way the problem reached me was: catch a wild lion in the Sahara\r\nDesert. [Another way of stating the problem] is:\r\n\r\n

\r\n       [Axiom] 1: Sahara [elem] deserts\r\n       Axiom 2: Lion elem Sahara\r\n       Axiom 3: NOT(Lion elem cage)\r\n
\r\n

We observe the following invariant:\r\n\r\n

       P1:     C(L) v not(C(L))\r\n
\r\n

where C(L) means: the value of \"L\" is in the cage.\r\n\r\n

Establishing C initially is trivially accomplished with the statement\r\n\r\n

       ;cage := {}\r\nNote 0:\r\n[This is easily implemented] by opening the door to the \r\ncage and shaking out any lions that happen to be there \r\ninitially.\r\n(End of note 0.)\r\n
\r\n

The obvious [program structure] is then:\r\n

\r\n       ;cage:={}\r\n       ;do NOT (C(L)) ->\r\n               ;\"approach lion under [invariance] of P1\"\r\n               ;if P(L) ->\r\n                       ;\"insert lion in cage\"\r\n                [] not P(L) ->\r\n                       ;skip\r\n               ;fi\r\n       ;od\r\n\r\nwhere P(L) means: the value of L is within arm's reach.\r\n\r\nNote 1:\r\nAxiom 2 ensures that the [loop termination|loop terminates].\r\n(End of note 1.)\r\n\r\nExercise 0:\r\nRefine the step \"Approach lion under invariance of P1\".\r\n(End of exercise 0.)\r\n\r\nNote 2:\r\nThe program is [robust] in the sense that it will lead to\r\n[abortion] if the value of L is \"lioness\".\r\n(End of note 2.)\r\n\r\nRemark 0: This may be a new sense of the word \"robust\" for you.\r\n(End of remark 0.)\r\n\r\nNote 3:\r\n\r\nFrom observation we can see that the above program leads to the\r\n[desired goal]. It goes without saying that we therefore do not \r\nhave to [run] it.\r\n(End of note 3.)\r\n(End of approach.) \r\n(End of document)\r\n
\r\n\r\n         
\r\n\r\n

You can find an infinity of variations on the above [theme] floating around in the [cyberspace] (and probably in [dead tree] format too), but some of them tend to wear the concept a bit [thin]...

","writeuptype":"idea","title":"How To Catch a Lion in the Sahara Desert (idea)","author":{"is_bot":0,"lasttime":"2024-10-24T07:10:44Z","hidelastseen":0,"type":"user","node_id":1477422,"title":"drdave"},"publishtime":"2003-07-21T21:02:14Z","createtime":"2003-07-21T21:02:14Z","type":"writeup","node_id":1478484}],"softlinks":[{"hits":20,"title":"I would have cooled this if you had written it","filled":true,"type":"e2node","node_id":"705766"},{"title":"An interesting application of binary search","hits":10,"type":"e2node","filled":true,"node_id":"1290215"},{"filled":true,"type":"e2node","node_id":"551463","hits":6,"title":"Dijkstra's algorithm"},{"filled":true,"type":"e2node","node_id":"95609","hits":6,"title":"geek humor"},{"hits":5,"title":"10 questions to ask myself after waking up in a dumpster","filled":true,"node_id":"1074199","type":"e2node"},{"type":"e2node","filled":true,"node_id":"845014","title":"Monte Carlo Simulation","hits":4},{"node_id":"106934","filled":true,"type":"e2node","hits":4,"title":"Sahara"},{"filled":true,"type":"e2node","node_id":"1317320","hits":3,"title":"Hilbert's axioms"},{"title":"Peano monster curve","hits":3,"filled":true,"type":"e2node","node_id":"1136054"},{"type":"e2node","filled":true,"node_id":"17785","hits":3,"title":"theoretical physics"},{"filled":true,"type":"e2node","node_id":"1198931","hits":2,"title":"sentinel value"},{"hits":2,"title":"Enoch Root","filled":true,"type":"e2node","node_id":"772794"},{"filled":true,"node_id":"606605","type":"e2node","hits":2,"title":"Game Hunting"},{"title":"The Lion, the Mouse, and the Fox","hits":2,"filled":true,"node_id":"373812","type":"e2node"},{"title":"The Bees Made Honey in the Lion's Skull","hits":1,"type":"e2node","filled":true,"node_id":"1969853"},{"hits":1,"title":"Las Vegas","node_id":"1959233","filled":true,"type":"e2node"},{"title":"Modern Talking","hits":1,"filled":true,"type":"e2node","node_id":"1735451"},{"hits":1,"title":"exchange operator","filled":false,"node_id":"1733820","type":"e2node"},{"title":"Majorana","hits":1,"filled":false,"node_id":"1673839","type":"e2node"},{"node_id":"1537115","filled":true,"type":"e2node","hits":1,"title":"Reel Bad Arabs"},{"title":"Eigenstate","hits":1,"node_id":"1297455","filled":true,"type":"e2node"},{"node_id":"515249","filled":true,"type":"e2node","title":"cult classic","hits":1},{"hits":1,"title":"The Lion, The Other Lion and the Kipper","filled":true,"node_id":"433225","type":"e2node"},{"title":"Lioness","hits":1,"type":"e2node","filled":true,"node_id":"272376"}],"createtime":"2003-07-21T20:52:24Z","author":{"type":"usergroup","node_id":923653,"title":"Content Editors"},"orderlock_user":0,"createdby":{"type":"user","node_id":1477422,"title":"drdave"},"type":"e2node","node_id":1478480,"title":"How To Catch a Lion in the Sahara Desert","locked":0},"type":"e2node"},"chatterbox":{"roomTopic":"Massive site change may have surfaced various issues. See: [root log: mid-December 2025: Writeup display overhaul], and report any problems. - Publication problems fixed. Thank you -[jaybonci|jb]","miniMessages":[],"messages":[],"showMessagesInChatterbox":1,"roomName":"outside"},"lastCommit":"7fea468468c9e694b51ba1c454cddfde8737139c"}