Post Reply 
(49G) Finds Binary Palindrome's Position in OEIS A057148
02-17-2018, 09:10 PM
Post: #1
(49G) Finds Binary Palindrome's Position in OEIS A057148
For binary integer input B the programme returns B's position in the sequence

https://oeis.org/A057148

eg For input

1000101010101010001

the programme returns

1066.

Size: 158.5

CkSum: # EC76h

Code:
::
  CK1&Dispatch
  # FF
  ::
    DUP
    ZINT 2
    Z<
    case
    ::
      ZINT 1
      FPTR2 ^QAdd
    ;
    FPTR2 ^Z>S
    DUPLEN$
    BINT2
    #/
    SWAP
    #0=ITE
    ::
      ONESWAP
      SUB$
      "1"
    ;
    ::
      #1+
      ONESWAP
      SUB$
      CDR$
      "10"
    ;
    SWAP&$
    ZINT 0
    OVERLEN$
    #1+_ONE_DO
    DUP
    FPTR2 ^QAdd
    OVERINDEX@
    SUB$1#
    BINT48
    #=ITE
    ZINT 0
    ZINT 1
    FPTR2 ^QAdd
    LOOP
    SWAPDROP
  ;
;
Find all posts by this user
Quote this message in a reply
Post Reply 




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