# Which answer did this user write?

EDIT (Jan 19, 2022, 18:00 UTC): This challenge is now over. The winner is Citty with this Pyth answer. Congratulations!

This is an challenge where each answer must take an integer $$\N\$$ as input and return the 1-indexed ID of the answer which was written by the user whose ID is $$\N\$$.

You may want to sort by oldest to get the answers in the logical order.

## Rules

1. I will post the first answer.
2. You are only allowed to post one answer, so that a user ID is linked to one and only one answer ID.
3. You are only supposed to support user IDs that were used in the previous answers and your own user ID. (So your code may return anything or crash when given an unknown user ID.)
4. The maximum code size is set to 50 bytes. So the challenge will end when nobody is able to add a new ID without exceeding this size.
5. You may use any language, no matter which ones were used before. It is recommended to use verbose languages early in the chain, while they still have a chance to compete.
6. The last valid answer in the chain on January 19, 2022 at 18:00 UTC wins the challenge.

[your_user_ID] -> [your_answer_ID]


## Examples

The first answer is written by user Arnauld (58563):

### 1. JavaScript (ES6), 4 bytes

_=>1


Try it online!

Updated list:

58563 -> 1


This code returns 1 when given 58563 (my user ID) ... or any other input. That's fine because 1 is the only possible output at this point (see rule #3).

The second answer is written by user JohnDoe (123456) (who actually doesn't exist yet):

### 2. Python 2, 14 bytes

lambda n:2-n%2


Try it online!

Updated list:

58563 -> 1
123456 -> 2


This code returns 1 when given 58563 or 2 when given 123456.

• Sandbox Jan 19, 2021 at 16:18

# 7. Julia, 17 bytes

works due to Int64 overflowing to negative numbers

x->(x-8479)^6%5+5


Try it online!

Updated list:

58563 -> 1
80214 -> 2
95792 -> 3
89930 -> 4
86147 -> 5
97857 -> 6
98541 -> 7


I found those numbers by guessing and brute-forcing :

for i in Iterators.product(-9999:9999,1:20,1:20)
d = diff(((L.+i[1]) .^ i[3]) .% i[2])
if all(==(-1), d) || all(==(1),d)
println(i)
println(((L.+i[1]) .^ i[3]) .% i[2])
break
end
end


Try it online!

• How did you come up with this? Can you show your approach? Jan 20, 2021 at 7:22

# 2. Ruby, 11 bytes

->x{1+~x%2}


Try it online!

Updated list:

58563 -> 1
80214 -> 2

• Was ->x{2-x%2} too much like the example for you?
– Neil
Jan 23, 2021 at 1:08
• You read my mind. Jan 23, 2021 at 3:29

# 1. JavaScript (ES6), 4 bytes

_=>1


Try it online!

Updated list:

58563 -> 1


# 6. Zsh, 26 25 bytes

a=80596
<<<$a[(i)${1[2]}]


Try it online!

Boring.

-1 by @GammaFunction

Updated list:

58563 -> 1
80214 -> 2
95792 -> 3
89930 -> 4
86147 -> 5
97857 -> 6


# 8. J, 46 bytes

Last time this works, here to grab the boring answer!

1+58563 80214 95792 89930 86147 97857 98541&i.


95594 doesn't need to be included as J's index-of-operator i. returns the length of the array in the case the item was not found. But as it is 0-based, the index gets incremented 1+.

Try it online!

Update list:

58563 -> 1
80214 -> 2
95792 -> 3
89930 -> 4
86147 -> 5
97857 -> 6
98541 -> 7
95594 -> 8

• Since the last two digits are unique, could you just use those?
– user
Jan 19, 2021 at 19:14
• @user Sure, but then this wouldn't be the last most boring answer! :-) From now on answers will probably have more operations than mine because of the byte limit.
– xash
Jan 19, 2021 at 19:31
• – user
Jan 19, 2021 at 22:18

# 9. Perl 5-p, 46, 37 bytes

$_=(a74a298635=~/./g)[$_%26%20%12]||1


Try it online!

Updated list:

58563 -> 1
80214 -> 2
95792 -> 3
89930 -> 4
86147 -> 5
97857 -> 6
98541 -> 7
95594 -> 8
70745 -> 9


Explanation:

$_=$_%26%20%12 gives
58563 -> 11
80214 -> 4
95792 -> 8
89930 -> 2
86147 -> 9
97857 -> 7
98541 -> 1
95594 -> 6
70745 -> 5
(a74a298635=~/./g) because shorter than (a,7,4,a,2,9,8,6,3,5)

• @MarcMush, golfed, i will try to add an explanation Jan 19, 2021 at 20:59

# 13. Python 3, 45 bytes

lambda n:ord('ehlkacfbdgimj'[n%209%80%13])-96


Try it online!

Updated list:

58563 -> 1
80214 -> 2
95792 -> 3
89930 -> 4
86147 -> 5
97857 -> 6
98541 -> 7
95594 -> 8
70745 -> 9
45613 -> 10
94066 -> 11
44718 -> 12
9481 -> 13

• Replace the string literal by a bytes literal to remove the ord Jan 20, 2021 at 13:57
• @mic_e Nice idea but this isn't code golf, just have to weigh in at 50 bytes or less. Jan 20, 2021 at 15:00
• Your shorter ID makes it less straight-forward for some approaches. :) Jan 20, 2021 at 15:14
• @KevinCruijssen Yeah, this competition reminds me just how long ago I joined SO! :D Jan 20, 2021 at 15:18

# 15. 05AB1E, 42 bytes

This is based on the Chinese remainder theorem. Since all divisors need to be pairwise coprime, we use the nth prime for each user id n.

•3hy₁Ω=”Ó6™≠ò“êS’>₄?Θ¢9?Âγ”J4 %œ~ª‰fÃα•IØ%


Try it online!

•3hy...fÃα• is the large compressed integer 1369130535064223821413376960561972089702936948491908270885271972462351716275011314738309.
I pushes the input, Ø takes the n-th prime and % takes the large compressed integer modulo the prime number.

The big constant is generated with the ChineseRemainder builtin from the Wolfram Language: Try it online!

Updated list:

58563 -> 1
80214 -> 2
95792 -> 3
89930 -> 4
86147 -> 5
97857 -> 6
98541 -> 7
95594 -> 8
70745 -> 9
45613 -> 10
94066 -> 11
44718 -> 12
9481 -> 13
78123 -> 14
64121 -> 15


By using the closest prime to n/349 instead of the nth prime this can be golfed to 24 bytes:

•1RMζ)šÙ&KxγŸÏäí•IƵù/Ån%


Try it online!

•1R...äí•         # compressed integer 5437583563235532232480395276083021
I        # push the input
Ƶù/     # divide by 349
Ån   # find the nearest prime
%  # modulo the large integer with the prime


# 20. Charcoal, 30 bytes

Ｉ⁺²⌕⪪”)¶q⁹1＆¡⍘DλＫ⟦l∧NＨz¿”²…⮌Ｓ²


Try it online! Link is to verbose version of code. Works by taking the last two digits of the user ID and looking it up in a table generated by splitting a compressed string into pairs of characters. (Taking the first two digits doesn't work because there are several repeats.) A few variants are possible by spending an extra byte or two on the table which are offset by the saving from not having to offset the resulting index. Unfortunately there are overlaps between adjacent user IDs which means that the string has to be split into pairs of characters to find the index accurately, although one byte of this is offset by not having to halve the resulting index. Updated list:

58563 -> 1
80214 -> 2
95792 -> 3
89930 -> 4
86147 -> 5
97857 -> 6
98541 -> 7
95594 -> 8
70745 -> 9
45613 -> 10
94066 -> 11
44718 -> 12
9481 -> 13
78123 -> 14
64121 -> 15
41565 -> 16
52210 -> 17
91569 -> 18
3852 -> 19
17602 -> 20


# 3. APL (Dyalog Unicode), 7 bytes

4|∘⍎3⊃⍕


Try it online!

Updated list:

58563 -> 1
80214 -> 2
95792 -> 3


Explanation:

4|∘⍎3⊃⍕
⍕  ⍝ Convert to string
3⊃   ⍝ Pick the third digit (5, 2, or 7)
⍎      ⍝ Execute (make the digit a number again)
4|        ⍝ Mod 4


# 12. C (gcc), 50 bytes

int f(int n){return"DJHABILFCGKE"[n%60%50%12]-64;}


Try it online!

This code could be golfable. But this question is not taged . So let's leave it warning free.

58563 -> 1
80214 -> 2
95792 -> 3
89930 -> 4
86147 -> 5
97857 -> 6
98541 -> 7
95594 -> 8
70745 -> 9
45613 -> 10
94066 -> 11
44718 -> 12


# 21. Pyth, 49 50 bytes

(answer ID & 753) % 38 happens to be unique for every answer so I just use that to make a lookup table.

C@" \r	
         "%.&753Q38


The string in python repr format: ' \r\x14\x01\x02\t\x04\x06 \n \x05\x0b\x0f\x13 \x08 \x10 \x12\x0c \x03 \x11 \x0e \x07'

Updated list:

58563 -> 1
80214 -> 2
95792 -> 3
89930 -> 4
86147 -> 5
97857 -> 6
98541 -> 7
95594 -> 8
70745 -> 9
45613 -> 10
94066 -> 11
44718 -> 12
9481 -> 13
78123 -> 14
64121 -> 15
41565 -> 16
52210 -> 17
91569 -> 18
3852 -> 19
17602 -> 20
75429 -> 21


+1 byte because Python doesn't like carriage returns on their own apparently

Try it online!

• @Arnauld Let me double check, I copy pasted it in to TIO from a school laptop and who knows what it did Apr 9, 2021 at 13:03
• Fixed it, the carriage return was being translated to a newline Apr 9, 2021 at 13:11

# 17. MathGolf, 41 40 bytes

☼+░╞╪2<W48R0879H4957V6984♂Y☻5405]y2/├=)


Try it online.

Updated list:

58563 -> 1
80214 -> 2
95792 -> 3
89930 -> 4
86147 -> 5
97857 -> 6
98541 -> 7
95594 -> 8
70745 -> 9
45613 -> 10
94066 -> 11
44718 -> 12
9481 -> 13
78123 -> 14
64121 -> 15
41565 -> 16
52210 -> 17


Explanation:

☼+           # Add 100000 to the (implicit) input-integer
░          # Convert it to a string
╞         # Remove the first digit (the 1)
# (the ☼+░╞ is used to convert the input 9481 to "09481",
#  and at the same time convert any other input-integer to a string)
╪            # Rotate it once towards the right
2<          # Leave only the first two characters
W48R0879H4957V6984♂Y☻5405
# Push the following integers to the stack
# (where  duplicates the top two items, thus 8,7):
#  35,4,8,29,0,8,7,8,7,9,19,4,9,5,7,34,6,9,8,4,10,37,16,5,4,0,5
]y       # Wrap the stack in a list, and join it together
2/     # Split it into parts of size 2
├    # Pop the left item from the list, and push it to the stack
# (which is the value we calculated at first)
=   # Get its 0-based index in the list
)  # And increase it by 1 to make it a 1-based index
# (after which the entire stack is output implicitly as result)


# 4. C# (.NET Core), 16 bytes

n=>2-n%2+n%100%7


Try it online!

58563 -> 1
80214 -> 2
95792 -> 3
89930 -> 4


Lucky coincidence that

• All IDs except the first are even

• Last 2 digits of the first 2 IDs are divisible by 7

• Last 2 digits of the second 2 IDs are 1 and 2 mod 7 respectively

• @user Thanks for the tip. This isn't a code golf question so I didn't really care about the code length but I'll amend it. Jan 19, 2021 at 16:51
– user
Jan 19, 2021 at 16:52
• You're right of course, I meant that there wasn't a scoring criterion with length of code as the score. Jan 19, 2021 at 16:53

<<<$[$1&7?(4+${1:4})%6:3]  Try it online! (4 +${1:4}) % 6 works for every ID but 95792. But, 95792 is the only ID divisible by 8, so a ternary with $1 % 8 as the condition works. 58563 -> 3 ? (4 + 3) % 6 : 3 -> 7 % 6 -> 1 80214 -> 6 ? (4 + 4) % 6 : 3 -> 8 % 6 -> 2 95792 -> 0 ? (4 + 2) % 6 : 3 -> 3 89930 -> 2 ? (4 + 0) % 6 : 3 -> 4 % 6 -> 4 86147 -> 3 ? (4 + 7) % 6 : 3 -> 11 % 6 -> 5  The more boring 24 byte answer, based off of @pxeger's a=8059 <<<$a[(i)${1[2]}]  • I'm sorry my ID fails your shorter function :( – user Jan 19, 2021 at 17:31 • @user You're just a special case :P Jan 19, 2021 at 17:33 # 18. 05AB1E, 45 bytes •1ααāš®‚wA%|ʒη¦%áYζ”€…FKΘćRÉ±nG’*AÂÉζ•5ôíÌskÌ  Try it online! 58563 -> 1 80214 -> 2 95792 -> 3 89930 -> 4 86147 -> 5 97857 -> 6 98541 -> 7 95594 -> 8 70745 -> 9 45613 -> 10 94066 -> 11 44718 -> 12 9481 -> 13 78123 -> 14 64121 -> 15 41565 -> 16 52210 -> 17 91569 -> 18  The compressed number is each user ID minus 2, reversed, and joined together (except 9481 which is changed into 97490, and 58563 which is not included). 5ô splits it, εR} reverses it, sk returns the index of the input in the list, and Ì adds 2. • Input 9481 is currently incorrectly resulting in 1 instead of 13. EDIT: I think this is supposed to be the compressed integer? Jan 20, 2021 at 14:55 • @KevinCruijssen Thanks, updated answer. EDIT: I didn't double-check the compressed integer, I thought it was an issue because it was 09481 instead of 9481 Jan 20, 2021 at 14:59 • Here a test suite to make it easier to test/verify your program works, which right now is unfortunately not the case. The edit I proposed earlier does works, though. (And without the reverse-each it's even shorter, although the byte-count doesn't matter in this challenge, as long as it's $\leq50$.) Jan 20, 2021 at 15:10 • I put my new program into the test suite and it looks like it has the correct results. Jan 20, 2021 at 15:19 • just for fun : "verbose" languages can still barely be used Jan 21, 2021 at 9:39 # 14. Stax, 48 bytes "&,R>&N_QbmO.%:VUVh5m@x~|LVju(bWJij<$"%98542|EI^


Run and debug it

You thought the time for trivial solutions was over? Fool!

Well, maybe not entirely trivial. But the nontrivial part was generated by Stax's array literal generator. The only thing I added is the I^, which means "find the index of the input number in the array and increment it".

The code could be packed, but this is not .

Updated list:

58563 -> 1
80214 -> 2
95792 -> 3
89930 -> 4
86147 -> 5
97857 -> 6
98541 -> 7
95594 -> 8
70745 -> 9
45613 -> 10
94066 -> 11
44718 -> 12
9481 -> 13
78123 -> 14


# 16. C# (.NET Core), 47 bytes

Not creative... just a basic mapping. Constants came from experimentation

x=>" +$Q2('%OINFA;4@0".IndexOf((char)(x%49+35))  Try it online! Updated list: 58563 -> 1 80214 -> 2 95792 -> 3 89930 -> 4 86147 -> 5 97857 -> 6 98541 -> 7 95594 -> 8 70745 -> 9 45613 -> 10 94066 -> 11 44718 -> 12 9481 -> 13 78123 -> 14 64121 -> 15 41565 -> 16  • The average minimal modulo $m$ to have this working for 16 distinct random numbers in $[10000...100000]$ seems to be close to $51$. So the odds are slightly in our (your) favor so far. :-) Jan 20, 2021 at 11:32 # 10. Python 3, 44 bytes lambda x:'973.84.612..5a'[int(x[0]+x[4])%15]  Try it online! Input is taken as a decimal string and returned as a hexadecimal string Updated list: 58563 -> 1 80214 -> 2 95792 -> 3 89930 -> 4 86147 -> 5 97857 -> 6 98541 -> 7 95594 -> 8 70745 -> 9 45613 -> 10 (displayed as a in this case)  ## Explanation Takes the first and last digits, mod 15 and indexes into a string lookup table. This approach won't work for too much longer, but could probably be stretched to 20 or so in a language with more flexible string->int conversion, like Javascript, PHP, or Perl. # 11. 05AB1E, 30 bytes •γ¤š×Pγ…þiðþ– çô&)½c©2è•5ôsk>  Try it online! Updated list: 58563 -> 1 80214 -> 2 95792 -> 3 89930 -> 4 86147 -> 5 97857 -> 6 98541 -> 7 95594 -> 8 70745 -> 9 45613 -> 10 94066 -> 11  •...•5ôsk> # trimmed program k # get 0... > # plus 1... k # -based index of... s # implicit input... k # in... •...• # 5856380214957928993086147978579854195594707454561394066... ô # split in pieces of... 5 # literal # implicit output  # 19. Befunge-93, 45 bytes "0$>K"&\%\%\%\%1g\-.@
/1C274=B8?A5>:/@;3</96


Try it online!

Updated list:

58563 -> 1
80214 -> 2
95792 -> 3
89930 -> 4
86147 -> 5
97857 -> 6
98541 -> 7
95594 -> 8
70745 -> 9
45613 -> 10
94066 -> 11
44718 -> 12
9481 -> 13
78123 -> 14
64121 -> 15
41565 -> 16
52210 -> 17
91569 -> 18
3852 -> 19


There's a raw low-ASCII byte (decimal 25) between the 0 and the \$.

This computes str[input%75%62%36%25] - '0', where str is the string on the second line of the program.

• Lowest user ID so far! ;) Jan 22, 2021 at 19:16