Sujet : Re: The "Strand" puzzle --- ( Continued Fractions using Lisp orPython? )
De : droleary (at) *nospam* 2017usenet1.subsume.com (Doc O'Leary ,)
Groupes : rec.puzzlesDate : 02. Aug 2024, 16:54:42
Autres entêtes
Organisation : Subsume Technologies, Inc.
Message-ID : <v8ivg2$2sgfk$1@dont-email.me>
References : 1 2 3 4 5
User-Agent : com.subsume.NNTP/1.0.0
For your reference, records indicate that
"B. Pym" <
Nobody447095@here-nor-there.org> wrote:
===>
352
Faster:
But is it correct? Because surrounding 352 I get (with Ruby):
irb(main):001:0> (50..351).sum
=> 60551
irb(main):002:0> (353..500).sum
=> 63122
This solution for the example:
irb> x = 1
=> 1
irb> y = 8
=> 8
irb> (x..y).select {|n| (x..(n-1)).sum == ((n+1)..y).sum}
=> [6]
For the puzzle yields:
irb> x = 50
=> 50
irb> y = 500
=> 500
irb> (x..y).select {|n| (x..n-1).sum == (n+1..y).sum}
=> []
So no house. I’ll skip the full output, but for the tipping point I see:
irb> (x..y).select {|n| puts "#{n} #{(x..(n-1)).sum} #{((n+1)..y).sum}"}
355 61610 62060
356 61965 61704
-- "Also . . . I can kill you with my brain."River Tam, Trash, Firefly