# sporeball numbers

## Brachylog, 26 bytes

```
{ḃ~c₃↺{↔?¬Ė}ʰ↻c}ᶠlᵒlᵍh∋~jz
```

Try it online!

Dreadfully slow for large falsy testcases, but verifies truthy ones surprisingly quickly. My original solution ran into the same false negatives as xash's deleted answer, but fortunately the process of fixing that helped me shave off 2 bytes.

```
{ }ᶠ Find every possible result from:
ḃ take the binary digits of the input,
~c₃ split them into three (possibly empty) partitions,
↺{ }ʰ↻ for the middle partition:
↔ reversed it is
? itself
¬Ė which is not the empty list;
Ė replace it with the empty list.
c and re-concatenate the partitions.
lᵒ Sort the results by length,
lᵍ group them by length,
h and take the first group (that with minimal length).
∋ Some element of that group
~j is something concatenated with itself
z which is not the empty list.
```

Rather than maximize the length of the palindromic substring, it just minimizes the length of everything left, which is an approach I really only came up with because of my initial approach of relying on `≜`

.

## 05AB1E, ~~47~~ ~~45~~ ~~43~~ ~~42~~ ~~40~~ ~~41~~ ~~40~~ 31 bytes

```
b©ŒʒÂQ}é.γg}θε®sõ.;D2ä1ìËsgĀ*}à
```

Try it online!

*-2 thanks to @ovs!*

*-1 thanks to @ovs!*

*-1 (lol) thanks to a bug fix*

*-1 thanks to @ovs (again!)*

*+1 due to challenge clarification :-(*

*but -1 thanks to @Kevin!*

*and another whopping -9 thanks to @Kevin!*

Don't mind me... just posting another overly long answer in 05AB1E that ~~will probably be~~ **was** golfed by anyone experienced with 05AB1E.

The `ÂQ`

trick to see if a string is a palindrome was taken from this 05AB1E tip answer by Kevin.

### Explained (old)

```
bDV.œ˜ʒÂQ} Ð€gàUʒgXQ}εYsõ:Ðg;ôËsgD0ÊsÈ**}à
bDV # Get the binary representation of the input, and assign variable Y to that value while still keeping a copy on the stack
.œ # Push all partitions of that binary representation
˜ # Flatten said list and
ʒ # Select items where:
ÂQ} # They are a palindrome
Ð # and push three copies of it to the stack.
€g # For one of those copies, push the length of each item
àU # Find the maximum length and assign it to variable Y
ʒgXQ} # From the list of palindromic partitions, select the ones which are of the maximum length
ε # And from that list:
Ysõ: # Replace the occurrence of that number in variable Y with nothing THEN
Ð # Triplicate it THEN
g;ô # Split it in half THEN
Ë # See if all elements are equal AND
sgD0ÊsÈ** # Ensure the length of Y with the item removed isn't 0 and isn't odd
}à # Close the map, and take the maximum of the list and implicitly print the result
```

## J, ^{80} ^{78} ^{75} ^{66} ^{61} 57 bytes

```
1 e.#\,@((#<.[-:[:,~,~inv)\.*[:(*i.@#=+./"{i:1:)(-:|.)\)]
```

Try it online!

*-3 bytes thanks to Marshall*

*-9 bytes thanks to xash*

Tougher than I thought it would be.

Finally a respectable size, though still high for J.

## J, alternate approach, 73 bytes

```
1 e.1}.((((<:@[,(-:|.)\#(#<.]-:[:,~,~inv)\.)~{.))^:(0<{.@]*1=#@])^:_#)@#:
```

Try it online!

This one uses do..while `^:(while)^:_`

, starting by searching the longest possible length palindrome, and stopping as soon as it finds any for a certain length, returning the boolean telling you if the complement for that palindrome is a doubled string.