# Do you know that language?

Your challenge is, given previous submissions and itself as input, output the language that they're written in, in the following format:

Say the first program is in Ruby. It must output 1, because Ruby is the 1st language used in this challenge. An example program is:

a=gets
puts 1


When given itself as input, it returns 1.

The next program might be in Python. It must output 2, because Python is the 2nd language used in the challenge. An example program is:

print(1 if input()[0]=="a"else 2)


Given the first submission, it outputs 1, and given itself it outputs 2.

You're allowed to repeat languages, though you're not allowed to submit an answer in the previous answer's language.

For example, if the third program is in Ruby, it must output 1 given the first program and itself (because Ruby is the 1st language used), and given the second program it must output 2.

## Rules:

• If there are n answers currently in the challenge, there must be at least floor(n / 3) different languages. Any submission that breaks this rule is disqualified.
• No two "neighbouring answers" (e.g. answer n and answer n+1) cannot use the same language.
• Different versions of a language do not count as different languages (so Python 2 == Python 3).
• Answers must take previous submissions in full as input.
• The first submission must take input.
• You are not allowed to submit multiple answers in a row.
• "Repeat answers" (answers that have the exact same code as a previous submission) are not allowed.
• Answers are not allowed to go over the allocated byte-count of that answer - see "Allocated Byte-count" for more details.

## Allocated Byte-count:

For each answer number n, the allocated byte-count for that answer is 45 + 5n.

# {answer no.}, {language}
{program}
This prints:
- 1 in answer(s) {all answers using 1st language, with links}
- 2 in answer(s) {all answers using 2nd language, with links}
...
{optional explanation}


For the answer lists, do this:

- 1 in answers [1]({link to answer}), [3]({link to answer})...


## Scoring:

The first answer to survive after 7 days without any valid submissions after that is declared the winner.

• Can one user post two consecutive submissions in a row? Jan 19, 2017 at 11:46
• So, as it stands, I could repeat as is, without any changes, my answer n°6 as answer n°8, after which Martin could repeat his number n°7 (unless I'm mistaken) etc. until answer n°15 before reaching the imposed threshold (i. e. floor(n / 3) languages). I'm guessing this is not intended behaviour. Jan 19, 2017 at 14:32
• @plannapus I noticed this as well. Of course, your goal is to have the last answer, so knowing that I would have a trivial follow-up too you might want to complicate things (which I didn't think about before posting my own answer). Jan 19, 2017 at 14:36
• Allocated byte count grows in geometrical progression, and probably these challenge will not terminate until we run out of languages, not because the code will become too long. Jan 19, 2017 at 15:41
• IMO a reasonable fixed limit (e.g. 384 or 256 bytes), would have worked better, and would trigger a tight competition at the end. Jan 19, 2017 at 18:03

## 1. Retina, 0 bytes

Try it online!

The empty program prints 1 when given empty input (i.e. itself), because it counts how often the empty regex matches the input (which is always 1+length(input)).

# 2. Brain-Flak, 22 bytes

{<>(())(<>)}{}(<>{}())


Try it online!

This checks the top of the stack and puts a one on the opposite stack if it is non-zero. It then increments and returns the opposite stack. This makes it return 1 for the empty program and 2 for anything else.

Since stacks in Brain-Flak default to zero, an empty program will have a zero on the top of the stack while any other program (except programs which end in null characters) will have a truthy value. This means we can run a very simple if program on the input stack.

{      (<>)}{}              #If not zero
<>(())                     #Push one to the other stack
(<>{}())      #Switch to other stack and increment by one

• Could you edit this answer? I accidentally down voted it :) Jan 20, 2017 at 12:42

# 3. APL, 7 bytes

' {'⍳⊃⍞


Explanation:

      ⍞  read from the keyboard
⊃   first item of list, or space if empty
' {'⍳    index into the string ' {', giving N+1 (=3) if not found


# 10. Bash (+coreutils) [language 6], 44, 74 bytes

Fixed Version (returns the language id)

expr substr "1234151516" $(expr index "365f8dc0eb" md5sum|cut -c12) 1 #G  Note: this expects the trailing newline, after the input program text ## 9. Retina (language 1), 20 bytes $|}\{|[:'][^]']|,\b1


Try it online!

Like plannapus, I decided to go for a rewrite to switch things up a bit, which also ended up shortening the code considerably (a modification of my last answer to account for plannapus's latest would have ended up around 32 bytes, I think).

### Explanation

Like my other answers, this just counts the number of various regex matches, but goes about it much more efficiently:

• $ matches the end of the string. This always works, even if there's a match going all the way to the end of the string, so this gives us a baseline of 1 for all inputs. • }\{ finds a single match in the second program (Brain-Flak), bringing the count there up to 2. The backslash isn't necessary for escaping but it prevents this part of the regex from matching itself. • [:'][^]'] is pretty fancy actually. The only purpose is to count the two ' in the APL program (language 3) and the three : in the JavaScript program (language 4), but we need to prevent this part from matching itself. So we also ensure that the next character is neither ', nor ] (because those don't appear after the ones we do want to match, but they do appear in this program here). • The ' from the previous part already causes one match in the R programs, so we need three more. The substring ,1 appears in both of them three times, and in no other programs. We match it by adding a tautological wordboundary in between with ,\b1 to prevent it from matching itself again. • Hm, just realised that this doesn't foil the R answers at all, because 1 is simply their default output. I'll have to do something about that with the next answer. Jan 19, 2017 at 15:14 # 18. C (language 10), 121 bytes This is the C89 or C90 standard. It works with either clang or gcc on Try It Online. main(n){char*v=" ^{ s ePfwm",b[999],*c;gets(b);c=strchr(v,*b);n=strlen(b);printf("%d",n?c?c-v:n>99?4:n>60?5:n>15?1:3:1);}  This prints: • 1 with answers 1, 5, 7, 9, and 14 (Retina). • 2 with answer 2 (Brain-Flak). • 3 with answer 3 (APL). • 4 with answers 4, 12, and 15 (Javascript). • 5 with answers 6 and 8 (R). • 6 with answers 10 and 17 (Bash). • 7 with answer 11 (Mathematica). • 8 with answer 13 (Python). • 9 with answer 16 (Perl). • 10 with this answer (C). Here is a bash driver that runs it with all 18 answers on Try it online! Ungolfed equivalent (646 bytes): #include <string.h> #include <stdio.h> int main(){ char *v=" ^{ s ePfwm", b[999]; gets(b); /* buffer overrun if more than 998 characters in the input. could be a problem if we get to 191 answers */ char *c = strchr(v, b[0]); /* Find first character of input in v, or null */ int n = strlen(b); if (!n) { printf("1"); } else if (c) { printf("%d", c-v); /* Index of first character of input in v */ } else if (n > 99) { printf("4"); } else if (n > 60) { printf("5"); } else if (n > 15) { printf("1"); } else { printf("3"); } return 0; }  ## 5. Retina (language 1), 23 bytes ^$|(?![⊂⍴])[⊂-⍴]|\B=|{}


Try it online! (Tests all possible inputs.)

Counts the matches of various things in the input:

• ^$ matches the input string, i.e. the first answer once. • {} matches itself, which there are two of in the second program, and one in this one. • (?![⊂⍴])[⊂-⍴] matches characters with code points 8834 to 9076, exclusive, which finds three matches in the third program. We use the negative lookahead to avoid the ends of the range being matched in this program. • \B= matches a = that isn't preceded by a word character. This matches four of the = in the fourth program, and doesn't match the = in this program. ## 7. Retina (language 1), 27 bytes ^$|(?![⊂⍴])[⊂-⍴]|\B=|{}|\b5


Try it online! (Tests all possible inputs.)

A minor modification of the fifth answer. \B= already finds 4 matches in the sixth answer, and \b5 finds another without matching any other answers.

# 26. ><> (language 12), 164 bytes

My first ever program in ><>! It's 156 characters, but 164 bytes in UTF-8.

^$|(?![⊂⍴])[⊂-⍴]|\B=|{} {:}&1+&=?v .&0/ v+!?='>'i41i v+?='y'i47 v+?=' 'i12 v+?=' 'i24 v4 v6 v7 v8 v9 va v?(0:i v1 n;\b1laa*)?+ /"^mwfPes{'tc"i2&01.;  This prints: • 1 with answers 1, 5, 7, 9, and 14 (Retina). • 2 with answer 2 (Brain-Flak). • 3 with answer 3 (APL). • 4 with answers 4, 12, and 15 (Javascript). • 5 with answers 6 and 8 (R). • 6 with answers 10, 17, 20, 22, and 25 (Bash). • 7 with answers 11 and 19 (Mathematica). • 8 with answer 13 (Python). • 9 with answer 16 (Perl). • 10 with answers 18, 21, and 23 (C/C++). • 11 with answer 24 (Zsh). • 12 with this answer (><>). Try it online! Explanation: The first line is simply answer #5. It does nothing but send the instruction pointer to the bottom line. / turns the fish right, and the characters ^mwfPes{'tc are put on the stack. A single character of input is read (i). (Let's call this character C for exposition.) 2 is put in the register (2&). Then we jump to the beginning of the second line (line 1) (01.). This line compares C to each character on the stack. A copy of C is kept on the bottom of the stack. { rotates the stack so C is on top; : duplicates it; } rotates the copy back to the bottom. We increment the register (&1+&) until a match is found. (So if C is "c", the register holds 3 when the match is found; if C is "t", the register holds 4, and so on.) Then we jump to the first character of the line number in the register (0&.). Lines 3 through 13 deal with what to do when C is c, t, ', {, etc., respectively. The instruction pointer is moving backwards when we jump; it lands on the first character of the given line, but after a jump it advances a tick before executing, so it begins executing from the end of the line going backward. Each line pushes the appropriate language number on the stack, then sends the fish down to the n instruction, which prints it out. ^ is the most complicated case, because of my own dastardliness with the first line of this answer. Line 13 reads input until EOF. Then it directs down to line 15, which compares the length of the stack (l) to 100 (aa*). If it is longer ()?), we add + b and 1 to get 12, this language; otherwise, 1 remains on top of the stack. # 4, JavaScript (ES6), 32 bytes s=>s?s[0]=={?2:s[0]==s?4:3:1  Outputs 1 for an empty input, 2 if the input starts with a {, 4 if it starts with an s and 3 otherwise.. • You can replace the s[0]=='{' by s[0]>'z' – user64039 Jan 19, 2017 at 13:05 • @Masterzagh I was also thinking about how this can be golfed, but alas, this isn't a code-golf :/ Jan 19, 2017 at 13:05 • @KritixiLithos Well yea, but he has already kind of golfed it so I thought he would want to go further. – user64039 Jan 19, 2017 at 13:07 • @Masterzagh People should avoid editing valid answers in challenges like this because they can invalidate a) later answers, b) answers that are currently being worked on. Jan 19, 2017 at 13:17 • @MartinEnder, you're right. As such I won't edit it. I know it looks golfed (because of the ternary operators), but I didn't write it like that on purpose... Thanks for all the feedback nonetheless! – Luke Jan 19, 2017 at 13:28 # 11. Mathematica [language 7], 53 bytes Position[Characters@"^{'sceP",#&@@#][[1,1]]/._@__->1&  Unnamed function taking a list of characters as its argument and outputting a positive integer. Simply branches on the first letter of the input, using its position in the string "^{'sceP" to decide on the output. This gives the right answer for all previous submissions except the initial empty Retina program and the most recent Retina answer; both of these spit errors, but the output is repaired by the rule /._@__->1 which transforms any unevaluated function to 1. • I think it's really time to mess up that first-character strategy :) Jan 19, 2017 at 18:43 • I was going to, but then I remembered I had to correctly output for my own language too :D Jan 19, 2017 at 19:03 # 16. Perl (language 9), 94 bytes while(<>){print substr("1234151516748149",index("0F=POmS6D4e_XWVH",chr(47+length($_)%70)),1);}


Try it online! (checks all answers). Outputs "1234151516748149"

This prints:

• 1 with answers 1, 5, 7, 9 and 14 (Retina).
• 2 with answer 2 (Brain-Flak).
• 3 with answer 3 (APL).
• 4 with answers 4, 12 and 15 (Javascript).
• 5 with answers 6 and 8 (R).
• 6 with answer 10 (Bash).
• 7 with answer 11 (Mathematica).
• 8 with answer 13 (Python).
• 9 with this answer (Perl).

The program checks input length and maps it to the current language distribution.

# 6. R (language 5), 61 bytes

cat(switch(substr(readline(),1,1),"{"=2,"'"=3,"s"=4,"c"=5,1))


Checks what is the first character of the input and choose output accordingly.

This thus prints:

• 1 with answers 1 and 5 (Retina).

• 2 with answer 2 (Brain-Flak).

• 3 with answer 3 (APL).

• 4 with answer 4 (Javascript).

• and 5 with this answer.

Usage:

> cat(switch(substr(readline(),1,1),"{"=2,"'"=3,"s"=4,"c"=5,1))

1
{<>(())(<>)}{}(<>{}())
2
' {'⍳⊃⍞
3
s=>s?s[0]=={?2:s[0]==s?4:3:1
4
^$|(?![⊂⍴])[⊂-⍴]|\B=|{} 1 > cat(switch(substr(readline(),1,1),"{"=2,"'"=3,"s"=4,"c"=5,1)) cat(switch(substr(readline(),1,1),"{"=2,"'"=3,"s"=4,"c"=5,1)) 5  • To run this outside of an REPL, see comment under answer 8. Jan 19, 2017 at 15:56 # 8. R (language 5), 76 bytes c=which(c("","{","'","s","c")==substr(readline(),1,1));ifelse(length(c),c,1)  Checks the first letter of the input, and compares it with a vector containing (in that order) the empty string, {, ', s and c. It then outputs the index of the match (R indexing is 1-based) or 1 if there is no match. Same concept as answer n°6 but prevents answer n°7 from matching it. This prints: • 1 with answers 1, 5 and 7 (Retina). • 2 with answer 2 (Brain-Flak). • 3 with answer 3 (APL). • 4 with answer 4 (Javascript). • and 5 with answer 6 and this answer (R). If I'm not mistaken, the byte-count allowance for this answer was 94 bytes. • FYI R online interpreters (rfiddle, ideone and tryitonline) seems to have problem handling stdin (at least with readline() ) and thus won't behave properly. If you want to try this (and the previous answer) you'll have to try locally on an installed version of R, i'm afraid. Jan 19, 2017 at 15:02 • ^ Ok, outside of a REPL readline should be replaced by readLines(file("stdin")). Which means 16 more characters: answer 6 should therefore be 77 bytes (out of 79 allowed) andthis answer 92 bytes (out of 94 allowed). With this change it works on online interpreters as well. Jan 19, 2017 at 15:53 # 12. Javascript (language 4), 117 bytes Note: I changed a character to correct a mistake in this one. c=>c?c[0]=='e'?6:c[0]=='$'||c[0]=='^'?1:c[0]=='c'&&c.length>80?4:c[0]=='P'?7:c[0]=='c'?5:c[0]=='{'?2:c[0]=='s'?4:3:1;


Checks the first letter of the input, if it's c, checks the length of the input.

Outputs:

• 1 for answers 1, 5, 7, 9
• 5 for answers 6, 8

# 13. Python (language 8), 110 bytes

Note: This answer was altered 6 hours after posting, at the recommendation of the OP.

from hashlib import*;print("1234151516748"["a5e1f936cd78b".index(sha256(input().encode()).hexdigest()[34])])#N


This is the same idea as answer 10 (in bash), but in Python 3. (This approach can work for at most 3 more entries before we run out of hex digits.)

This prints:

• 1 with answers 1, 5, 7, and 9 (Retina).

• 2 with answer 2 (Brain-Flak).

• 3 with answer 3 (APL).

• 4 with answers 4 and 12 (Javascript).

• 5 with answers 6 and 8 (R).

• 6 with answer 10 (Bash).

• 7 with answer 11 (Mathematica).

• 8 for this answer (Python).

• What is the current byte limit?
– Vi.
Jan 19, 2017 at 23:41
• @Vi.: Well, it WAS 149 for answer 13 and 163 for answer 14; but the OP just changed the byte count rules to 45+5n, so that it would be 110 bytes for answer 13 and 115 bytes for answer 14. Jan 19, 2017 at 23:56
• You should probably put the 110 byte solution up. Jan 20, 2017 at 5:26
• @Qwerp-Derp: All right. Hopefully that won't break anyone's ongoing work. Jan 20, 2017 at 5:43
• OK, waiting for about 60 answers until the byte limit it gets to Java-friendly land.
– Vi.
Jan 20, 2017 at 10:20

# 24. Zsh (language 11), 142 bytes

My previous answer #18 in C still works unmodified for all the subsequent entries (demo). So let's mix it up a little.

typeset -A p
p=("[$^]*|'\[*" 1 '{*' 2 "' *" 3 '?=>*' 4 'c?[wt]*' 5 'e*' 6 'P*' 7 'f*' 8 'w*' 9 'm*' 10 'ty*' 11) echo {p[(k)1]:-1} #@<w&X{  The purpose of the comment at the end is to match the length of answers 21 and 23, and ensure that no single character of the sha256 or sha384 hashes is unique for every answer so far, using the characters checked by Lyth's C++ answers. ;-) This prints: • 1 with answers 1, 5, 7, 9, and 14 (Retina). • 2 with answer 2 (Brain-Flak). • 3 with answer 3 (APL). • 4 with answers 4, 12, and 15 (Javascript). • 5 with answers 6 and 8 (R). • 6 with answers 10, 17, 20, and 22 (Bash). • 7 with answers 11 and 19 (Mathematica). • 8 with answer 13 (Python). • 9 with answer 16 (Perl). • 10 with answers 18, 21, and 23 (C/C++). • 11 with this answer (Zsh). Try it online! • I think this is the first answer to be multi-lined... +1 from me. Jan 25, 2017 at 1:12 ## 14. Retina (language 1), 39 bytes '[ ⍳]|}\{|[o@:][^]'c@:]|^c|,\b1|1\d|  Try it online! (Tests all valid inputs.) • Come on Martin, post in a different language... also, could you do the answer-formatting thing? Jan 20, 2017 at 9:38 • @Qwerp-Derp This is actually turning into an interesting variation on standard regex golf. Instead of having a set of inputs and having to match some of them and fail some others, here you have to get a specific number of matches on each of the inputs. I do wonder whether this regex will blow up exponentially at some point. Jan 20, 2017 at 9:40 • Is it really 39 bytes? TIO reports 37 bytes. Jan 21, 2017 at 13:32 • @Arnauld TIO is hardcoded to just count characters for Retina because you often use single-byte encodings. This answer requires UTF-8 though. Jan 21, 2017 at 13:34 # 15. Javascript (language 4), 108 bytes Golfed t=>({24:2,86:3,5:4,73:5,68:5,74:7,4:6,79:4,1:8,67:4})[[...t].reduce((r,c,i)=>r*i^c.charCodeAt(0),0)&0x5F]||1  # 17. Bash (+coreutils +openssl) (language 6), 103 bytes Golfed expr substr 69418476151514321 (expr index 2PtgBOlrvfDVC8ZHL openssl md5 -binary|base64|cut -c2) 1 #x  Uses the same technique as my answer #10, but with Base64 encoded dictionary, instead of Hex. I've put together the following data file for testing: 6 17 expr substr 69418476151514321 (expr index 2PtgBOlrvfDVC8ZHL openssl md5 -binary|base64|cut -c2) 1 #x 9 16 while(<>){print substr("1234151516748149",index("0F=POmS6D4e_XWVH",chr(47+length(_)%70)),1);} 4 15 t=>({24:2,86:3,5:4,73:5,68:5,74:7,4:6,79:4,1:8,67:4})[[...t].reduce((r,c,i)=>r*i^c.charCodeAt(0),0)&0x5F]||1 1 14 '[ ⍳]|}\{|[o@:][^]'c@:]|^c|,\b1|1\d| 8 13 from hashlib import*;print("1234151516748"["a5e1f936cd78b".index(sha256(input().encode()).hexdigest()[34])])#N 4 12 c=>c?c[0]=='e'?6:c[0]==''||c[0]=='^'?1:c[0]=='c'&&c.length>80?4:c[0]=='P'?7:c[0]=='c'?5:c[0]=='{'?2:c[0]=='s'?4:3:1; 7 11 Position[Characters@"^{'sceP",#&@@#][[1,1]]/._@__->1& 6 10 expr substr "1234151516" (expr index "365f8dc0eb" md5sum|cut -c12) 1 #G 1 09 |}\{|[:'][^]']|,\b1 5 08 c=which(c("","{","'","s","c")==substr(readline(),1,1));ifelse(length(c),c,1) 1 07 ^|(?![⊂⍴])[⊂-⍴]|\B=|{}|\b5 5 06 cat(switch(substr(readline(),1,1),"{"=2,"'"=3,"s"=4,"c"=5,1)) 1 05 ^|(?![⊂⍴])[⊂-⍴]|\B=|{} 4 04 s=>s?s[0]=={?2:s[0]==s?4:3:1 3 03 ' {'⍳⊃⍞ 2 02 {<>(())(<>)}{}(<>{}()) 1 01  Test for i in seq 17 do echo -n cat lchain|sed -n i'{p;q}'|cut -c1=\> cat lchain|sed -n i'{p;q}'|cut -c6-|\ expr substr 69418476151514321 (expr index 2PtgBOlrvfDVC8ZHL openssl md5 -binary|base64|cut -c2) 1 #x done 6=>6 9=>9 4=>4 1=>1 8=>8 4=>4 7=>7 6=>6 1=>1 5=>5 1=>1 5=>5 1=>1 4=>4 3=>3 2=>2 1=>1  # 19. Mathematica (language 7), 96 bytes Position[ToCharacterCode@StringSplit@";NRU Q B [1: =L J, 5% 3 # >",Mod[Length@#,59,33]][[1,1]]&  Unnamed function taking a list of characters as input and returning an integer: • 1 with answers 1, 5, 7, 9, and 14 (Retina). • 2 with answer 2 (Brain-Flak). • 3 with answer 3 (APL). • 4 with answers 4, 12, and 15 (Javascript). • 5 with answers 6 and 8 (R). • 6 with answers 10 and 17 (Bash). • 7 with answer 11 and this answer (Mathematica). • 8 with answer 13 (Python). • 9 with answer 16 (Perl). • 10 with answer 18 (C). So far all the lengths of answers are distinct, and they're even distinct modulo 59—hence can be detected by which integer in the range 33, 34, ..., 91 they're congruent to (mod 59). These are all printable ASCII characters, encoded by the string ";NRU Q B [1: =L J, 5% 3 # >"; using ToCharacterCode@StringSplit@ turns this string into a list of ten lists of integers in that range, and Position[...,Mod[Length@#,59,33]][[1,1]] finds which of the ten sublists matches the modified length of the input. # 20. Bash (+coreutils +openssl) (language 6), 121 byte Golfed expr substr 67A69418476151514321 (expr index 7042PtgBOlrvfDVC8ZHL openssl md5 -binary|base64|cut -c2) 1| dc -e16i?p #u  The same method as my answer #17 (which in turn is based on my original answer #10). As we have 10 distinct languages now, I've switched to hexadecimal position encoding. Data 6 20 expr substr 67A69418476151514321 (expr index 7042PtgBOlrvfDVC8ZHL openssl md5 -binary|base64|cut -c2) 1| dc -e16i?p #u 7 19 Position[ToCharacterCode@StringSplit@";NRU Q B [1: =L J, 5% 3 # >",Mod[Length@#,59,33]][[1,1]]& A 18 main(n){char*v=" ^{ s ePfwm",b[999],*c;gets(b);c=strchr(v,*b);n=strlen(b);printf("%d",n?c?c-v:n>99?4:n>60?5:n>15?1:3:1);} 6 17 expr substr 69418476151514321 (expr index 2PtgBOlrvfDVC8ZHL openssl md5 -binary|base64|cut -c2) 1 #x 9 16 while(<>){print substr("1234151516748149",index("0F=POmS6D4e_XWVH",chr(47+length(_)%70)),1);} 4 15 t=>({24:2,86:3,5:4,73:5,68:5,74:7,4:6,79:4,1:8,67:4})[[...t].reduce((r,c,i)=>r*i^c.charCodeAt(0),0)&0x5F]||1 1 14 '[ ⍳]|}\{|[o@:][^]'c@:]|^c|,\b1|1\d| 8 13 from hashlib import*;print("1234151516748"["a5e1f936cd78b".index(sha256(input().encode()).hexdigest()[34])])#N 4 12 c=>c?c[0]=='e'?6:c[0]==''||c[0]=='^'?1:c[0]=='c'&&c.length>80?4:c[0]=='P'?7:c[0]=='c'?5:c[0]=='{'?2:c[0]=='s'?4:3:1; 7 11 Position[Characters@"^{'sceP",#&@@#][[1,1]]/._@__->1& 6 10 expr substr "1234151516" (expr index "365f8dc0eb" md5sum|cut -c12) 1 #G 1 09 |}\{|[:'][^]']|,\b1 5 08 c=which(c("","{","'","s","c")==substr(readline(),1,1));ifelse(length(c),c,1) 1 07 ^|(?![⊂⍴])[⊂-⍴]|\B=|{}|\b5 5 06 cat(switch(substr(readline(),1,1),"{"=2,"'"=3,"s"=4,"c"=5,1)) 1 05 ^|(?![⊂⍴])[⊂-⍴]|\B=|{} 4 04 s=>s?s[0]=={?2:s[0]==s?4:3:1 3 03 ' {'⍳⊃⍞ 2 02 {<>(())(<>)}{}(<>{}()) 1 01  Test (output) ./test 6=>6 7=>7 A=>10 6=>6 9=>9 4=>4 1=>1 8=>8 4=>4 7=>7 6=>6 1=>1 5=>5 1=>1 5=>5 1=>1 4=>4 3=>3 2=>2  # 23. C (gcc) (language 10), 142 bytes main(c){int d[256]={0};while((c=getchar())!=EOF)d[c]++;printf("%d",d[88]?9:d[119]?5*d[123]:d[35]?d[38]?7:8-d[96]:d[48]?4:d[60]?2:1+d[158]*2);}  Try it online! • 1 with answers 1, 5, 7, 9, and 14 (Retina). • 2 with answer 2 (Brain-Flak). • 3 with answer 3 (APL). • 4 with answers 4, 12, and 15 (Javascript). • 5 with answers 6 and 8 (R). • 6 with answers 10, 17, 20 and 22 (Bash). • 7 with answer 11 and 19 (Mathematica). • 8 with answer 13 (Python). • 9 with answer 16 (Perl). • 10 with answer 18, 21 and this answer (C). This program counts number of different characters (in ASCII, so multi-byte UTF-8 characters get split into several entries) and then follows a carefully designed decision tree, basing on the number of occurrences of this or that character. The decision tree is unchanged from #21 (yay!). I'm not allowed to post exactly same code, so we're back to pure C with minor modifications. # 21. C++ (gcc) (language 10 as a variant of C), 142 bytes main(){int K,d[256]{0};while((K=getchar())!=EOF)d[K]++;printf("%d",d[88]?9:d[119]?5*d[123]:d[35]?d[38]?7:8-d[96]:d[48]?4:d[60]?2:1+d[158]*2);}  Try it online! • 1 with answers 1, 5, 7, 9, and 14 (Retina). • 2 with answer 2 (Brain-Flak). • 3 with answer 3 (APL). • 4 with answers 4, 12, and 15 (Javascript). • 5 with answers 6 and 8 (R). • 6 with answers 10, 17 and 20 (Bash). • 7 with answer 11 and 19 (Mathematica). • 8 with answer 13 (Python). • 9 with answer 16 (Perl). • 10 with answer 18 and this answer (C). This program counts number of different characters (in ASCII, so multi-byte UTF-8 characters get split into several entries) and then follows a carefully designed decision tree, basing on the number of occurrences of this or that character. Trivia: letter K was not used until this entry. Letters I, E, Y, j, k, q, z remain unused. • There is an option to consider C++ language 11, a few bytes are left to fit that in. – Lyth Jan 23, 2017 at 19:25 # 22. Bash (+coreutils) [language 6], 123, 131 bytes EDIT: Published a wrong version at first, should be fixed now. Golfed expr substr 6A67A69418476151514321 (expr index i3xFepQsAalyIvtqPY7ZN+ \\openssl sha256 -binary|base64|cut -c10) 1| dc -e16i?p #L  The same technique as my answers #20, #17 and #10. Data 6 22 expr substr 6A67A69418476151514321 (expr index i3xFepQsAalyIvtqPY7ZN+ \\openssl sha256 -binary|base64|cut -c10) 1| dc -e16i?p #L A 21 main(){int K,d[256]{0};while((K=getchar())!=EOF)d[K]++;printf("%d",d[88]?9:d[119]?5*d[123]:d[35]?d[38]?7:8-d[96]:d[48]?4:d[60]?2:1+d[158]*2);} 6 20 expr substr 67A69418476151514321 (expr index 7042PtgBOlrvfDVC8ZHL openssl md5 -binary|base64|cut -c2) 1| dc -e16i?p #u 7 19 Position[ToCharacterCode@StringSplit@";NRU Q B [1: =L J, 5% 3 # >",Mod[Length@#,59,33]][[1,1]]& A 18 main(n){char*v=" ^{ s ePfwm",b[999],*c;gets(b);c=strchr(v,*b);n=strlen(b);printf("%d",n?c?c-v:n>99?4:n>60?5:n>15?1:3:1);} 6 17 expr substr 69418476151514321 (expr index 2PtgBOlrvfDVC8ZHL openssl md5 -binary|base64|cut -c2) 1 #x 9 16 while(<>){print substr("1234151516748149",index("0F=POmS6D4e_XWVH",chr(47+length(_)%70)),1);} 4 15 t=>({24:2,86:3,5:4,73:5,68:5,74:7,4:6,79:4,1:8,67:4})[[...t].reduce((r,c,i)=>r*i^c.charCodeAt(0),0)&0x5F]||1 1 14 '[ ⍳]|}\{|[o@:][^]'c@:]|^c|,\b1|1\d| 8 13 from hashlib import*;print("1234151516748"["a5e1f936cd78b".index(sha256(input().encode()).hexdigest()[34])])#N 4 12 c=>c?c[0]=='e'?6:c[0]==''||c[0]=='^'?1:c[0]=='c'&&c.length>80?4:c[0]=='P'?7:c[0]=='c'?5:c[0]=='{'?2:c[0]=='s'?4:3:1; 7 11 Position[Characters@"^{'sceP",#&@@#][[1,1]]/._@__->1& 6 10 expr substr "1234151516" (expr index "365f8dc0eb" md5sum|cut -c12) 1 #G 1 09 |}\{|[:'][^]']|,\b1 5 08 c=which(c("","{","'","s","c")==substr(readline(),1,1));ifelse(length(c),c,1) 1 07 ^|(?![⊂⍴])[⊂-⍴]|\B=|{}|\b5 5 06 cat(switch(substr(readline(),1,1),"{"=2,"'"=3,"s"=4,"c"=5,1)) 1 05 ^|(?![⊂⍴])[⊂-⍴]|\B=|{} 4 04 s=>s?s[0]=={?2:s[0]==s?4:3:1 3 03 ' {'⍳⊃⍞ 2 02 {<>(())(<>)}{}(<>{}()) 1 01  Test Run ./test 6=>6 A=>10 6=>6 7=>7 A=>10 6=>6 9=>9 4=>4 1=>1 8=>8 4=>4 7=>7 6=>6 1=>1 5=>5 1=>1 5=>5 1=>1 4=>4 3=>3 2=>2 1=>1  • What's the 44? Jan 24, 2017 at 0:29 • 22*2?󠀠󠀠󠀠󠀠󠀠 – Vi. Jan 24, 2017 at 1:01 • @Qwerp-Derp, just a typo Jan 24, 2017 at 8:06 • Come on, your answers are getting boring now - if your next answer is like this, I'm considering downvoting (it's not interesting, y'know?) Jan 24, 2017 at 8:20 • Something is wrong here. There are only 20 entries in your hashed letters (3PgT etc.). For empty input I get an error, and for answer #2 I get "4" (both worked correctly with answer 20.) Jan 24, 2017 at 18:56 # 25. Bash (language 6), 169 bytes The same technique as my answers #22, #20, #17 and #10. Sorry @Qwerp-Derp ! ;) I promise this is the last one :) Golfed { echo -n 'addsomesalt?';cat; }|expr substr 6BA6A67A69418476151514321 (expr index 1W0TC4YrKwRGAJupDqn7Xlcog \\openssl sha256 -binary|base64|cut -c40) 1| dc -e16i?p #8  Data Note that newlines are encoded as \n for answer #24 6 25 { echo -n 'addsomesalt?';cat; }|expr substr 6BA6A67A69418476151514321 (expr index 1W0TC4YrKwRGAJupDqn7Xlcog \\openssl sha256 -binary|base64|cut -c40) 1| dc -e16i?p #8 B 24 typeset -A p\np=("[$^]*|'\[*" 1 '{*' 2 "' *" 3 '?=>*' 4 'c?[wt]*' 5 'e*' 6 'P*' 7 'f*' 8 'w*' 9 'm*' 10 'ty*' 11)\necho ${p[(k)$1]:-1} #@<w&X{
A 23 main(c){int d[256]={0};while((c=getchar())!=EOF)d[c]++;printf("%d",d[88]?9:d[119]?5*d[123]:d[35]?d[38]?7:8-d[96]:d[48]?4:d[60]?2:1+d[158]*2);}
6 22 expr substr 6A67A69418476151514321 $(expr index i3xFepQsAalyIvtqPY7ZN+ \\openssl sha256 -binary|base64|cut -c10) 1| dc -e16i?p #L A 21 main(){int K,d[256]{0};while((K=getchar())!=EOF)d[K]++;printf("%d",d[88]?9:d[119]?5*d[123]:d[35]?d[38]?7:8-d[96]:d[48]?4:d[60]?2:1+d[158]*2);} 6 20 expr substr 67A69418476151514321$(expr index 7042PtgBOlrvfDVC8ZHL openssl md5 -binary|base64|cut -c2) 1| dc -e16i?p #u
7 19 Position[ToCharacterCode@StringSplit@";NRU$Q B [1: =L J, 5% 3 # >",Mod[Length@#,59,33]][[1,1]]& A 18 main(n){char*v=" ^{ s ePfwm",b[999],*c;gets(b);c=strchr(v,*b);n=strlen(b);printf("%d",n?c?c-v:n>99?4:n>60?5:n>15?1:3:1);} 6 17 expr substr 69418476151514321$(expr index 2PtgBOlrvfDVC8ZHL openssl md5 -binary|base64|cut -c2) 1 #x
9 16 while(<>){print substr("1234151516748149",index("0F=POmS6D4e_XWVH",chr(47+length($_)%70)),1);} 4 15 t=>({24:2,86:3,5:4,73:5,68:5,74:7,4:6,79:4,1:8,67:4})[[...t].reduce((r,c,i)=>r*i^c.charCodeAt(0),0)&0x5F]||1 1 14 '[ ⍳]|}\{|[o@:][^]'c@:]|^c|,\b1|1\d|$
8 13 from hashlib import*;print("1234151516748"["a5e1f936cd78b".index(sha256(input().encode()).hexdigest()[34])])#N
4 12 c=>c?c[0]=='e'?6:c[0]=='$'||c[0]=='^'?1:c[0]=='c'&&c.length>80?4:c[0]=='P'?7:c[0]=='c'?5:c[0]=='{'?2:c[0]=='s'?4:3:1; 7 11 Position[Characters@"^{'sceP",#&@@#][[1,1]]/._@__->1& 6 10 expr substr "1234151516"$(expr index "365f8dc0eb" md5sum|cut -c12) 1 #G
1 09 $|}\{|[:'][^]']|,\b1 5 08 c=which(c("","{","'","s","c")==substr(readline(),1,1));ifelse(length(c),c,1) 1 07 ^$|(?![⊂⍴])[⊂-⍴]|\B=|{}|\b5
1 05 ^\$|(?![⊂⍴])[⊂-⍴]|\B=|{}
4 04 s=>s?s[0]=={?2:s[0]==s?4:3:1
3 03 ' {'⍳⊃⍞
2 02 {<>(())(<>)}{}(<>{}())
1 01


Test Output

6=>6
B=>11
A=>10
6=>6
A=>10
6=>6
7=>7
A=>10
6=>6
9=>9
4=>4
1=>1
8=>8
4=>4
7=>7
6=>6
1=>1
5=>5
1=>1
5=>5
1=>1
4=>4
3=>3
2=>2
1=>1