Post Reply 
(49G) OEIS A178225: Test for Binary-Palindromicity
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
     ::
       ROTDROP
       %0
       3UNROLL
       ExitAtLOOP
     ;

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:
::
   CK1&Dispatch
   # FF
   ::
     DUP
     ZINT 2
     Z<
     casedrop
     %1
     FPTR2 ^Z>ZH
     FPTR2 ^ZBits
     DUPUNROT
     #2/
     DUP
     ZERO_DO
       DROP
       SWAP#1-SWAP
       OVER
       FPTR2 ^ZBit?
       SWAPINDEX@
       FPTR2 ^ZBit?
       ROT
       EQUAL
       DUP
       ?SKIP
       ExitAtLOOP
     LOOP
     UNROT2DROP
     COERCEFLAG
   ;
 ;

Cheers, Werner

41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: (49G) OEIS A178225: Test for Binary-Palindromicity - Werner - 02-26-2018 08:12 AM



User(s) browsing this thread: 1 Guest(s)