Palindromic prime problems are pretty common, but that's not what this question is about. In this challenge, the number doesn't have to be a palindrome, its prime factors do.
Task
Your code has to take a single positive integer as input. Then check if any of the permutations of the prime factors of that integer are palindromic when concatenated. If so, output one of them (the list of factors, not the concatenated string). Else, you have to output -1
.
This is code-golf, so shortest code in bytes wins!
Test Cases
11 -> [11]
4 -> [2, 2]
39 -> [3, 13]
6 -> -1
1207 -> [17, 71]
393 -> -1
2352 -> [2, 2, 7, 3, 7, 2, 2]
-1
be returned? In Perl 6 I'm thinking aboutNil
,Fail
or other undefined values. Also can the output be any Positional value? \$\endgroup\$1
, or-1
? \$\endgroup\$