Re: The "Strand" puzzle --- ( Continued Fractions using Lisp orPython? )

Liste des GroupesRevenir à s lang 
Sujet : Re: The "Strand" puzzle --- ( Continued Fractions using Lisp orPython? )
De : HenHanna (at) *nospam* devnull.tb (HenHanna)
Groupes : rec.puzzles comp.lang.lisp sci.lang sci.math
Date : 01. Aug 2024, 21:47:30
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v8gook$2bqob$1@dont-email.me>
References : 1 2 3 4
User-Agent : Mozilla Thunderbird
On 8/1/2024 2:33 AM, B. Pym wrote:
HenHanna wrote:
 
e.g. -------- For the (street)  Numbers (1,2,3,4,5,6,7,8)
>
        (1,2,3,4,5)  and  (7,8)  both add up to 15.
>
>
>
"In a given street of houses with consecutive numbers between
50 and 500, find the house number, for which, the sum of
numbers on the left is equal to the sum of numbers on the
right"

 Gauche Scheme
 (define (strand lst)
   (let go ((left-sum 0) (tail lst))
     (if (null? tail)
       #f
       (let ((right-sum (fold + 0 (cdr tail))))
         (cond ((< left-sum right-sum)
                (go (+ left-sum (car tail)) (cdr tail)))
               ((= left-sum right-sum) (car tail))
               (#t #f))))))
 (strand '(1 2 3 4 5 6 7 8))
   ===>
6
 (lrange 2 5)
   ===>
(2 3 4)
 (any
   (lambda (n)
     (if (strand (lrange 50 n))
       n
       #f))
   (lrange 500 50 -1))
   ===>
352
 (strand (lrange 50 352))
   ===>
251
               does your Newsreader  set  Followup-to   automatically?
                        pls  disable it.
i still don't see how the prob is related to the Continued  Fraction.
if this Continued  Fraction  is written as  [2,1]  with a bar over 1 (?)
                                 What does   [3,1]  correspond to?

Date Sujet#  Auteur
25 Jul 24 * The "Strand" puzzle7HenHanna
26 Jul 24 `* Re: The "Strand" puzzle6IlanMayer
29 Jul 24  `* Re: The "Strand" puzzle --- ( Continued Fractions using Lisp or Python? )5HenHanna
31 Jul 24   +- Re: The "Strand" puzzle --- ( Continued Fractions using Lisp or Python? )1HenHanna
1 Aug 24   `* Re: The "Strand" puzzle --- ( Continued Fractions using Lisp orPython? )3B. Pym
1 Aug 24    `* Re: The "Strand" puzzle --- ( Continued Fractions using Lisp orPython? )2HenHanna
1 Aug 24     `- Re: The "Strand" puzzle --- ( Continued Fractions using Lisp orPython? )1Moebius

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal