Re: The "Strand" puzzle --- ( Posting On Python-List Prohibited)

Liste des GroupesRevenir à cl python 
Sujet : Re: The "Strand" puzzle --- ( Posting On Python-List Prohibited)
De : ldo (at) *nospam* nz.invalid (Lawrence D'Oliveiro)
Groupes : comp.lang.python
Date : 29. Jul 2024, 23:58:02
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v89399$ld7e$6@dont-email.me>
References : 1 2 3
User-Agent : Pan/0.159 (Vovchansk; )
On Mon, 29 Jul 2024 11:58:21 -0700, HenHanna wrote:

---------- is this (also) easy to do using Lisp or Python???

I threw this code together in about two minutes:

    lo = 50
    hi = 500
    i = (lo + hi) // 2
    while True :
        losum = sum(range(lo, i))
        hisum = sum(range(i + 1, hi + 1))
        print(i, losum, hisum)
        if losum == hisum :
            break
        if losum > hisum :
            i = i - 1
        else :
            i = i + 1
        #end if
    #end while

and it seems there is no actual solution: it keeps oscillating between 355
and 356.

Date Sujet#  Auteur
29 Jul 24 * Re: The "Strand" puzzle --- ( Continued Fractions using Lisp or Python? )3HenHanna
29 Jul 24 +- Re: The "Strand" puzzle --- ( Posting On Python-List Prohibited)1Lawrence D'Oliveiro
1 Aug 24 `- Re: The "Strand" puzzle --- ( Continued Fractions using Lisp orPython? )1B. Pym

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal