Given an integer
N as input, output the
Nth permutapalindromic number.
A permutapalindromic number is a strictly positive integer such that there is at least one permutation of its digits that results in a palindrome (i.e. a number that is its own reverse).
117 is a permutapalindromic number since its digits can be permuted into
171, which is a palindrome.
We consider that numbers like
10 are not permutapalindromic numbers, even though
01 = 1 is a palindrome. We impose that the palindromic permutation must not have a leading zero (as such,
0 itself is not permutapalindromic).
Numbers that are already palindromes are also permutapalindromic, since permuting nothing is valid.
Inputs and outputs
Nmay be either 0-indexed or 1-indexed. Please indicate which of the two your answer uses.
- The input can be taken through
STDIN, as a function argument, or anything similar in your language of choice. The output can be written to
STDOUT, returned from a function, or anything similar in your language of choice.
- The input and output must be in the decimal base.
The following test cases are 1-indexed. Your program must be able to pass any of the test cases presented here in at most 1 minute.
N Output 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 11 42 181 100 404 128 511 256 994 270 1166
This is code-golf, so the shortest answer in bytes wins.