A permutation of a set \$S = \{s_1, s_2, \dotsc, s_n\}\$ is a bijective function \$\pi: S \to S\$. For example, if \$S = \{1,2,3,4\}\$ then the function \$\pi: x \mapsto 1 + (x + 1 \mod 4)\$ is a permutation:
$$ \pi(1) = 3,\quad \pi(2) = 4,\quad \pi(3) = 1,\quad \pi(4) = 2 $$
We can also have permutations on infinite sets, let's take \$\mathbb{N}\$ as an example: The function \$\pi: x \mapsto x-1 + 2\cdot(x \mod 2)\$ is a permutation, swapping the odd and even integers in blocks of two. The first elements are as follows:
$$ 2,1,4,3,6,5,8,7,10,9,12,11,14,13,16,15,\dotsc $$
Challenge
Your task for this challenge is to write a function/program implementing any1 permutation on the positive natural numbers. The score of your solution is the sum of codepoints after mapping them with the implemented permutation.
Example
Suppose we take the above permutation implemented with Python:
def pi(x):
return x - 1 + 2*(x % 2)
The character d
has codepoint \$100\$, \$\texttt{pi}(100) = 99\$. If we do this for every character, we get:
$$ 99,102,101,31,111,106,39,119,42,57,9,31,31,31,31,113,102,115,118,113,109,31,119,31,46,31,50,31,44,31,49,41,39,119,31,38,31,49,42 $$
The sum of all these mapped characters is \$2463\$, this would be the score for that function.
Rules
You will implement a permutation \$\pi\$ either as a function or program
- given an natural number \$x\$, return/output \$\pi(x)\$
- for the purpose of this challenge \$\mathbb{N}\$ does not contain \$0\$
- the permutation must non-trivially permute an infinite subset of \$\mathbb{N}\$
- your function/program is not allowed to read its own source
Scoring
The score is given by the sum of all codepoints (zero bytes may not be part of the source code) under that permutation (the codepoints depend on your language2, you're free to use SBCS, UTF-8 etc. as long as your language supports it).
The submission with the lowest score wins, ties are broken by earliest submission.
Except for permutations which only permute a finite subset of \$\mathbb{N}\$, meaning that the set \$\{ x | \pi(x) \neq x \}\$ must be infinite.
If it improves your score, you can for example use a UTF-8 encoded Jelly submission instead of the usual SBCS.