| Bytes | Lang | Time | Link |
|---|---|---|---|
| 026 | Jelly | 250922T200906Z | Jonathan |
| 027 | Pyth | 250925T000130Z | dthusian |
Jelly, 26 bytes
Lœ?“EgÆ/”vð@“N6XU¥⁴"EɠẒḌḂż
A full program that prints the maximal exponent to stdout, i.e. an integer greater than \$1\$ if a perfect power or \$1\$ if not.
Try it online! - way too slow for its own input (which is no longer a requirement).
Or see the test-suite.
The bytecode is:
4C 1E 3F FE 45 67 0D 2F FF 76 18 40 FE 4E 36 58 55 04 84 22 45 9F BD AD BF F9
which, as base 10 is (TIO)
$$122317173525583340303786060012597342485674060763941233767596025$$ $$ = (5 \cdot 19 \cdot 254279 \cdot 457835662419192582175421)^{2}$$
How?
Lœ?“EgÆ/”vð@“... - Main Link: integer, N > 1
“... - length 13 string -> S
ð@ - dyadic chain - f(S, N)...
“EgÆ/” - "EgÆ/"
œ? - permutation of {that} at lexicographic index...
L - ...length of {S}
-> "ÆEg/"
v - evaluate as Jelly code with {N} as the left argument
i.e:
ÆE - prime factor exponents (e.g. 500 = 2*2*5*5*5 -> [2,0,3])
/ - reduce by:
g - greatest common divisor
If the output really needs to be truthy in our language and falsey otherwise, this, at \$28\$ bytes, prints a non-zero number if a perfect power (truthy) or zero if not (falsey):
Lœ?“ÆgCE/”vɓ@“F6Æ_æṃcSḌɠ2ḌƈÑ
The C produces one minus its argument, and the string is now length fourteen.
Pyth, 29 27 bytes (thanks CursorCoercer)
iFhMrPQssm.6"}ÉoÌ ¦¼ø
Hexdump:
00000000: 6946 684d 7250 5173 736d 2e36 227d 1b82 iFhMrPQssm.6"}..
00000010: c96f cc20 a619 8b99 bcf8 10 .o. .......
Outputs a number >1 for true, 1 for false.
Try it online! - The given input is the program value.
Explanation
This answer cheeses the challenge by using the length of an arbitrary string inside a computation. The string's contents can be varied to search for valid program values. I'm guessing the intent was to disallow putting arbitrary characters inside of a comment, but the challenge seems impossible without some cheese.
Start with the following Pyth program: iFhMrPQ8
PQ - Prime factors of the input, e.g. 36 => [2, 2, 3, 3]
r 8 - Run-length encoding, e.g. => [[2, 2], [2, 3]]
hM - Take the first element of each element, e.g. => [2, 2]
iF - Reduce with GCD
Notice that 8 is used as an "opcode" input to the r instruction - passing values other than 8 results in a different operation. This is important for the irreducibility requirement.
Replace 8 with the following snippet:
"xxxxxxxxxxxxxx - 14 arbitrary characters in a string
m.6 - Map each element to 0.6
s - Sum elements
s - Convert to int
This is to satisfy the irreducibility requirement: if any part of the string is removed, the length no longer evaluates to 8. If any part of the length-computing code is removed, it also no longer evaluates to 8. It is unlikely that some subset of this string is valid Pyth code evaluating to 8 (i.e. if the string delimiter " is removed).
Then I just used a script to exhaustively check for perfect square program values. I also checked if I could reduce the size of the string literal (for example, by replacing .5 with .6), but no valid programs were found. .6 (and thus a string literal of length 14) is possible with non-printable characters in the string.
The program value is
43307635010343855810373044925567686241308005777350905277347330064
which is the square of
208104865417279121841411971317508
As a bonus, the program is fast enough for it to evaluate its program value in a reasonable time.