Deutsch English Français Italiano |
<v8gour$2b98k$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!2.eu.feeder.erje.net!feeder.erje.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Moebius <invalid@example.invalid> Newsgroups: rec.puzzles,comp.lang.lisp,sci.lang,sci.math Subject: Re: The "Strand" puzzle --- ( Continued Fractions using Lisp orPython? ) Date: Thu, 1 Aug 2024 21:50:51 +0200 Organization: A noiseless patient Spider Lines: 55 Message-ID: <v8gour$2b98k$1@dont-email.me> References: <v7u7qd$2dgbs$1@dont-email.me> <6f90c2b4abed28c153dea46de3af408d@www.novabbs.com> <v88ood$jnp6$1@dont-email.me> <v8fkps$23nr5$1@dont-email.me> <v8gook$2bqob$1@dont-email.me> Reply-To: invalid@example.invalid MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Thu, 01 Aug 2024 21:50:51 +0200 (CEST) Injection-Info: dont-email.me; posting-host="d1357b6aef03946392c01cfb304e64ea"; logging-data="2467092"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/S9ucr71pxC6LH5lM/O2AM" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:qoQbrKo+IMQOEUZZUujqNn/Haog= In-Reply-To: <v8gook$2bqob$1@dont-email.me> Content-Language: de-DE Bytes: 2828 Am 01.08.2024 um 21:47 schrieb HenHanna: > 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. https://vasya10.wordpress.com/2012/01/11/groovy-olc-2-strand-puzzle-1914/ > i still don't see how the prob is related to the Continued Fraction.