🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: a.bsu.programming
Article #86798

Re: Simple Programming CHALLENGE!

#86798
From: Justin Heyes-Jones
Date: Fri, 02 Oct 1998 00:00
77 lines
3738 bytes
On Thu, 1 Oct 1998 21:46:38 +0100 , Thierry Coutelier
<netscan@prophecy.lu> wrote:

I suspect you just did someones homework. But dosn't this solution
break two rules? It dosn't do 3 or less weighings, and it dosn't
output whether the bad coin is heavier or lighter.

>Lets say your coins are C[1] to C[12]  And only 1 is a bad coin.
>
>You have a Balance.equal( ) which returns  true or false depending if the left
>   side is equal or not equal to the right side.
>Lets say we use  Balance.addLeft( Coin ) and the same for right and with remove.
>
>for( i = 1; i < 12/2; i++) {
>  Balance.addLeft( C[i]  );
>  Balance.addRight( C[12-i]  );
>  if( Balance.equal( ) ) {
>    Balance.removeRight( C[12-i] );
>    Balance.removeLeft( C[i] );
>    }
>  else {
>     Balance.removeLeft( C[i] );
>     Balance.addLeft( C[i+1] );
>     if( Balance.equal( ) ) {
>        output.write( i + " is the bad coin" );
>        i = 12;
>       }
>     else {
>        output.write( 12-i + "is the bad coin" );
>        i = 12;
>     }
>}
>
>if( i < 12 ) {
>  output.write( "No bad coin" );
>}
>
>
>JaSpIoN wrote:
>
>> Hello!
>>
>> I just got this simple programming challenge last night and couldn't sleep,
>> trying to solve it. I know there IS an answer and that it involves a
>> not-so-obvious insight. Anyone up for a challenge?  Here it is:
>>
>> we have 12 coins that look identical. However, one of them is counterfeit
>> and weight either more or less than all the others, but you do not know if
>> it's heavier or lighter. You have a beam balance which allows you to tell
>> whether things have equal or unequal weight but it does not allow
>> quantitative measurements of the weights since you have no standard weights.
>> Describe how you would determine which coin is fake and whether it's heavier
>> or lighter. The answer should be presenter as an algorithm. NOTE: The fake
>> coin's weight is either slightly heavier or slightly lighter, but no so much
>> that it would be the weight of half or twice a real coin. Also, you are only
>> allowed 3 weighings.
>>
>> Let's see if you can help me solve this!
>>
>> Thanks,
>>
>> ...LEo
>
>
>
>--
>---
>Thierry.Coutelier@remove-to-mail.prophecy.lu
>http://www.prophecy.lu
>
>Visit Prophecy the David Eddings MUD
>telnet://mud.prophecy.lu:4000
>---
>


Justin Heyes-Jones, justinhj@hotmail.com.
Technical Details
Message-ID: <361491a6.1643230@ProbeNews>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <3613ccd7.0@news.total.net> <3613EA2E.F6450F1A@prophecy.lu>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 105c7d,f4b447bdc7985244,start
X-Google-Attributes: gid105c7d,public
X-Google-Thread: 10804c,f4b447bdc7985244,start
X-Google-Attributes: gid10804c,public
X-Google-Thread: 10e889,f4b447bdc7985244,start
X-Google-Attributes: gid10e889,public
X-Google-Thread: faaa2,f4b447bdc7985244,start
X-Google-Attributes: gidfaaa2,public
X-Google-Thread: f5380,f4b447bdc7985244,start
X-Google-Attributes: gidf5380,public
X-Google-Thread: fc8d0,f4b447bdc7985244,start
X-Google-Attributes: gidfc8d0,public
X-Google-Thread: 10226d,f4b447bdc7985244,start
X-Google-Attributes: gid10226d,public
X-Google-Thread: 107d8b,f4b447bdc7985244,start
X-Google-Attributes: gid107d8b,public
From: justinhj@hotmail.com (Justin Heyes-Jones)
Subject: Re: Simple Programming CHALLENGE!
Date: 1998/10/02
Message-ID: <361491a6.1643230@ProbeNews>
X-Deja-AN: 396983807
References: <3613ccd7.0@news.total.net> <3613EA2E.F6450F1A@prophecy.lu>
Organization: UUNET WorldCom server (post doesn't reflect views of UUNET WorldCom)
Newsgroups: a.bsu.programming,adass.iraf.programming,alt.mud.programming,alt.talkers.programming,alt.winsock.programming,borland.public.vdbase.programming,comp.cad.autocad,comp.games.development.programming.algorithms,comp.games.development.programming.misc