# A rainbow of identity functions

Closely related: How high can you count?

## Challenge

In your programming language of choice, write as many different identity programs/functions as possible, under the following constraints:

• Each program should be a function or full program that is one of the following:
• A function that takes a single positive integer and returns it unchanged
• A function that takes a single string of printable ASCII (codepoints 32 to 126 inclusive) and returns it unchanged
• A full program that takes a single positive integer from stdin and prints to stdout unchanged, with an optional trailing newline (and possibly other outputs that cannot be suppressed in your language)
• A full program that takes a single line of printable ASCII from stdin and prints to stdout unchanged, with an optional trailing newline (and possibly other outputs that cannot be suppressed in your language)
• Different programs using different I/O methods is acceptable.
• Any single byte cannot appear in two or more programs, though it may appear more than once in a single program. You may freely use multi-byte characters, as long as every byte value consisting of each multi-byte character follows this exact rule.
• The programs must be independent of each other.
• If an empty program satisfies the condition above, you can include it only once in your answer.
• Symbol independent languages such as Lenguage (including partially independent ones such as Headsecks) are disallowed.
• If your language accepts flags, all programs in an answer must use a single combination of flags (e.g. one answer for "Keg" programs without flags, a separate answer for "Keg -hr" programs). According to this meta, a language with different flag combination is a different language.

## Examples

In Python 3, all of lambda a:a, print(input()), int, and str are valid identity programs independently, but only two of them can be used in an answer since the last three programs share the character t.

## Scoring

The submission with the largest number of programs wins.

• Is a Python function like float valid, which casts the integer to a float? – dingledooper Jun 9 '20 at 23:37
• How about a full program that takes a single positive integer from stdin and writes it to stdout (with an optional newline)? I'm not sure why that would be allowed for functions but not for full programs, but that appears to be the way the challenge is written right now. – Mitchell Spector Jun 9 '20 at 23:42
• What about a full program that takes all of STDIN and prints to STDOUT? – Value Ink Jun 9 '20 at 23:49
• @dingledooper Yes. For languages with multiple number types, input and output types may differ as long as both can express positive integers and the value is unchanged. – Bubbler Jun 9 '20 at 23:49
• @ValueInk It is acceptable as a full program taking single line; the program may do whatever you want for inputs different from the description (e.g. multiline inputs). – Bubbler Jun 10 '20 at 0:05

# 05AB1E, 130133144148150151155156157 159 programs

Uses the custom 05AB1E encoding for all programs.
All programs are a TIO-link to verify them.

Either type of input is fine:

1) (empty program): Implicit input is output implicitly
2,3)   (a space), \n (a newline): The whitespaces are ignored; implicit input is output implicitly (with trailing newline)
4) w: Unbound no-op; implicit input is output implicitly (with trailing newline)
5) I: Explicit input is output implicitly (with trailing newline)
6) ¹: Explicit first input is output implicitly (with trailing newline)
7) $: Push 1 and the input, after which the top input is output implicitly (with trailing newline) 8) Î: Push 0 and the input, after which the top input is output implicitly (with trailing newline) 9) ,: Implicit input is output explicitly with trailing newline 10) =: Implicit input is output explicitly with trailing newline (without popping) 11) ?: Implicit input is output explicitly without trailing newline 12) q: Exit program; implicit input is output implicitly (with trailing newline) 13,14) D, Ð: Duplicate / triplicate the implicit input and output the top implicitly (with trailing newline) 15) r: Reverse the values on the stack (which is empty); implicit input is output implicitly (with trailing newline) 16,17) s, Š: Swap / triple swap two / three implicit inputs; the top is output implicitly (with trailing newline) 18) Δ: Loop until the result no longer changes; the implicit input is used, it loops twice, and the unmodified input is output implicitly (with trailing newline) 19) :: Replace the implicit input-string with the implicit input-string, after which the unmodified input is output implicitly (with trailing newline) 20,21,22,23) J, », O, P: Join the empty stack without delimiter / join the empty stack with newline delimiter / sum the empty stack / take the product of the empty stack, after which the implicit input is output implicitly (with trailing newline) 24,25) U, V: Pop the implicit input, and store it in variable X or Y respectively, after which the implicit input is output implicitly (with trailing newline) 26) ©: Store the implicit input in variable ® (without popping), after which it is output implicitly (with trailing newline) 27) ˆ: Pop the implicit input, and add it to the global array, after which the implicit input is output implicitly (with trailing newline) 28) i: If-statement, if the (implicit) input is 1 it enters it. But whether the input is 1 and it enters the if-statement or not, the implicit input is output implicitly (with trailing newline) either way 29) v: For-each over each character/digit of the implicit input (but don't push any, since we don't use y). After the loop, the implicit input is output implicitly (with trailing newline) 30,31) }, ]: Close the inner-most or all if-statement(s)/loop(s), for which there are none right now. The implicit input is output implicitly (with trailing newline) 32) †: Filter the implicit input to the front of the implicit input; it will remain unmodified and is output implicitly (with trailing newline) 33) ‡: Transliterate the characters of the implicit input to the characters of the implicit input; it will remain unmodified and is output implicitly (with trailing newline) 34) ´: Clear the global array (which is already empty). After which the implicit input is output implicitly (with trailing newline) 35) §: Cast the implicit input to a string, after which it is output implicitly (with trailing newline) 36) Ã: Keep all values of the implicit input in the implicit input, after which the unmodified result is output implicitly (with trailing newline) 37) é: Sort the implicit input by length. Since it's a single string/integer, the characters/digits will remain at the same position, after which the unmodified input is output implicitly (with trailing newline) 38,39) ., Å, ž: All three are used to open up more 2-byte operations, but on their own they're unbound no-ops. So the implicit input is output implicitly (with trailing newline). 40) \: Discard the top item on the stack (which is already empty), after which the implicit input is output implicitly (with trailing newline) 41) ¼: Increase the counter_variable by 1. After which the implicit input is output implicitly (with trailing newline) 42) ½: If the implicit input is 1, increase the counter_variable by 1. After which the implicit input is output implicitly (with trailing newline) 43) ë: Else-statement, which is a no-op without if-statement. So the implicit input is output implicitly (with trailing newline) 44) ÿ: Used for string interpolation; outside of a string it's a no-op. So the implicit input is output implicitly (with trailing newline) 45) šн: Convert the implicit input implicitly to a character-list, and prepend the implicit input at the front. Then pop and push the first item of this list, which is output implicitly (with trailing newline). 46) ªθ: Convert the implicit input implicitly to a character-list, and append the implicit input at the end. Then pop and push the last item of this list, which is output implicitly (with trailing newline). 47) η¤: Get all prefixed of the implicit input. Push its last item (without popping), after which the top of the stack is output implicitly (with trailing newline). 48) ðý: Join the empty stack with space delimiter, after which the implicit input is output implicitly (with trailing newline). 49) õK: Remove all empty strings from the implicit input, after which the unmodified result is output implicitly (with trailing newline). 50) ¸ : Wrap the implicit input into a list, and then pop and dump the contents of that list to the stack, after which it is output implicitly (with trailing newline) 51) ʒX: Start a filter, and push variable X, which is 1 (truthy) by default. So all characters/digits in the implicit input will remain, and the unmodified input is output implicitly (with trailing newline) 52) RR: Reverse the implicit input, and reverse it back. After which the unmodified input is output implicitly (with trailing newline). 53) ÂÂ: Bifurcate (short for Duplicate & Reverse copy) twice, after which the unmodified input at the top of the stack is output implicitly (with trailing newline) 54) ÁÀ: Rotate the implicit input once towards the right, and then back towards the left. After which the unmodified input is output implicitly (with trailing newline). 55) Ć¨: Enclose the implicit input, appending its own first character/digit, and then remove the last character/digit again. After which the unmodified input is output implicitly (with trailing newline). 56) Σ9: Sort the characters/digits in the implicit input by 9 (so they'll all stay at the same positions), after which the unmodified input is output implicitly (with trailing newline). 57) 8ì¦: Prepend an 8 in front of the implicit input, and then remove the first character again. After which the unmodified input is output implicitly (with trailing newline) 58) āĀÏ: Push a list in the range [1, implicit input-length] (without popping). Python-style truthify each value in this list (so they'll all becomes 1s). Only keep the characters/digits of the implicit input at the truthy (1) indices, after which the unmodified result is output implicitly (with trailing newline). 59) ""«: Append an empty string to the implicit input, after which the unmodified input is output implicitly (with trailing newline). 60,61) ‘‘Û, ’’Ü: Trim all leading / trailing empty strings of the implicit input, after which the unmodified input is output implicitly (with trailing newline). 62) ““¡: Split the implicit input on an empty string, after which the unmodified input is output implicitly (with trailing newline). 63) ₆¢: Count the amount of 36 in the implicit input. Not sure why, but when using a multi-character value with the count, there seems to be a bug and it results in the unmodified string, instead of the actual amount of 36 substrings in the string I was expecting.. So this will output the unmodified input implicitly (with trailing newline). Only string input: 64 through 125) ǝαβив!%&(*+-/÷;<>BLbcefhjmnoptxz~‰£°±·¿ÃÆÈÉÌÍÑÒÓÕÖ×ØÝãäçèîôöùú: All these are integer operations (see the Wiki-page linked in the title to see what each does). They are no-ops for the (implicit) input-string(s); after which the unmodified input at the top of the stack is output implicitly. 126) ∍: Extend/shorten the implicit input-string to a size equal to the implicit input-string, after which it is output implicitly (with trailing newline). 127) δ: Apply double-vectorized. For integer inputs, it will implicitly convert to a $$\[1, a]\$$ range before applying double-vectorized. For strings, the implicit input is output implicitly. 128) Λ: Apply the Canvas with three options. For the digits 0 through 7, it will output the digit in a certain direction and length, depending on the input. For any other input, it will be a no-op outputting the implicit input implicitly (with trailing newline). 129) –: If the top of the stack is 1, it will print index N. So this will output 0 for input 1, but will output the implicit input itself implicitly (with trailing newline) for any other input. 130) —: If the top of the stack is 1, it will print item y. So this will output an empty string for input 1, but will output the implicit input itself implicitly (with trailing newline) for any other input. 131) œW: Get all permutations of the implicit input-string. Then push the minimum (without popping), which for string inputs will simply use the very first string. Then output this unmodified input at the top of the stack implicitly (with trailing newline). Only string input, and the output is a character-list: 132) S: Convert the implicit input to a list of characters and output it implicitly (with trailing newline). 133,134) ε, €: Map over each character in the implicit input, and output the resulting character-list implicitly (with trailing newline). 135) gι: Push the length of the implicit input. Uninterleave the implicit input using this length as block-size. After which the resulting character-list is output implicitly (with trailing newline). 136) øøø¬: Zip/transpose three times; swapping rows/columns. If it's a matrix, it will do as expected. If it's a string or list, it will use the implicit input as a pair-and-zip/tranpose. Since we're doing it three times, the following will happen: "abc"["aa","bb","cc"][["a","aa"],["b","bb"],["c","cc"]][["a","b","c"], ["aa","bb","cc"]]. Then we'll push the first inner list (without popping), after which this list at the top of the stack is output implicitly (with trailing newline). 137) ü1: ü is the overlapping builtin. It can be used with any other builtin to execute that builtin on every overlapping pair. But it can also be used with a single digit to create overlapping pair (2), triplets (3), quartets (4), etc. Apparently it also works with 1 to just convert the (implicit) input-string into a character-list, which is output implicitly (with trailing newline). Only character-list input: 138) í: Reverse each character in the implicit input-list, after which the unmodified input-list is output implicitly (with trailing newline). 139) ˜: Flatten the implicit input-list, after which the unmodified input-list is output implicitly (with trailing newline). 140) ζζΩ: Zip/transpose the (implicit) input-list twice: ["a","b","c"][["a","a"],["b","b"],["c","c"]][["a","b","c"],["a","b","c"]]. And then pop and push a random item of this list of lists, which are both the unmodified input-list. After which it will be output implicitly (with trailing newline). Only integer input: 141,142,143,144) E, F, G, ƒ: Start a ranged loop with the implicit input (E = $$\[1, a]\$$; F = $$\[0, a)\$$; G = $$\[1, a)\$$; ƒ = $$\[0, a]\$$), and output the implicit input implicitly (with trailing newline) afterwards. 145) ï: Convert the implicit input to an integer, after which the unmodified input is output implicitly (with trailing newline). 146) ò: Round to the nearest integer (which it already is), after which the unmodified input is output implicitly (with trailing newline). 147) þ: Only keep the digits of the implicit input-integer, after which the unmodified input is output implicitly (with trailing newline). 148) #: Split the implicit input-integer by spaces (it has none), after which the unmodified input is output implicitly (with trailing newline). 149,150,151) u, l, ™: Convert the implicit input-integer to uppercase / lowercase / titlecase, after which the unmodified input is output implicitly (with trailing newline). 152) ¶м: Remove all newline characters of the implicit input-integer, after which the unmodified input is output implicitly (with trailing newline). 153) ‚ß: Pair the implicit input-integer with the implicit input-integer, and then pop and push its minimum. After which it is output implicitly (with trailing newline). 154) AÚ: Trim leading and trailing lowercase alphabets of the implicit input-integer, after which the unmodified input is output implicitly (with trailing newline). 155) |M: Push all inputs as list. Push the largest value on the stack (including in all inner lists/matrices). After which the top of the stack is output implicitly (with trailing newline). 156) ∞@0k: Push an infinite positive list [1,2,3,...]. Check for each value if the (implicit) input is larger than or equal to this value (1 if truthy; 0 if falsey). And then get the 0-based index of the first 0 in this infinite list. After which it is output implicitly (with trailing newline). 157) µ¾Ê: Continue looping until the counter_variable (default 0) is equal to the implicit input-integer. Push the counter_variable each iteration, and check that it's NOT equal to the implicit input-integer. If this is truthy, the counter_variable will implicitly be increased by 1 after every iteration. When it becomes falsey, it means it's equal to the input-integer, and thus the loops stops, after which the counter_variable is output implicitly (with trailing newline) as result. 158) Œà: Push all substrings of the implicit input-integer, and then pop and push its maximum. After which this top of the stack is output implicitly (with trailing newline). 159) Z)Z: Get the largest digit of the implicit input-integer (without popping). Then wrap all values on the stack into a list, which is the input itself and its max digit. And then get the maximum again of this integer-pair (without popping), which will be the input itself. Then output the input at the top of the stack implicitly (with trailing newline). Unused characters / builtins: I'm pretty sure nothing useful is left anymore now.. Integer constants: 234567Tт₁₂₃₄₅Y®N• Empty list constant: ¯ Empty string constant (if used twice): ” (Partially) uniquify / sort builtins: Ù{êÔγ Convert from binary/hexadecimal to integer (which works on any input unfortunately): CH Checks resulting in truthy/falsey (0/1): Θ≠Qad›‹Ëå Recursive environment (which I can't close without } nor ]): λ Infinite loop (which I can't stop without # nor q): [ (Compressed) string/integer builtins, which result in errors on their own: '„…ƵŽ Ord (convert to codepoint integers): Ç Convert to a list and cycle infinitely: Þ Only leave the letters (which won't work if the input contains anything else): á Get the second or third input (we are only allowed to take a single input): ²³ Palindrome / mirror: ûº Cartesian product: â  • Wow... The persistence is incredible ⍤ ⍥ ⍤ – AviFS Jun 10 '20 at 23:45 # perl -pe, 8586 87 programs perl -pe 000 perl -pe 111 ... perl -pe 999 perl -pe aaa perl -pe bbb ... perl -pe zzz perl -pe AAA perl -pe BBB ... perl -pe ZZZ perl -pe '__' perl -pe '$$' perl -pe '%%' perl -pe '@@' perl -pe ';;' perl -pe '**' perl -pe '##' perl -pe '""' perl -pe "''" perl -pe '' perl -pe '//' perl -pe '::' perl -pe '??' # Only if your perl is old enough (pre 5.22) perl -pe ' ' # Spaces (or tabs, or newlines, etc) perl -pe '()' perl -pe '[]' perl -pe '<>' perl -pe '{}' perl -pe '\&\' perl -pe '' # Empty program  They all copy their input to output. ## How does it work? perl -pe reads the input line by line, and executes the given program, where _ contains the read line. After executing the program, it prints whatever is left in _. None of the given programs modify _, all statements are just noops. In short, all digits, all upper case letters and all but 3 lower case letters can used single (or double, triple, etc). They're either numbers or strings in void context. Since m, s, and q used single may be commands, (and for q, this is also the case when used double), using them all as triples will do. Many other characters can be used, sometimes single, or otherwise double. But if we can use them single, double will work too, hence we used doubles. __ is just a string. $$, @@, %%, and ** are variables. ;; are two command separators. "" is an empty string, and so is ''. Double backticks just execs a empty command. ## is a comment. :: is an alternative way of spelling the package main. // is an empty regexp. ?? is the weird regexp operator you never needed, or probably never knew about (it repeats the last successful match). Any of the whitespace characters (space, newline, tab, etc) can use used as well. This leaves a few characters I could not use by themselves, and I had to pair them with another: [] is an empty array. () is an empty list. <> reads line from the input. {} is an empty block. \&\ is a reference to (non-existing, but Perl is fine with that) subroutine named \. And of course, the empty program qualifies as well (thanks to David G. for pointing that out). This leaves !, +, ,, -, ., =, ^, |, ~ as an exercise for the reader. That's 10 (digits) + 52 (lower + upper case letters) + 6 (white space) + 13 (other characters used by themselves) + 5 (programs with 2 different characters) + 1 (empty program) = 87 programs. • Ah, of course. Ruby has the same thing but not as many single letters let you no-op. – Value Ink Jun 10 '20 at 0:23 • What kind of magic is this!? – Bubbler Jun 10 '20 at 0:26 • @Bubbler all the work goes into the -p flag, which takes a line of input, runs the program, and outputs it. The trick is in the fact that all these programs are no-ops. – Value Ink Jun 10 '20 at 0:29 • did you forget the empty program? – David G. Jun 11 '20 at 3:51 • @DavidG. No, but for some reason I assumed it wasn't allowed. But it's explicitly stated it is. – Abigail Jun 11 '20 at 9:42 # R, 1115 programs This is a very interesting challenge for R, we get to use lots of different features of the language! firstly, in R, any expression that isn't assigned somewhere is printed by default, so the empty program counts (it will return an integer unchanged, for example) c can be treated as a function of one argument that will return it unchanged. I adds a class attribute, but this does not affect the printing. t will return its argument as a 1x1 matrix (I hope this counts as "unchanged" for the purposes of the problem). min will return its argument unchanged if that is a single integer. as.raw will return a hexadecimal integer unchanged (from my reading of the problem, I think that's acceptable.) + as a unary function of one integer will return it unchanged. 1* as a program will then generate a prompt for the second argument: entering it will return the entered integer unchanged. --, similarly to 1*, will generate a prompt for a number which is then negated twice and therefore printed unchanged. (Edit: T%x% will do the same, taking the Kronecker product of the entered number with TRUE==1 --- thanks Robin Ryder) ( and '{' both return their argument (they are formal functions in R). They need the quotes to function, but luckily R lets you use different kinds of quotes. "\u73\u75\u6D" will also work as a function; the escapes evaluate to "s", "u" and "m" respectively which gives sum, which will return its argument unchanged if it is a single integer. Lastly, everyone always forgets about complex numbers but Re and Mod will return the real part and modulus of the argument respectively. If that argument is an integer then they are no-ops. Thanks to Giuseppe for the min and brackets ideas and to Robin Ryder for some other suggestions! • You could add { (with back ticks) as another – Giuseppe Jun 12 '20 at 12:32 • yes — you are actually allowed to use all quote types for referencing functions, so I can have both { and ( – JDL Jun 12 '20 at 12:33 • Maybe use ""m\x69\x6E" aka min and (? – Giuseppe Jun 12 '20 at 15:12 • t should be acceptable as well (transposing a single integer returns the same integer). If you include it, you have to remove identity, freeing up the characters i and n. You can now include min directly, and save the hex code trick to get sum as "\x73\x75\x6D". – Robin Ryder Oct 13 '20 at 19:19 • Nice use of Re! Mod is a great idea: you can remove T%o% and "\x73\x75\x6D", and replace with Mod, "\u73\u75\u6D" and T%x% for a net gain of +1 solution. – Robin Ryder Oct 14 '20 at 13:57 # Brain-Flak, 252 programs The first 5 programs are: [] () <><> #{}  and the empty string. These programs have 9 unique characters total. Each of the remaining 247 programs consist of an individual byte other than (){}<>{}#. ## How? In brain-flak, an empty program prints it's input. Any character other than #(){}[]<> has no affect on the behavior of the program. Try it online! • I think it'll be difficult to encode all of the 137929 unicode characters without repeating any byte in the encoding of each of them... – Dominic van Essen Jun 10 '20 at 11:47 • @DominicvanEssen Oh I missed Any single byte cannot appear in two or more programs, though it may appear more than once in a single program. You may freely use multi-byte characters, as long as every byte value consisting of each multi-byte character follows this exact rule.. Thanks for pointing that out, I'll fix – James Jun 10 '20 at 12:04 • Niggling question (and maybe I'm wrong...), but is the zero-byte equivalent to an empty string? This would mean only 251 programs (which isn't so bad, anyway)... – Dominic van Essen Jun 10 '20 at 12:10 • @DominicvanEssen Good question. For a null-terminated string like in C there is no difference. But other languages can have string that are not null terminated (character arrays, pascal strings, etc.) and more importantly, you can store null bytes in a file – James Jun 10 '20 at 12:12 # Charcoal, 12 15 programs Edit: Added three more programs which are no-ops only on numeric input. ↧  Try it online! Lowercases the implicit input, which has no effect for numeric input. ↥  Try it online! Uppercases the implicit input, which has no effect for numeric input. θ  Try it online! Link is to verbose version of code. Prints the default input. Ｓ  Try it online! Link is to verbose version of code. Prints the explicit string input. Ａ  Try it online! Link is to verbose version of code. Prints the explicit input. ＩＮ  Try it online! Link is to verbose version of code. Casts the explicit numeric input to string so that it can be printed. ∨⁰  Try it online! Prints the logical OR of 0 and the implicit input. ∧χ  Try it online! Prints the logical AND of 10 and the implicit input. ⮌⮌  Try it online! Prints the implicit input reversed twice. ⁺ω  Try it online! Prints the empty string concatenated with the implicit input. ×¹  Try it online! Prints the implicit input repeated once. ﹪%s  Try it online! Formats the implicit input as a string. ⊟⊞Ｏυ  Try it online! Pushes and pops the implicit input to a list before printing it. ⎇℅ψφ  Try it online! Prints the implicit input if the null byte's ordinal is zero. ⭆⊖²⊖⊕  Try it online! Increments and decrements one implicit (numeric) input, then joins the results together. • I see you are using characters outside of ASCII, and even outside of the Latin-1 range. What kind of encoding are you using to not violate the Any single byte cannot appear in two or more programs, though it may appear more than once in a single program. You may freely use multi-byte characters, as long as every byte value consisting of each multi-byte character follows this exact rule. restriction? Charcoal seems to use UTF-8, which would disallow a number of your programs. – Abigail Jun 10 '20 at 8:59 • @Abigail Charcoal has its own code page but it also accepts Unicode for TIO's convenience. – Neil Jun 10 '20 at 9:48 # Brachylog, 88 programs I doubt this is the longest I can get it, as I'm only posting this now because I need to take a break from making more of these, and if character lists are admissible for strings I know this can be expanded even further. The reason so many one-character solutions exist is that Brachylog has a lot of variables, constraint predicates, and flow control commands, plus a fair number of nondet predicates that happen to have the exact input as their first output. 1. The empty program, for integers or strings. 2 - 27. Any uppercase ASCII letter, for integers or strings. 28. İ for integers. 29. Ṡ for strings. 30 - 42. Any one of ȦḂḞĠḢṄṖṘẆẊẎŻ, for integers or strings. 43. A space, for integers or strings. 44. A newline, for integers or strings. 45. ?, for integers or strings. 46. ., for integers or strings. 47. &, for integers or strings. 48. |, for integers or strings. 49. ≜, for integers. 50. w, printing an integer from stdin. 51. ẉ, printing an integer from stdin with a trailing newline. 52. p, for strings. 53. s, for strings. 54. ≡, for integers or strings. 55. !, for integers or strings. 56. A backtick, for integers or strings. 57. ⊆, for strings. 58. ⊇, for strings. 59. (), for integers or strings. 60. {}, for integers or strings. 61. ↔↔, for strings. 62. ↺↻, for strings. 63. ∈h, for strings. 64. ,Ė, for strings. 65. ṅṅ, for integers. 66. gṛ, for integers or strings. 67. ℤ, for integers. (can't believe I forgot this earlier, but I can't be bothered to renumber everything) 68. ḋ×, for integers. 69. +₀, for integers. 70. ℕ, for integers. (I didn't notice the restriction to positive!) 71. ȧ, for integers. (again, specifically positive) 72. ṫị, for integers. 73. ċ₂, for strings. 74. ÷↙Ḋ, for integers. 75. ḅc, for strings. 76. <<<-₃, for integers. 77. aʰ, for strings. 78. f⌉, for integers. 79. dᵗ, for strings. 80. =ᵐ, for strings. 81. ≠ˢ, for strings. 82. ;1/, for integers. 83. ^₁, for integers. 84. jḍt, for strings. 85. ~⌋⌋, for integers or strings. 86. ⟦bl, for integers. 87. ⟧k∋ᶜ, for integers. 88. ≤, for integers. • I see you are using characters outside of ASCII, and even outside of the Latin-1 range. What kind of encoding are you using to not violate the Any single byte cannot appear in two or more programs, though it may appear more than once in a single program. You may freely use multi-byte characters, as long as every byte value consisting of each multi-byte character follows this exact rule. restriction? – Abigail Jun 10 '20 at 8:32 • – Unrelated String Jun 10 '20 at 8:48 # APL (dzaima/APL), 38 functions/programs The code to be counted is parenthesised below. The first two entries are full programs, the rest are tacit prefix functions, except {⍵} which is a prefix lambda. (⎕) ⍝ prompt for numeric input and implicitly print it (⍞) ⍝ prompt for string and implicitly print it (⍮)I ⍝ 1-element with (no visual difference on simple scalar) (⌷)S ⍝ materialise (no-op on anything but certain objects) (∧)I ⍝ LCM reduction (no-op on scalar) (∨)I ⍝ GCD reduction (no-op on scalar) (⌽)I ⍝ mirror (no-op on scalar) (⍉)I ⍝ transpose (no-op on scalar; TIO's version has a bug that has since been fixed) (⊖)I ⍝ flip (no-op on scalar) (+)I ⍝ complex conjugate (no-op on real number) (∊)S ⍝ enlist (no-op on strings) (↑)S ⍝ mix (no-op on simple arrays) (↓)I ⍝ split (no-op on simple scalars) (⊢)S ⍝ identity (⊣)S ⍝ identity (⌈)I ⍝ ceiling (no-op on integer) (⌊)I ⍝ floor (no-op on integer) (⍕)I ⍝ stringify (no-op on string) (⊂)I ⍝ enclose (no-op on simple scalar) (⊃)I ⍝ first (no-op on simple scalar) (∪)I ⍝ unique (no-op on simple scalar) (|)I ⍝ absolute value (no-op on positive numbers) (,)I ⍝ ravel (no-op on strings) (⍪)I ⍝ table (no visual difference on scalars) (⍷/)I ⍝ use find (arbitrary otherwise unused function) to reduce (no-op on scalar) (1⌿)S ⍝ replicate all elements to 1 copy each (no-op on string) (9○)I ⍝ real part (no-op on real number) (⍟*)I ⍝ natural logarithm of e to the power (⍬,)S ⍝ prepend the empty list (no-op on string) (⊥⊤)I ⍝ the base-2 evaluation of the base-2 representation (--)I ⍝ negate the negation (÷÷)I ⍝ reciprocate the reciprocal (~∘8)S ⍝ remove all occurences of number 8 (no-op on string) ({⍵})S ⍝ user-defined identity function (!⍣0)I ⍝ apply the factorial zero times (''⍴)I ⍝ reshape to 0D (no-op on scalar) (.5×2×)I ⍝ half the double (⍳∘≢⍛⊇⍨)S ⍝ use all the indices to permute the argument (this one is supposed to say ⍤ instead of ∘ but TIO isn't updated) Try it online! ## Haskell, 5 6 programs ### 1: id  Haskell has an identity function, so that is a good start. It uses i and d which are not terribly valuable anyway. ### 2: k x=x  A simple definition of an identity. It uses = which is going to make it hard for us to define any new functions (instead we will have to build them). And it also uses the space which is would be useful otherwise. ### 3: \z->z  This is a lambda of the last version. This marks the end of the straight forward identities. ### 4: (*1)  Multiplies the input by 1, which is an identity for members of the Num class. This uses up the very valuable parentheses. ### 5: abs  As pointed out by H.PWiz since the input is positive abs is an identity ### 6: fromEnum  This is an identity on integers. At this point we still have a lot of room we could use <$> or $ (replacement for space or parentheses), however I can't get anything to fit the t in Just is a problem for things like subtract, const and repeat which would be useful. • You can replace sum.Just with abs and fromEnum, since the input is positive – H.PWiz Jun 11 '20 at 0:07 • I'm partial to (const const) myself – Andrew Ray Jun 11 '20 at 20:12 # Stack Cats, 19 programs All programs that are exactly mirrored in Stack Cats function exactly as cat programs. Therefore, we can score one program for each valid symmetric character by having there be two of them, and we can score one program for each pair of matching characters. These character sets are: !"*+-:=ITX^_| (){}[]<>\/  Unfortunately, most other characters cause syntax errors in the existing interpreters. However, the empty program is also symmetric, so it also produces a cat program. Sample symmetric program: II  Try it online! Sample matching program: {}  Try it online! Empty program example: Try it online! • Nice language choice! – Bubbler Jun 10 '20 at 0:50 # Husk, 1 program + 24 functions Programs: 1. ḟ=⁰N - Find an element that equals the last command-line argument in the infinite list of natural numbers. Try it online Functions: 1. I - the identity function 2. +0 - Add 0 3. *1 - Multiply by 1 4. D½ - Double and then halve 5. ĠK - Scan right without an initial value. The K combinator just discards the second argument, so the list remains the same. 6. ←; - Make a singleton list, then get the first element. Try it online 7. __ - Negate twice 8. ⌉ - Ceiling (identity for integers) 9. ⌋ - Floor (identity for integers) 10. i - Round (identity for integers) 11. a - Absolute value (identity for positive numbers) 12. √□ - Square root of square 13.  - Swap arguments of binary function twice 14. \\ - Reciprocal twice (Try it online!) 15. LR"3" - Repeat "3" n times, then take the length, giving back n. Can be something other than 3 16. -ø - Remove the empty list (Try it online!) 17. cc - Convert integer to character, convert character back to integer 18. dd - d can both get the base 10 digits or interpret digits in base 10 19. n¹ - Bitwise and with itself 20. tΘ - Prepend default value, then get tail 21. s - Show (for strings) 22. ↔↔ - Swap pair/reverse list/reverse digits twice 23. !4∞ - Get fourth (arbitrary) element of infinite list of copies of argument 24. ΣC2 - Cut into sublists of size 2, concatenate them (for lists of size > 1) • Nice first Husk answer! A few more off the top of my head: ⌉⌋ia are ceil, floor, round and abs. √□ is square then sqrt (perfect squares produce integers).  \\  is invert twice. LR"2" is repeat "2" n times then length. – Zgarb Oct 12 '20 at 20:49 • @Zgarb Thanks! It's actually my third, I had to delete the first two :\ – user Oct 12 '20 at 21:08 • tΘ and s for strings, ↔↔ for strings and numbers, !2∞ for numbers – Razetime Oct 14 '20 at 13:57 • @Razetime Cool, I'll add those too! – user Oct 14 '20 at 14:20 # Python 3, 4 programs Python turned out to be much harder than I thought, with only 4 so far. int abs repr (1).__mul__  Try it online! # Ruby, 4 programs ->x{x}  The basic stabby lambda form. Try it online! def f e;e;end  The classic way of defining functions in Ruby. Try it online! puts(ARGF.to_a.sum(""))  Takes the input stream ARGF (points to STDIN if no program arguments are present), turns it into an array, combines it again (using sum because join shares an n with the previous program) and outputs it. Try it online! b=*$<
STDOUT<<b*''


$< is an alias for ARGF. Same as above, but uses the splat operator * to turn it into an array, and joins it using the array join operator *. Try it online! • @Bubbler fixed. – Value Ink Jun 10 '20 at 17:56 # Keg, -hr, -lp 17 programs There'll be more soon. #  Try it online! ,  Try it online! .  Try it online! Try it online! 0+  Try it online! 1*  Try it online! ¿  Try it online! ᠀  Try it online! ∑)  Try it online! :  Try it online! "  Try it online! ±±  Try it online! ⅍  Try it online! ;⑨  Try it online! ⑵½  Try it online! ④_  Try it online! ⑩᠈  Try it online! • I thought adding flags made it count as a "different language" now? – Value Ink Jun 9 '20 at 23:45 • – Jerry Jeremiah Jun 9 '20 at 23:51 • @JerryJeremiah yes, that is the exact meta post I had in mind. I wonder how its "different language"-ness applies in relation to this challenge, and this answer. – Value Ink Jun 9 '20 at 23:52 • Let me clarify: All programs in a single answer must use the same combination of flags. So "Keg" (no flags) and "Keg -hr" must go to separate answers. – Bubbler Jun 9 '20 at 23:58 • @Bubbler I fixed it to use all the same flags – Lyxal Jun 10 '20 at 0:06 # AWK, 21222425 26 programs Edit: thanks to Abigail for duplicate-letter-spotting and for the suggestion that led to l^l! Edit: +2 +3 more programs thanks again to Abigail Awk will print the input line by default if a condition evaluates to TRUE. non-zero values that evaluate to TRUE: 1 2 3 4 5 6 7 8 9  experessions that evaluate to TRUE: $0 # only if input is not equal to the digit zero (so Ok for positive integer)
a~a
b==c
d---d
++f
!h
"j"
'k'
//
m^m
q**q


built-in variables that evaluate to TRUE:

NR
OFMT
SUBSEP


functions that evaluate to TRUE

log
exp
int i


Try it online!

• rand and tolower j share the r. And you've already used the a, d, and e. (But those are fixable by using other variables) – Abigail Jun 10 '20 at 10:54
• You can use ++h, instead of ++h>i to save the > for use elsewhere (although I haven't found a use for it yet). (And that would also get rid of the duplicate usage of i). – Abigail Jun 10 '20 at 11:06
• cos, exp, sin, log, int i, and sqrt i all evaluate to true as well. (But you can't use all at the same time). – Abigail Jun 10 '20 at 11:24
• f---f evaluates to true as well, which rescues the > for later use. – Abigail Jun 10 '20 at 11:31
• q**q evaluates to true as well. – Abigail Jun 10 '20 at 17:10

# Scala, 9 functions

x=>x


A lambda function.

math.abs


A utility function from the math package.

For the following functions, we use the fact that methods on objects can be converted to functions if no arguments are given.

1*
0+
2-2|      // bitwise or with (2-2)
~(8&4)&   // bitwise and with ~(8&4)
3^3^      // bitwise xor with (3^3)
Nil:::    // concat with an empty sequence

_ ##


Here, the underscore is syntactic sugar for a lambda argument. It calls the method ## on it, which calculates a hash code, but is an identity function for integers.

• It obviously doesn't, thanks for the note. I updated the answer. – corvus_192 Jun 12 '20 at 7:46

# Brainetry, 1 program

1 is the maximum score attainable by the Brainetry programming language. The programs below are cat programs, they take any user input and output it unchanged.

a b c d e f
a b c d e f g h
a b c d e f g
a b c d e f
a b c d e f g h i


Brainetry is partially symbol independent but it needs spaces to understand what instruction each line refers to, so a program with no spaces can only be composed of empty lines and lines with one word, corresponding to the « and » instructions, which are not useful for this challenge.

The program above was golfed from this other program:

This program you are currently reading
has the particularity of explaining itself. In fact,
this program has one simple mission :
Take some input provided by you
and throw it right back at your face !!!


# PHP, 6 programs (functions)

abs
fn($n)=>$n
iNtvAl
chop
HeBreV
TRIm


Try it online!

We're taking advantage of PHP looseness about functions lower/upper case and types (all these fall into first case: taking an integer and return it unchanged), still searching for more

# Clojure, 8 functions

They are:

+
*
/
->
do
max
str
(fn[n]n)


Arithmetic operations in Clojure are variadic functions that when given only one argument return it unchanged, and thus work as identity functions for numerics.

Minus is an exception, because with one argument it becomes unary negation. But in its place we can use threading macro ->, which with no further functions to apply returns the supplied value as is.

do is a special form that is normally used to group several expressions into one and returns the value of the last one (in our case - the only one).

max of one entry is obviously equal to the entry itself.

str converts the argument to string, and so is the identity for strings.

Finally, the last one is an explicitly written out identity function.

Many important letters are now exhausted, and with () used up we aren't going anywhere further in a Lisp. I haven't included several other possible functions because they collide with those above:

identity
min
and
or


# Rust, 2 functions

|x|x
i8::abs


Sadly, the colon is needed for all other ways to define a function.

# Zsh, 4 functions/math functions

()((argv))                 # bind as a math function
int                        # math function from zsh/mathfunc
echo -E - $@ # string arg to stdout <&0 # stdin to stdout  Try it online! This is with zmodload zsh/mathfunc for int. This is not the only combination of 4 functions, but it is the shortest set I found that only uses a single zsh/mathfunc function. Either echo or print can use $'\xHH' notation to replace conflicting characters, in which case ceil can also be substituted in place of int.

# J, 13 functions

## Either

[ and ] return their arguments.

> removes their argument from a box. Strings and integers don't have boxes.

## Rank 0 Array

(characters or integers)

=/ acts on a more than length 1 array. Rank 0 arrays are always length 1.

## Positive Integers

| is magnitude, which is abs(x) in Python. Does nothing for positive integers.

+ is complex conjugate, which negates the imaginary part.

---- negates the number 4 times.

%%%% takes the reciprocal of the number 4 times.

** is a hook that becomes y*(*y). For positive integers, *y always returns 1. That means (**)y is y*1.

^# is a hook that becomes y^(#y). For rank 0 arrays, #y always returns 1. That means (^#)y is y^1.

<. rounds down a number to the nearest integer. The nearest integer from an integer is the integer itself.

1&! returns how many ways you can pick 1 ball from a bag of y balls, which is y.

0}~ works.

• Dropping {:, -/, *=, %#, #. (which was double) there is ----, %%%%, **, ^#, ,, ;. >, <., ":, 1&!. 0}~, which then only leaves ={\?$. Any of these can be put into X/. – xash Jun 14 '20 at 13:52 • And you can throw some standard library functions into the mix. – Bubbler Jun 15 '20 at 9:06 • @xash I didn't include , and ; because they actually return a length 1 rank 1 array, not a rank 0 array. – PkmnQ Jun 16 '20 at 8:41 # str, 19 programs This is a very flexible language, because the empty program works, and there are a lot of no-op functions, or things that can be combined into no-ops. All of these are programs taking strings as input. 1. The empty program 2. A space character 3. A tab character 4. A newline character 5. . (this and the whitespace above explicitly do nothing) 6. ; (the ; character is used as a separator and does nothing by itself) 7. 3~ (push a value, then swap it. The language only pays attention to the top value of the stack for each character) 8. 2$ (push a value, then discard it)
9. e: (concatenate each character with the empty string)
10. oq (explicitly print each character, then tell the language not to implicitly print it)
11. 1x (repeat each character one time)
12. bu (move each character to the buffer, then back to the stak)
13. yc (convert to a number, then back to a string)
14. m (convert to a string, which it already is)
15. XY (increment by one codepoint, then decrement again)
16. w (unlike all the above programs, this adds a trailing newline. I have no idea why this works)
17. 0- (subtracts 0 from each character)
18. _ (_ is the reverse function, except it operates on each character individually, so does nothing here)
19. d (duplicates each character, but the implicit output only prints one character per input, so this amounts to nothing)

# Python 3, 5 solutions (a program, three functions and a default-value variable)

I see there's already a Python 3 answer, but I thought I'd try and make another one anyway. Or should it have been a comment?

• exec("p\x72\x69\x6e\x74(\x69\x6epu\x74())") # reads a line from standard input and writes it to standard output, the code has most letters escaped so they aren't directly included, and then the quotes unescape them and exec runs them
• str # returns an argument as a string
• lambda a:a # returns an argument
• ''.join # returns a string with nothing inserted between the characters
• _ equals the previous line (this one only works in the interactive interpreter, but the other ones work there too, so it should probably be okay). I think I saw some solution to another puzzle here using a default variable like that as an input, so hope that's okay. Otherwise this is four solutions, like the other answer.

# ><>, 3 programs

><> has exactly two characters that can be used for output. n prints an integer.

Program 1:

n;

The other output character is o, printing an ascii character. Since we have already spent the program terminator ; and programs are required to halt, we can trigger the "something smells fishy..." by division by zero

Program 2:

io00,

But yet another program is still possible. A n or o character can be obtained by reflection, which only p can perform.

Program 3:

ab*aa-:p4f*1-1aa-p

The useable IO instructions in ><> are then depleted.

# Elixir, 5 functions

+
abs
round
ceil
&(&1)


Well, unary + is technically an operator, but I think it should count, as it really quacks like a function in Elixir. For instance, it can be captured and passed as an argument to a higher-order function in the same way as a named function, and even the syntax for overriding unary operators is like defining normal functions.

The next three are numerical functions that work as identity for positive integers. These are all defined in Kernel module (ceil available from version 1.8+), which is imported by default, and thus callable directly without qualifying the module name.

Finally, the last one is a shorthand form of the explicit identity function.

As always, there are other unused candidates that share characters with those above. In particular, the letter n is rather "popular":

floor
trunc
to_string
Function.identity
fn n->n end


# Wolfram Language (Mathematica), 14 15 functions

Verify: with Re or with Ramp

Mathematica only has so many ways to define a function, but there are still has a good number of built-ins up to the task.

1. #&. A function that returns its first argument.

2. $$. A function of one variable that returns that variable.  is U+F4A1.

3. f_//f=f. Defines a function f that returns its argument.

4. ⌊⌋〚1-1〛. The floor function Floor[][[0]]. ⌊⌋〚〛 are U+230A, U+230B, U+301A, and U+301B, respectively.

5. \043\046. Escape sequences for #&.

6. z[[I+I I I]] The complex conjugate Conjugate[z][[0]].  is U+F3C8

1. D. Computes the derivative, but acts as identity when passed only one argument.

2. N. Converts the argument to a numeric (approximate) value. For Integers, returns the Rational corresponding to that integer.

3. Or. Logical or. Returns the argument when called with only one argument.

4. And. Logical and. Returns the argument when called with only one argument.

5. LCM. Computes the least common multiple of its arguments.

6. Sow. Returns its argument. Additionally, allows that value to be collected by an enclosing Reap.

7. Exit. A function that returns an integer via exit code.

Note that Run returns 256*(return code) on TIO instead. Try it online!

8. Plus. Returns the sum of its arguments.

The final function can be either of:

# Java, 2 functions

x->x


A lambda function.

Function.identity()


This returns the identity function.

Without the letters e and t, we can't use any of the {byte,char,short,int,long}Value, valueOf or toString methods.

• You can use \uXXXX literals in place of letters in identifiers. – LegionMammal978 Jun 11 '20 at 23:30

# CJam, 3 programs + 20 functions

Programs first, these work just as you'd expect:

r


TIO: Integer stdin input. Technically, CJam has no integer input, but reading and returning a space-separated string is no different if you're just sending an integer.

l


TIO: Line stdin input

q


TIO: Line stdin input. Can actually accept more than one line, as demonstrated here, but if you just give it one that's okay too.

Bonus unused program:

114c~


TIO: Integer stdin input. There's only 3 ways to get stdin in CJam, so we've got a pretty hard limit there. However! We can use ~ to execute a string as code, so we can sneak a fourth one in. Unfortunately, this uses up too many useful bytes for our functions later.

Functions next. A reasonable definition for a CJam function is a piece of code whose input and output are the stack. I'm not 100% certain if this is actually allowed, though, so I've separated them here.




Int or string: no op is a no op.




Int or string: so is a space. Imagine StackExchange actually is rendering the space.





Int or string: newline is a no-op. You'd think there'd be a bunch of these, but CJam has an annoying habit of throwing errors on characters it doesn't recognize rather than ignoring them.




Int or string: tab is our last no-op. Hooray! (Imagination once again necessary.)

9;


Int or string: Pushes and discards a nine

()


Int: decrements, then increments.

s


String: converts to a string

i


Int: converts to an int




String: converts to a string representation.

1*


Int: multiplies by one

T+


X/


Int: divides by one

U-


Int: subtracts zero

e0


Int: multiplies by 10^0

mo


Int: rounds to nearest int

z


Int: takes absolute value, fine since positive is specified

V|


Int: bitwise or with 0

~~


Int: bitwise negates twice

KJ<^


Int: Ooh, four characters at once? Yeah, but it all amounts to an XOR with 0.

_&


Int: bitwise AND with itself

There's probably a couple others, but I'm running out of useful characters now, so I think I'll stop here. Feel free to add more, or point out if I accidentally used something twice (though I'm fairly sure I didn't)