]/[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]...

","title":"How To Catch a Lion in the Sahara Desert (idea)"}],"createtime":"2003-07-21T20:52:24Z","softlinks":[{"filled":true,"type":"e2node","hits":20,"node_id":"705766","title":"I would have cooled this if you had written it"},{"title":"An interesting application of binary search","node_id":"1290215","hits":10,"filled":true,"type":"e2node"},{"filled":true,"type":"e2node","node_id":"551463","hits":6,"title":"Dijkstra's algorithm"},{"type":"e2node","filled":true,"node_id":"95609","hits":6,"title":"geek humor"},{"filled":true,"type":"e2node","hits":5,"node_id":"1074199","title":"10 questions to ask myself after waking up in a dumpster"},{"filled":true,"type":"e2node","node_id":"845014","hits":4,"title":"Monte Carlo Simulation"},{"title":"Sahara","filled":true,"type":"e2node","node_id":"106934","hits":4},{"title":"Hilbert's axioms","filled":true,"type":"e2node","hits":3,"node_id":"1317320"},{"filled":true,"type":"e2node","hits":3,"node_id":"1136054","title":"Peano monster curve"},{"type":"e2node","filled":true,"node_id":"17785","hits":3,"title":"theoretical physics"},{"title":"sentinel value","node_id":"1198931","hits":2,"filled":true,"type":"e2node"},{"hits":2,"node_id":"772794","filled":true,"type":"e2node","title":"Enoch Root"},{"title":"Game Hunting","filled":true,"type":"e2node","node_id":"606605","hits":2},{"title":"The Lion, the Mouse, and the Fox","hits":2,"node_id":"373812","filled":true,"type":"e2node"},{"title":"The Bees Made Honey in the Lion's Skull","hits":1,"node_id":"1969853","filled":true,"type":"e2node"},{"filled":true,"type":"e2node","node_id":"1959233","hits":1,"title":"Las Vegas"},{"hits":1,"node_id":"1735451","filled":true,"type":"e2node","title":"Modern Talking"},{"title":"exchange operator","type":"e2node","filled":false,"hits":1,"node_id":"1733820"},{"title":"Majorana","hits":1,"node_id":"1673839","type":"e2node","filled":false},{"hits":1,"node_id":"1537115","type":"e2node","filled":true,"title":"Reel Bad Arabs"},{"hits":1,"node_id":"1297455","type":"e2node","filled":true,"title":"Eigenstate"},{"type":"e2node","filled":true,"node_id":"515249","hits":1,"title":"cult classic"},{"title":"The Lion, The Other Lion and the Kipper","node_id":"433225","hits":1,"type":"e2node","filled":true},{"hits":1,"node_id":"272376","type":"e2node","filled":true,"title":"Lioness"}],"author":{"type":"usergroup","node_id":923653,"title":"Content Editors"},"locked":0,"title":"How To Catch a Lion in the Sahara Desert"}},"user":{"admin":false,"developer":false,"title":"Guest User","editor":false,"in_room":0,"guest":true,"node_id":"779713","chanop":false},"node_id":"1478480","newWriteups":[{"writeuptype":"poetry","node_id":"2214208","is_junk":false,"is_log":false,"notnew":false,"title":"The plum you're going to eat this summer (poetry)","parent":{"node_id":2214207,"type":"e2node","title":"The plum you're going to eat this summer"},"author":{"node_id":2061110,"type":"user","title":"rosetinted"}},{"notnew":false,"title":"worst coffee ever (thing)","author":{"title":"wertperch","node_id":958245,"type":"user"},"is_junk":false,"node_id":"2214203","writeuptype":"thing","is_log":false,"parent":{"type":"e2node","node_id":2214202,"title":"worst coffee ever"}},{"is_junk":false,"node_id":"2214155","writeuptype":"thing","is_log":false,"notnew":false,"title":"coffee processing methods (thing)","parent":{"title":"coffee processing methods","node_id":2214118,"type":"e2node"},"author":{"node_id":958245,"type":"user","title":"wertperch"}},{"notnew":false,"title":"Caffe Cappuccino (thing)","author":{"type":"user","node_id":958245,"title":"wertperch"},"is_log":false,"is_junk":false,"node_id":"2214199","writeuptype":"thing","parent":{"title":"Caffe Cappuccino","type":"e2node","node_id":36121}},{"author":{"type":"user","node_id":958245,"title":"wertperch"},"parent":{"title":"cafe culture","type":"e2node","node_id":927430},"title":"cafe culture (thing)","notnew":false,"is_log":false,"writeuptype":"thing","is_junk":false,"node_id":"2214198"},{"parent":{"node_id":2211969,"type":"e2node","title":"caffe latte"},"title":"caffe latte (thing)","author":{"node_id":958245,"type":"user","title":"wertperch"},"is_log":false,"is_junk":false,"node_id":"2214197","writeuptype":"thing","notnew":false},{"notnew":false,"author":{"title":"Pandeism Fish","type":"user","node_id":1902455},"title":"Check yourself before you wreck yourself (thing)","is_log":false,"node_id":"2214196","writeuptype":"thing","is_junk":false,"parent":{"title":"Check yourself before you wreck yourself","type":"e2node","node_id":1418722}},{"notnew":false,"author":{"node_id":977360,"type":"user","title":"Glowing Fish"},"title":"Goosebumps #15: You Can't Scare Me (review)","writeuptype":"review","node_id":"2214194","is_junk":false,"is_log":false,"parent":{"type":"e2node","node_id":2214193,"title":"Goosebumps #15: You Can't Scare Me"}},{"notnew":false,"title":"quandary (poetry)","author":{"type":"user","node_id":1992599,"title":"lostcauser"},"node_id":"2214192","is_junk":false,"writeuptype":"poetry","is_log":false,"parent":{"node_id":137535,"type":"e2node","title":"quandary"}},{"title":"The odd coffee (thing)","author":{"title":"wertperch","type":"user","node_id":958245},"notnew":false,"parent":{"node_id":2214190,"type":"e2node","title":"The odd coffee"},"node_id":"2214191","is_junk":false,"writeuptype":"thing","is_log":false},{"parent":{"title":"Through line","node_id":2214184,"type":"e2node"},"title":"Through line (thing)","author":{"title":"Dustyblue","type":"user","node_id":2068077},"is_log":false,"is_junk":false,"node_id":"2212394","writeuptype":"thing","notnew":false},{"title":"August 9, 2026 (personal)","author":{"title":"wertperch","node_id":958245,"type":"user"},"notnew":false,"parent":{"type":"e2node","node_id":2214172,"title":"August 9, 2026"},"node_id":"2214173","is_junk":false,"writeuptype":"personal","is_log":true},{"parent":{"type":"e2node","node_id":2214179,"title":"Cropped"},"is_junk":false,"writeuptype":"poetry","node_id":"2214178","is_log":false,"author":{"title":"lostcauser","node_id":1992599,"type":"user"},"title":"Cropped (poetry)","notnew":false},{"title":"A song by Armis Loustrong (poetry)","author":{"title":"Chord","node_id":2069883,"type":"user"},"notnew":false,"parent":{"node_id":2214175,"type":"e2node","title":"A song by Armis Loustrong"},"is_log":false,"node_id":"2214174","writeuptype":"poetry","is_junk":false},{"author":{"type":"user","node_id":6339,"title":"Jet-Poop"},"title":"Remarkably Bright Creatures (review)","parent":{"title":"Remarkably Bright Creatures","node_id":2214170,"type":"e2node"},"notnew":false,"is_junk":false,"node_id":"2214171","writeuptype":"review","is_log":false},{"parent":{"type":"e2node","node_id":2184996,"title":"We rode around the town late in the evening counting the streetlights to be sure all were burning"},"is_log":false,"writeuptype":"fiction","is_junk":false,"node_id":"2214169","author":{"type":"user","node_id":1252419,"title":"gate"},"title":"We rode around the town late in the evening counting the streetlights to be sure all were burning (fiction)","notnew":false},{"parent":{"title":"The Scientist's Paramour","type":"e2node","node_id":2214161},"is_log":false,"node_id":"2214162","is_junk":false,"writeuptype":"poetry","author":{"title":"Lucy-S","node_id":1184215,"type":"user"},"title":"The Scientist's Paramour (poetry)","notnew":false},{"is_log":false,"node_id":"2214106","is_junk":false,"writeuptype":"thing","notnew":false,"parent":{"node_id":2214160,"type":"e2node","title":"Promethean: the Created"},"title":"Promethean: the Created (thing)","author":{"type":"user","node_id":2068077,"title":"Dustyblue"}},{"is_log":true,"is_junk":false,"node_id":"2214157","writeuptype":"personal","notnew":false,"parent":{"type":"e2node","node_id":2214156,"title":"August 8, 2026"},"title":"August 8, 2026 (personal)","author":{"node_id":958245,"type":"user","title":"wertperch"}},{"is_junk":false,"node_id":"2214145","writeuptype":"personal","is_log":true,"notnew":false,"title":"August 7, 2026 (personal)","parent":{"node_id":2214154,"type":"e2node","title":"August 7, 2026"},"author":{"type":"user","node_id":1934284,"title":"jessicaj"}},{"notnew":false,"author":{"title":"Dustyblue","type":"user","node_id":2068077},"title":"The Great God Pan (thing)","node_id":"2214098","is_junk":false,"writeuptype":"thing","is_log":false,"parent":{"type":"e2node","node_id":2162390,"title":"The Great God Pan"}},{"parent":{"title":"I've been living my life half asleep","node_id":529328,"type":"e2node"},"is_log":false,"is_junk":false,"writeuptype":"idea","node_id":"2214030","title":"I've been living my life half asleep (idea)","author":{"title":"time thief","node_id":2208602,"type":"user"},"notnew":false},{"parent":{"title":"The Importance of Flowers","node_id":2214142,"type":"e2node"},"is_log":false,"node_id":"2214141","is_junk":false,"writeuptype":"personal","author":{"type":"user","node_id":1992599,"title":"lostcauser"},"title":"The Importance of Flowers (personal)","notnew":false},{"is_log":false,"node_id":"2214038","writeuptype":"thing","is_junk":false,"notnew":false,"parent":{"title":"The Spirits' Book","node_id":2214140,"type":"e2node"},"title":"The Spirits' Book (thing)","author":{"node_id":2068077,"type":"user","title":"Dustyblue"}},{"parent":{"type":"e2node","node_id":410021,"title":"Girl Scout Cookies"},"is_log":false,"node_id":"2214138","is_junk":false,"writeuptype":"thing","author":{"title":"wertperch","type":"user","node_id":958245},"title":"Girl Scout Cookies (thing)","notnew":false},{"title":"The lengths that I will go to (personal)","parent":{"type":"e2node","node_id":2214101,"title":"The lengths that I will go to"},"author":{"type":"user","node_id":958245,"title":"wertperch"},"is_junk":false,"node_id":"2214137","writeuptype":"personal","is_log":false,"notnew":false},{"is_log":false,"node_id":"2214134","is_junk":false,"writeuptype":"personal","parent":{"node_id":2214133,"type":"e2node","title":"How I realized that my childhood was more complex than just our lunches at The Country Cousin"},"notnew":false,"title":"How I realized that my childhood was more complex than just our lunches at The Country Cousin (personal)","author":{"title":"Glowing Fish","type":"user","node_id":977360}},{"notnew":false,"author":{"type":"user","node_id":1992599,"title":"lostcauser"},"title":"A Bird in the House (fiction)","node_id":"2214123","is_junk":false,"writeuptype":"fiction","is_log":false,"parent":{"title":"A Bird in the House","node_id":2214124,"type":"e2node"}},{"author":{"title":"hypostyle","type":"user","node_id":2178478},"title":"July 30, 2026 (log)","notnew":false,"parent":{"node_id":2214113,"type":"e2node","title":"July 30, 2026"},"is_log":true,"node_id":"2214121","writeuptype":"log","is_junk":false},{"parent":{"type":"e2node","node_id":2214119,"title":"Bible Warehouse"},"writeuptype":"thing","node_id":"2214120","is_junk":false,"is_log":false,"title":"Bible Warehouse (thing)","author":{"node_id":958245,"type":"user","title":"wertperch"},"notnew":false},{"is_log":false,"node_id":"2214114","is_junk":false,"writeuptype":"thing","notnew":false,"parent":{"title":"Plaza Inn","node_id":2214115,"type":"e2node"},"title":"Plaza Inn (thing)","author":{"node_id":2212534,"type":"user","title":"Finky"}},{"is_log":false,"writeuptype":"thing","node_id":"2214111","is_junk":false,"parent":{"title":"emotional support animal","type":"e2node","node_id":2208636},"notnew":false,"title":"emotional support animal (thing)","author":{"title":"wertperch","type":"user","node_id":958245}},{"title":"barista (thing)","parent":{"node_id":457094,"type":"e2node","title":"barista"},"author":{"node_id":958245,"type":"user","title":"wertperch"},"is_junk":false,"writeuptype":"thing","node_id":"2214109","is_log":false,"notnew":false},{"is_log":false,"node_id":"2214100","is_junk":false,"writeuptype":"personal","notnew":false,"parent":{"title":"The lengths that I will go to","node_id":2214101,"type":"e2node"},"title":"The lengths that I will go to (personal)","author":{"title":"etouffee","node_id":1153472,"type":"user"}},{"is_junk":false,"node_id":"2205967","writeuptype":"poetry","is_log":false,"parent":{"type":"e2node","node_id":2153021,"title":"I dream of a language whose words, like fists, would fracture jaws"},"notnew":false,"author":{"title":"haqiqat","type":"user","node_id":1931459},"title":"I dream of a language whose words, like fists, would fracture jaws (poetry)"},{"author":{"title":"BookReader","node_id":1681230,"type":"user"},"parent":{"title":"The Blue Dragon","type":"e2node","node_id":758897},"title":"The Blue Dragon (place)","notnew":false,"is_log":false,"is_junk":false,"node_id":"2214092","writeuptype":"place"},{"is_log":false,"is_junk":false,"node_id":"2214087","writeuptype":"idea","notnew":false,"parent":{"title":"Footwear That Fits","node_id":2214088,"type":"e2node"},"title":"Footwear That Fits (idea)","author":{"title":"jessicaj","node_id":1934284,"type":"user"}},{"notnew":false,"is_log":false,"node_id":"2213607","is_junk":false,"writeuptype":"thing","author":{"title":"Dustyblue","type":"user","node_id":2068077},"parent":{"title":"Carl's Doomsday Scenario","node_id":2214084,"type":"e2node"},"title":"Carl's Doomsday Scenario (thing)"}],"display_prefs":{"vit_hidemaintenance":0,"rtn_hidecwu":0,"rtn_hideedc":0,"num_newwus":"10","vit_hidelist":0,"edn_hideutil":0,"vit_hidenodeinfo":0,"vit_hidenodeutil":0,"nw_nojunk":false,"rtn_hidenws":0,"vit_hidemisc":0,"edn_hideedev":0},"architecture":"aarch64","developerNodelet":{},"node":{"can_bookmark":true,"title":"How To Catch a Lion in the Sahara Desert","node_id":"1478480","type":"e2node","createtime":1058820744},"pageheader":{},"use_local_assets":"0","reactPageMode":true,"title":"How To Catch a Lion in the Sahara Desert","chatterbox":{"numborged":1,"borged":0},"nodetype":"e2node","lastCommit":"ff57790348b58c2d84549c750fca2a8354ed26ad","lastnode_id":null,"guest":1,"assets_location":"https://s3-us-west-2.amazonaws.com/deployed.everything2.com/ff57790348b58c2d84549c750fca2a8354ed26ad"}