Deutsch   English   Français   Italiano  
<uskvmv$341fu$8@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: DFS <nospam@dfs.com>
Newsgroups: comp.os.linux.advocacy
Subject: Re: Simple math/programming challenge for the "REAL programmer" Feeb
Date: Sun, 10 Mar 2024 14:55:28 -0400
Organization: A noiseless patient Spider
Lines: 30
Message-ID: <uskvmv$341fu$8@dont-email.me>
References: <usj06r$2jn18$3@dont-email.me> <87h6heilev.fsf@yaxley.in>
 <uskh40$30qhq$2@dont-email.me> <87y1aqaxij.fsf@yaxley.in>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 10 Mar 2024 18:55:27 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="ec05b6bf3a15acd02cf034c1d7a8084f";
	logging-data="3278334"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18T2U8Xestn00aAhgo2TWtG"
User-Agent: Betterbird (Windows)
Cancel-Lock: sha1:xW3y89o+5AjhVSmCIlAKq2Yl1lI=
Content-Language: en-US
In-Reply-To: <87y1aqaxij.fsf@yaxley.in>
Bytes: 2244

On 3/10/2024 11:59 AM, Yaxley Peaks wrote:
>> And got:
>> Error(s), warning(s):
>> *** - EVAL: undefined function SEQ-KEEP
> 
> SEQ-KEEP was added in emacs 29, what version are you using?
> https://www.gnu.org/software/emacs/manual/html_node/elisp/Sequence-Functions.html#index-seq_002dkeep

As I said, I submitted it here:
https://rextester.com/l/common_lisp_online_compiler


Just post the output of your lisp code.

(defun kaprekarp (n)
   (let* ((num (* n n))
          (snum (number-to-string num))
          (num-digits (length (number-to-string n)))
          (num-list (string-split snum "" t))
          (right-side (reverse (take num-digits (reverse num-list))))
          (left-side (reverse (nthcdr num-digits (reverse num-list))))
          (left-side-num (string-to-number (mapconcat 'identity left-side)))
          (right-side-num (string-to-number (mapconcat 'identity 
right-side))))
     (= n (+ right-side-num left-side-num))))
(defun solve-problem (low high)
   (seq-keep (lambda (x)
               (and (kaprekarp x) x))
             (number-sequence low high)))
(solve-problem 1 100000000)