(49G) OEIS A178225: Test for Binary-Palindromicity
|
02-22-2018, 06:18 PM
Post: #1
|
|||
|
|||
(49G) OEIS A178225: Test for Binary-Palindromicity
For integer decimal input N the programme tests whether N in binary is palindromic.
This is OEIS https://oeis.org/A178225 Size: 95.5 CkSum: # C785h Code: :: |
|||
02-23-2018, 03:02 PM
Post: #2
|
|||
|
|||
RE: (49G) OEIS A178225: Test for Binary-Palindromicity
A neater, faster programme:
Size: 122.5 CkSum: # 1FA9h Code: :: |
|||
02-25-2018, 09:43 AM
Post: #3
|
|||
|
|||
RE: (49G) OEIS A178225: Test for Binary-Palindromicity
Here the definitive version of the programme, a model of elegance, shortest & fastest possible.
I'm sure no one can find an improvement - I'd be amazed if you did! Size: 105. CkSum: # 2C8Eh Code: :: |
|||
02-26-2018, 08:12 AM
Post: #4
|
|||
|
|||
RE: (49G) OEIS A178225: Test for Binary-Palindromicity
Well..
that sounded like a challenge, no? Never could resist. Two things bothered me about your code: First, the sequence Code: BINT2 While #2/ is not the same, in this case it does the job - there's no need to test the middle bit, so to speak. Second thing: the snippet Code: ?SKIP The secondary wastes 5 bytes in my eyes ;-) so I tried to do without one. It turned out not to be so easy to improve upon, though. All I've been able to manage so far is save a single command (2.5 bytes). Well, this is it, 97.5 Bytes, # 945Fh Code: :: Cheers, Werner 41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE |
|||
02-26-2018, 10:27 AM
Post: #5
|
|||
|
|||
RE: (49G) OEIS A178225: Test for Binary-Palindromicity
Very nice, Werner, congrats!
After incorporating your suggestion not to test the middle bit into my version, my programme tested the 691 decimal digits binary palindrome 8999426634711432210874665907816903956988683664722921509315478192749207880463456922990872105835307171055080251964909961257453802179645499054716333672539545544118932968691884084960688692597413433759874480699854844501836094850133947983753204817698281788633116753054503696404359361578125612931539740671066508864784351529154391934339180653852887403515211867169617043784799543175497949666073579771413066215421083208629713930186272527242260162642480210729326691627240372999886606875669375524245678348406217132838891048302886533496403036545542639162038790659197087400238193942009504229380072518565320107237768892369217461716099224829006631795274618330918728005922738663971483339019497645460273904057 in 3.891345 s & your programme took 3.869235 s (average of 20 runs). So your programme is smaller & faster, I shall put it in my library. Thus the crestfallen boaster acknowledges your acumen. |
|||
02-26-2018, 05:56 PM
Post: #6
|
|||
|
|||
RE: (49G) OEIS A178225: Test for Binary-Palindromicity
Shorter:
Size: 92.5 CkSum: # 1249h Code: :: |
|||
02-26-2018, 07:41 PM
(This post was last modified: 02-27-2018 11:31 AM by Gerald H.)
Post: #7
|
|||
|
|||
RE: (49G) OEIS A178225: Test for Binary-Palindromicity
Shorter:
NB PTR 273B6 has been stable at least from version 1.19-6 on. Size: 90. CkSum: # FB5Bd (edited to correct incorrect checksum) Code: :: |
|||
02-27-2018, 09:01 AM
Post: #8
|
|||
|
|||
RE: (49G) OEIS A178225: Test for Binary-Palindromicity
But what does it do, PTR 273B6?
Werner 41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE |
|||
02-27-2018, 10:14 AM
Post: #9
|
|||
|
|||
RE: (49G) OEIS A178225: Test for Binary-Palindromicity
It puts the short form of
ZINT 1 on the stack. |
|||
02-27-2018, 10:57 AM
Post: #10
|
|||
|
|||
RE: (49G) OEIS A178225: Test for Binary-Palindromicity
In that case, add
EQU ZINT_1 $273B6 as first line of your source code, then you can use ZINT_1. A bit clearer than PTR 273B6 ;-) Werner 41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE |
|||
02-27-2018, 11:24 AM
Post: #11
|
|||
|
|||
RE: (49G) OEIS A178225: Test for Binary-Palindromicity
In my own programming environment I use an XTable library where
Z1_ represents the pointer. As not everyone has the same XTable library I avoid using Z1_ publicly, preferring to use the pointer, which should compile OK for everyone. Your suggestion is a good idea, I mean more transparent, but could well confuse those not so experienced in Sys programming. |
|||
02-27-2018, 01:15 PM
Post: #12
|
|||
|
|||
RE: (49G) OEIS A178225: Test for Binary-Palindromicity
"but could well confuse those not so experienced in Sys programming"
? More confused than by PTR 273B6? Werner 41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)