Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #16626

Re: [Hardest Maths Statement Puzzle] Toughest Math Statement Question

Message-ID <4F29CEF5.1880@mindspring.com> (permalink)
Date 2012-02-01 18:47 -0500
From pete <pfiland@mindspring.com>
Organization PF
Newsgroups comp.lang.c
Subject Re: [Hardest Maths Statement Puzzle] Toughest Math Statement Question
References <d2f643df-1028-4906-808d-faa935f94fa0@f8g2000prm.googlegroups.com> <4F090789.D54@mindspring.com> <kfnaa5a2v1l.fsf@x-alumni2.alumni.caltech.edu> <4F233391.5FC@mindspring.com> <kfnsjivxe2m.fsf@x-alumni2.alumni.caltech.edu>

Show all headers | View raw


Tim Rentsch wrote:
> 
> pete <pfiland@mindspring.com> writes:
> 
> > Tim Rentsch wrote:
> >>
> >> pete <pfiland@mindspring.com> 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

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [Hardest Maths Statement Puzzle] Toughest Math Statement Question pete <pfiland@mindspring.com> - 2012-01-07 22:03 -0500
  Re: [Hardest Maths Statement Puzzle] Toughest Math Statement Question Tim Rentsch <txr@alumni.caltech.edu> - 2012-01-26 10:11 -0800
    Re: [Hardest Maths Statement Puzzle] Toughest Math Statement Question pete <pfiland@mindspring.com> - 2012-01-27 17:06 -0500
    Re: [Hardest Maths Statement Puzzle] Toughest Math Statement Question pete <pfiland@mindspring.com> - 2012-01-27 18:30 -0500
      Re: [Hardest Maths Statement Puzzle] Toughest Math Statement Question 88888 Dihedral <dihedral88888@googlemail.com> - 2012-01-31 06:19 -0800
        Re: [Hardest Maths Statement Puzzle] Toughest Math Statement Question Willem <willem@toad.stack.nl> - 2012-03-08 22:26 +0000
      Re: [Hardest Maths Statement Puzzle] Toughest Math Statement Question Tim Rentsch <txr@alumni.caltech.edu> - 2012-01-31 22:28 -0800
        Re: [Hardest Maths Statement Puzzle] Toughest Math Statement Question pete <pfiland@mindspring.com> - 2012-02-01 18:47 -0500
          Re: [Hardest Maths Statement Puzzle] Toughest Math Statement Question Tim Rentsch <txr@alumni.caltech.edu> - 2012-03-08 12:24 -0800

csiph-web