Background
We've studied at least five different types of numbers based on the IDs of different users on this site. Why not study another?
My user ID is \$91030_{10}\$. Its binary representation is \$10110001110010110_2\$, a representation which has an interesting property of its own:
- One option for the longest palindromic run of binary digits is \$0011100\$.
- If you remove this run of digits, the remaining list of digits (\$1011010110\$) can be split into two identical halves.
I define a sporeball number as any positive integer where at least one of the options for the longest palindromic run of digits in its binary representation can be removed such that the remaining list of digits can be split into two identical halves.
Task
Write a program or function which takes a positive integer as input and determines whether or not it is a sporeball number.
Some clarifications to keep in mind:
- Leading zeroes should be ignored.
- Exactly one palindromic run of digits should be removed before checking if the remaining digits can be split into identical halves.
- If one of the options for the longest palindromic run occurs multiple times, remove only one occurrence, rather than all of them, before checking if the remaining digits can be split into identical halves.
- Single digits are palindromic.
- The empty string
""
is not palindromic, and cannot be split into two identical halves.
Remember that there may be more than one longest palindromic run of digits:
- The binary digits of \$12_{10}\$ (\$1100\$) contain two options for the longest palindromic run (\$11\$ and \$00\$). No matter which one is removed, the remaining digits will be able to be split into identical halves. Thus, \$12_{10}\$ is a sporeball number.
- The binary digits of \$20_{10}\$ (\$10100\$) contain two options for the longest palindromic run (\$010\$ and \$101\$). Removing \$010\$ leaves the digits \$10\$, which cannot be split into identical halves; however, removing \$101\$ leaves the digits \$00\$, which can be. Thus, \$20_{10}\$ is a sporeball number.
There are 153 sporeball numbers under 1,000:
12 20 23 24 26 28 29 39 48 57 60 68 71 84 87 96 100 106 108 110 111 113 117 123 124 132
135 154 166 178 180 183 192 204 207 210 222 225 237 240 243 252 260 263 277 282 287 295
314 326 334 336 337 340 343 348 351 354 370 372 375 384 392 394 396 399 404 412 418 426
428 431 432 446 449 457 469 476 477 479 480 483 484 490 491 496 497 501 503 508 516 519
533 538 543 562 600 610 612 615 634 646 652 660 663 664 670 673 676 691 700 703 706 718
720 735 742 754 756 759 768 778 780 783 792 804 816 821 826 828 831 834 858 870 874 876
879 894 897 918 921 922 924 927 933 957 960 963 972 978 987 993 999
Rules
- This is code-golf, so shortest answer in bytes wins.
- Standard I/O rules apply.
2405
. \$\endgroup\$