From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,af4868d4b196fa50 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit X-Received: by 10.180.85.134 with SMTP id h6mr2925365wiz.1.1367665945345; Sat, 04 May 2013 04:12:25 -0700 (PDT) Path: p18ni66820wiv.0!nntp.google.com!feeder1.cambriumusenet.nl!82.197.223.108.MISMATCH!feeder2.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.86.MISMATCH!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!border4.nntp.ams.giganews.com!border2.nntp.ams.giganews.com!border3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!backlog1.nntp.dca.giganews.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newsfeed.news.ucla.edu!nrc-news.nrc.ca!News.Dal.Ca!news.litech.org!news.etla.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!eternal-september.org!feeder.eternal-september.org!mx05.eternal-september.org!.POSTED!not-for-mail From: "Will Koch" Newsgroups: comp.lang.ada Subject: Re: Breadth First Search Missionaries and Cannibals Date: Tue, 30 Apr 2013 13:37:18 +0000 (UTC) Organization: A noiseless patient Spider Message-ID: References: <6c3bb45c-6cb1-4609-9c3f-c3f01c545eac@googlegroups.com> <517f7917$0$9507$9b4e6d93@newsspool1.arcor-online.net> Mime-Version: 1.0 Injection-Date: Tue, 30 Apr 2013 13:37:18 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="72dc6a9c0740cf94e68329f099dbd9be"; logging-data="30689"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/+rCgv4dDEx1RnymScqUIfKjoe3MbI7n0=" User-Agent: XanaNews/1.19.1.320 Cancel-Lock: sha1:empiAqtuaa9mHufS610AeibhY+U= X-Original-Bytes: 3530 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 7bit Date: 2013-04-30T13:37:18+00:00 List-Id: willmann817@gmail.com wrote: > On Tuesday, April 30, 2013 3:56:17 AM UTC-4, Georg Bauhaus wrote: > > On 30.04.13 04:48, willmann817@gmail.com wrote: > > > > > Given the following Function signature how would I go about using > > > breadth first search to find out the minimum number of trips it > > > would take to get all the missionaries and cannibals across the > > > river. *MUST USE BREADTH FIRST SEARCH* If you are not familiar > > > with the problem see the wiki page here : > > > > > > > > > > http://en.wikipedia.org/wiki/Missionaries_and_cannibals_problem > > > > > > > > > > The only difference between the problem in the wiki article is in > > > this one the number of missionaries and cannibals and the number > > > of people the boat can hold can change. > > > > > > > > > > M is missionaries, C is cannibals and R is the number of people > > > you can fit in the boat. > > > > > > > > > > function Min_Crossings(M, C, R : Integer) return Integer is > > > > > -- you can assume M, C, and R are all >= 2 and C <= M > > > > > > > > While this does not address the combinatorial part, if modern IT > > > > is permitted to be built atop vague, implementation defined > > > > types stuck in the 1970s (Integer), why not boldly move on to the > > > > 1980s and turn the assumption "all are >= 2" into a rock solid type? > > > > > > > > type Entity_Count is range 2 .. Max_Possible_Number; > > > > > > > > function Min_Crossings(M, C, R : Entity_Count) return ... > > > > > > > > If the suffix of Entitiy_Count hides too much information ("Is this > > an int, > > > > actually?") in the context of an algorithmic exercise, you could > > call it > > > > Entity_int. > > I do not know the answer to your question. He is objecting to the use of Integer type in the function signature [which, for a 32-bit integer, has a range of -2^31 to (2^31) - 1] rather than modeling your problem more precisely by using Ada's ability to specify a new type (or subtype) that only allows values greater than or equal to 2. If M, C, and R should never be less than 2, then maybe the code shouldn't allow values less than 2 to be passed to it without throwing an exception.