Path: ...!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: vallor Newsgroups: comp.os.linux.advocacy Subject: Re: Simple math/programming challenge for the "REAL programmer" Feeb Date: Sun, 10 Mar 2024 19:56:45 -0000 (UTC) Organization: A noiseless patient Spider Lines: 56 Message-ID: References: <87h6heilev.fsf@yaxley.in> <09acnYe4UemsSnD4nZ2dnZfqnPidnZ2d@supernews.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Sun, 10 Mar 2024 19:56:45 -0000 (UTC) Injection-Info: dont-email.me; posting-host="81ad7be002f583b290569ed3788100ad"; logging-data="3284798"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19RcoaAX9jgzucNO4OppDID" User-Agent: Pan/0.155 (Kherson; c0bf34e gitlab.gnome.org/GNOME/pan.git; x86_64-pc-linux-gnu) Cancel-Lock: sha1:Nri7HBVnSs0YGpz/baTxb0fDAro= X-Face: \}2`P"_@pS86<'EM:'b.Ml}8IuMK"pV"?FReF$'c.S%u9 wrote in : > On 3/10/2024 11:52 AM, Tyrone wrote: >> On Mar 10, 2024 at 10:46:27 AM EDT, "DFS" wrote: > > >> Other than 1, your list above is missing at least 4 numbers: 4879, 5292, 38962 >> and 627615. The reason is you are not handling zeros correctly. > > Depends on who you ask. > > https://oeis.org/A053816 > https://oeis.org/A006886 > > >> But seriously, these numbers are constants. There is no need to waste my time >> and computer time calculating them. > > You just wasted your time and computer time responding to this post. > > > >> Put them in an array and do a search for >> whatever number you want to check. "Is 123456 a Kaprekar number?" Not in the >> array, so no it is not. >> >> Done. > > There are infinite K numbers. > > Better to use a few lines of code to calculate/check them on demand. And > then you can generalize the K code for powers > 2 (not shown here, but > easy to do). > > def isKaprekar(val,exp): > s,n = str(val**exp), len(str(val)) > if len(s) % exp != 0: n-=1 > p1,p2 = int(s[0:n]), int(s[n:]) > if p1 + p2 == val: > return True > else: > return False > > > > > Why waste time re-inventing the wheel? > > What if I want to call out that talentless "REAL programmer / > mathematician / extraordinaire" hack Feeb Russell, so I can watch him > squirm and flub a tiny math program? That would be an off-charter post, like this one. -- -v