Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail NNTP-Posting-Date: Wed, 01 Feb 2012 17:46:57 -0600 Message-ID: <4F29CEF5.1880@mindspring.com> Date: Wed, 01 Feb 2012 18:47:01 -0500 From: pete Reply-To: pfiland@mindspring.com Organization: PF X-Mailer: Mozilla 3.04Gold (WinNT; I) MIME-Version: 1.0 Newsgroups: comp.lang.c Subject: Re: [Hardest Maths Statement Puzzle] Toughest Math Statement Question References: <4F090789.D54@mindspring.com> <4F233391.5FC@mindspring.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 42 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 4.154.219.82 X-Trace: sv3-iB0SAh2GU5wopmXVl7d4h/TnFSQ2WXV5X6XbRze6vt0yRU2L6zUsiMxQaVhHTGNM8ppX4zrw+tKmXzZ!w2bmLnCA/j0DXovBGeA/yk7R94s24eh5rVLo9xwtnziZC7P349+J3bt61twIfHCL4asQ+LlaQ3e0!47/owEfvhA== X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 2515 Xref: x330-a1.tempe.blueboxinc.net comp.lang.c:16626 Tim Rentsch wrote: > > pete writes: > > > Tim Rentsch wrote: > >> > >> pete writes: > >> > >> > divya bisht wrote: > >> >> > >> >> Toughest Math Statement Question > >> >> (Source : http://hardest-puzzle.blogspot.com/2011/12/toughest-math-statement-question.html > >> >> ) > >> >> > >> >> I am thinking of a 6-digit number. The sum of the digits is 43. > >> >> > >> >> And only two of the following three statements > >> >> about the number are true: > >> >> > >> >> (1) it's a square number, > >> >> (2) it's a cube number, and > >> >> (3) the number is under 500000. > >> > > > The algorithm seems to be a little more clever. > > I'll have to study it a bit. > > It follows pretty directly from the problem statement that > a solution must be either a square or a cube (or both). > > Knowing that, we simply go through the squares and cubes > in order, checking each case appropriately. The only > complication is making sure each case is checked once > and once only, which is done by the s/c comparisons in > checking for solutions and in the logic that chooses > which of s and/or c to change for the next loop iteration. I got it now. That was well done. -- pete