Given the 95 printable characters in ASCII plus newline, break it apart into two equal, 48 character groups (hereafter called group A and group B). Create a one-to-one mapping of your choice (you have total discretion) between the two groups. In other words, A
might map to a
, and vice versa, but A
might also map to >
and vice versa, if that's what you need for your program.
Once you've broken up ASCII into two groups, write two programs and/or functions, using only the characters in each group, respectively. In other words, write one program / function that only uses the characters in group A, and another program / function that only uses the characters in group B.
These programs must be able to receive one character as input. The program written with the characters in Group A should output / return the same character if the input was a group A character, and the mapped group A character if it received a group B character; the Group A program should always output a group A character. Similarly, the Group B program should output the same character if it's a group B character, and the mapped group B character if the input is a group A character.
That might not be so clear, so here's an example. If you assume that all capital letters are in group A, and all lowercase letters are in group B, and you've chosen that your one-to-one mapping for these letters are from one to the other, then: then here are some sample input/outputs:
Program A:
Input Output
A A
D D
a A
q Q
Program B:
Input Output
A a
D d
a a
q q
Other rules:
- The two programs do not need to be in the same language.
- They don't need to be both programs or both functions; one could be a program, the other a function, that is fine.
- They don't need to work the same way, be of similar length, anything like that; they simply must meet the the other rules above.
- Yes, only one of your programs may use newlines, and only one can use spaces (this could be the same, or a different program).
- You do not need to use all 48 characters in each program.
Standard loopholes are banned, as normal. All programs must be self contained, no files containing the mapping you choose.
Scoring criteria: code-golf. Specifically, the sum of the bytes of the text of the two programs.
Please post your answer like this:
Language - # bytes + Language - # bytes = # bytes
An unambiguous description of your mapping. If it's complicated, use a chart like this:
ABCDEFGHIJKLMNOPQRSTUVWXYZ (etc.) zyxwvutsrpqonmlkjihgfedcba (etc.)
Or, you can just explain it (first 48 maps to last 48 in sequence), followed by your answer as normal.
+
and>
, and the other using-
and<
. Then you have to try to generate the missing operators, such as a,
or.
in the program that cannot use them. \$\endgroup\$