text:
Quandle Quandary Episode I: Identifying Finite Quandles
Write a program that will determine if a given matrix represents a quandle.  A quandle is a set equipped with a single (non-commutative, non-associative) operation \$◃\$ which obeys the following axioms:

The operation is closed, meaning that \$a◃b = c\$ is always an element of the set if \$a\$ and \$b\$ are elements of the set.
The operation is right-self-distributive: \$(a◃b)◃c = (a◃c)◃(b◃c)\$.
The operation is right-divisible:  For any chosen pair of \$a\$ and \$b\$, there is a single unique \$c\$ such that \$c◃a = b\$
The operation is idempotent: \$a◃a = a\$

A finite quandle can be represented as a square matrix.  Below is an example of an order-\$5\$ quandle (source).
0 0 1 1 1
1 1 0 0 0
3 4 2 4 3
4 2 4 3 2
2 3 3 2 4

The value located at the \$n\$-th row and \$m\$-th column (0-indexed) is the value of \$n◃m\$. For example, in this quandle, \$4◃1 = 3\$.  Some of the quandle properties are easy to see from this matrix:

It is closed because only values \$0-4\$ appear in this \$5\times5\$ matrix.
It is idempotent because the matrix diagonal is \$0, 1, 2, 3, 4\$
It is right-divisible because no column contains any duplicate values. (The rows can, and usually will.)

The property of right-self-distributivity is harder to test.  There might be a shortcut, but the simplest method is to iterate over each possible combination of three indexes to verify that m[m[a][b]][c] = m[m[a][c]][m[b][c]].
Input
Input will be the list of rows of a square matrix, using either 0-indexing or 1-index (your choice).  Each entry will be a single digit number from 0 to 8 (or 1 through 9).  I will be flexible on the input format.  Some acceptable formats include:

Your language's most natural formatting for matrices or lists, such as [[0 0 0][2 1 1][1 2 2]] or (0,0,0,2,1,1,1,2,2).
The list of values delimited by whitespace, newlines, commas, etc.
A single string consisting of all values concatenated together, such as 000211122.

You are also allowed to take the transpose of the matrix as input (swapping rows with columns).  Just be sure to state this in your answer.
Output
A single truthy/falsey value indicating the matrix's status as a quandle.
Examples of quandles
0

0 0
1 1

0 0 0
2 1 1
1 2 2

0 0 1 1
1 1 0 0
3 3 2 2
2 2 3 3

0 3 4 1 2
2 1 0 4 3
3 4 2 0 1
4 2 1 3 0
1 0 3 2 4

Examples of non-quandles
not closed
1

0 0 0
2 1 1
1 9 2

not right-self-distributive
0 0 1 0
1 1 0 1
2 3 2 2
3 2 3 3

(3◃1)◃2 = 2◃2 = 2
(3◃2)◃(1◃2) = 3◃0 = 3

not right-divisible
0 2 3 4 1
0 1 2 3 4
3 4 2 2 2
3 3 3 3 3
4 1 1 1 4

0 1 2 3
3 1 2 0
3 1 2 3
0 1 2 3

not idempotent
1 1 1 1
3 3 3 3
2 2 2 2
0 0 0 0

2 1 0 4 3
3 4 2 0 1
4 2 1 3 0
1 0 3 2 4
0 3 4 1 2

The word "matrix" is misleading, because this is nothing to do with linear algebra. "Table" would be better (or maybe "Cayley table", but I think that strictly that's only appropriate for a group).

Haskell, 100 bytes
This answer uses transposed input.
q m=and$(elem<$>v<*>m)++[a#a==a&&a#b#c==a#c#(b#c)|a<-v,b<-v,c<-v]where v=[0..length m-1];i#j=m!!j!!i

Seems like I can't use a pattern guard to bind an infix operator, so I'm using where in this case.
(First version was 108 bytes but missed idempotency test, fixed version was 120 bytes, later versions had 108, 103 and 98 bytes but I had to realize thanks to @nimi that they were all wrong: of course I need to do the right-divisibility test (which implies closedness) before doing any dangerous !! operations,  but I could still use most of my later golfing ideas and with one more, it was 102 bytes, now improved by changing the operand order of # (which is nicer anyway to compensate the transposition) to make better use of its associating to the left)
Use like this:
*Main> q [[0,1,2,3],[0,1,3,2],[1,0,2,3],[0,1,2,3]]
False

Python 2, 104 103 102 bytes
t=input();e=enumerate
[0%(a==A[a]in B>C[B[a]]==t[C[b]][C[a]])for(a,A)in e(t)for(b,B)in e(t)for C in t]

Input is transposed. Output is via exit code, so 0 (success) is truthy and 1 (failure) is falsy.
Try it online!
How it works
e(t) returns the enumerated rows of the input matrix t – which represents an operator ◃ – as (index,row) pairs. for(a,A)in e(t), e.g., iterates over these, storing the index in a and the row itself in A, so A becomes a shortcut for t[a].
Between the former, for(b,B)in e(t), and for C in t, we iterate over all possible ordered tuples (a, b, c) in the Cartesian power t3.
For each of these tuples, we evaluate the expression
0%(a==A[a]in B>C[B[a]]==t[C[b]][C[a]])

The value of the parenthesized Boolean is False if and only if one or more of the following individual comparisons do the same.

a==A[a] will fail (for some value of a) iff ◃ is not idempotent.
A[a]in B will fail if B doesn't contain all indices of A.
Since A has n indices and B has n elements, non-failure means that the elements of B match the indices of A, so ◃ is closed and right-divisible.
B>C[B[a]] is a tautology, since Python 2 considered numbers "smaller" than iterables.
C[B[a]]==t[C[b]][C[a]] will fail for some value if ◃ is not right-self-distributive.

If any one of the comparisons returns False, the expression (0%...) will throw a ZeroDivisionError. Also, if ◃ is not closed A[a] or C[b] may also throw an IndexError. In both cases, the program exits with status code 1 (failure).
If all test passed, the program will exit normally with status code 0 (success).

Python 2, 138 bytes
def f(m):R=range(len(m));return all(m[i][i]==i<set(zip(*m)[i])==set(R)>m[m[j][k]][i]==m[m[j][i]][m[k][i]]for i in R for j in R for k in R)

m is a list of lists of integers.
Try it online!

JavaScript (ES6), 150 bytes
a=>!(a.some((b,i)=>b[i]-i)|a.some(b=>[...new Set(b)].sort()+''!=[...b.keys()])||a.some((_,i)=>a.some((_,j)=>a.some((b,k)=>b[a[j][i]]-a[b[j]][b[i]]))))

Takes input as an array of column arrays of integers.

Mathematica, 122 bytes
(n_±m_:=#[[m,n]];#&@@Union[Sort/@#]==Range@l==Array[#±#&,l=Length@#]&&And@@Flatten@Array[±##2±#==(#2±#)±(#3±#)&,{l,l,l}])&

Pure function taking a 2D array of integers (1-indexed) as input, with rows and columns reversed from the convention in the question, and returning True or False. The first line defines the binary infix operation n_±m_ to be the quandle operation.
For an l x l array, closed and right-divisible is equivalent to every row (in my case) being some permutation of {1, ..., l}, and idempotent is equivalent to the main diagonal being exactly {1, ..., l}. So #&@@Union[Sort/@#]==Range@l==Array[#±#&,l=Length@#] detects for these three conditions. (The use of Sort/@# here is why I chose to swap rows and columns.)
For right-distributive, we literally check all possibilities using Array[±##2±#==(#2±#)±(#3±#)&,{l,l,l}]). (Note that ±##2±# automatically expands to (#2±#3)±#, since ##2 represents the sequence of the second and third arguments to the three-variable pure function being arrayed over.) Then &&And@@Flatten@ checks whether every single test was passed. For some non-closed quandles, errors might be thrown when it tries to access a part of a matrix that doesn't exist, but the correct answer is still returned.

±m__:=#[[m]]; I think. And there's a Diagonal built-in. And ± is left-associative so you can use #2±#±(#3±#), but if I didn't make a mistake then it's shorter to reassign # to #3 and do #±#2±#3==#±#3±±##2&. And it should also be possible replace the whole Flatten@ part with (...&~Array~{l,l,l}<>"")

I wonder if you have to move the l=Length into Range@l though because that one should be evaluated first, so if you use the function repeatedly, I think Range still gets the previous l, no?

Jelly, 38 36 bytes
ŒDḢJƑ;ZQƑ€$;Jṗ3Ṗịṛ/ịⱮ¥œịʋ=Ṫṭœị⁺ʋɗ€ƲẠ

Try it online!
Takes input as a matrix. The Footer converts the test case formats into matrix formats for you.
Truly a monstrosity of a program. This is broken into 3 stages, each of which checks a different axiom (except closedness as this is implied by right-divisibility):
ŒDḢJƑ - Checks for idempotentness
ZQƑ€  - Checks for right-divisibility and closedness
Jṗ3Ṗịṛ/ịⱮ¥œịʋ=Ṫṭœị⁺ʋɗ€ - Checks for right-self-distributiveness

We group these 3 results together using ; and check that Ạll are true.
How each stage works
We use œị to calculate \$b ◃ a\$, when the left argument is [a, b] and the right argument is M. œị is the "multi-dimensional index-into" command, which retrieves the bth element of the ath row of M. As we're checking every triple of coordinates, and the arguments are reversed for both sides of the indexing equality, the fact that we're calculating \$b ◃ a\$ instead of \$a ◃ b\$ doesn't matter. That means that instead of checking that \$(a◃b)◃c=(a◃c)◃(b◃c)\$, we instead check that \$c◃(b◃a) = (b◃c)◃(a◃c)\$ for all triples \$a, b, c\$.
Each stage is run as a "monadic link", meaning that the only argument passed to it is the inputted matrix.
ŒDḢJƑ - Argument: an n×n matrix M
ŒD    - Yield the diagonals of M
  Ḣ   - Extract the first i.e. the main diagonal
   JƑ - Is it in the form [1, 2, 3, ..., n]?

ZQƑ€ - Argument: an n×n matrix M
Z    - Transpose M
   € - Over each row:
 QƑ  -   Is it unchanged when deduplicated?

Jṗ3Ṗịṛ/ịⱮ¥œịʋ=Ṫṭœị⁺ʋɗ€ - Argument: an n×n matrix M
J                      - Extract n and yield [1, 2, 3, ..., n]
 ṗ3                    - Yield all triples of elements of [1, 2, 3, ..., n]
                    ɗ€ - Over each triple [a,b,c], do the following, with M as the right argument:
              =        -   Are the two following results equal?
             ʋ         -     First result:
   Ṗ                   -       Yield [a,b]
         ¥             -       Group the previous 2 links into a dyad:
     ṛ/                -         Yield c
        Ɱ              -         Over each row in M:
       ị               -           Get the c'th element
                                  This returns a list [1◃c, 2◃c, 3◃c, ..., n◃c]
    ị                  -       Get the a'th and b'th elements
                                  This yields [a◃c, b◃c]
          œị           -       Calculate (b◃c)◃(a◃c); See above
                     ʋ   -     Second result:
               Ṫ         -       Yield c and replace the left argument with [a, b]
                 œị     -        Calculate (b◃a)
                ṭ        -       Tack on c; [b◃a, c]
                    ⁺    -       Repeat the previous link (œị), yielding c◃(b◃a)
              =          -     Does c◃(b◃a) equal (b◃c)◃(a◃c)?

The first yields either 1 or 0, depending on whether the matrix is idempotent or not.
The second yields an array of \$n\$ 1s or 0s, for each row in M. M is only right-divisible and closed iff all of these are 1
The third yields a list of \$n^3\$ 1s if M is right-self-distributive, or a list with at least one 0 if not.

Finally, we concatenate all of these results into a single list. If that list contains a 0, then M is not a quandle, otherwise it is.

C++14, 175 bytes
As unnamed lambda, assuming n to be like std::vector<std::vector<int>> and returning via reference parameter. 0 is false, everything else is true.
#define F(x);for(x=-1;++x<s;){
[](auto m,int&r){int s=r=m.size(),a,b,c F(a)auto A=m[a];r*=s==A.size()&&A[a]==a;int u=0 F(b)u|=1<<m[b][a];r*=A[b]<s F(c)r*=m[A[b]][c]==m[A[c]][m[b][c]];}}r*=!(u-(1<<s)+1);}}

Ungolfed and usage:
#include<vector>
#include<iostream>

auto f=
#define F(x);for(x=-1;++x<s;){
[](auto m,int&r){
 int s=r=m.size(),a,b,c
 F(a)
  auto A=m[a];               //shortcut for this row
  r*=s==A.size()&&A[a]==a;   //square and idempotet
  int u=0                    //bitset for uniqueness in col
  F(b)
   u|=1<<m[b][a];            //count this item
   r*=A[b]<s                 //closed
   F(c)
    r*=m[A[b]][c]==m[A[c]][m[b][c]];
   }
  }
  r*=!(u-(1<<s)+1);          //check right-divisibility
 }
}
;

int main(){
 int r;
 std::vector<std::vector<int>>
  A = {
   {0, 0, 1, 1},
   {1, 1, 0, 0},
   {3, 3, 2, 2},
   {2, 2, 3, 3},
  },
  B = {
   {0, 2, 3, 4, 1},
   {0, 1, 2, 3, 4},
   {3, 4, 2, 2, 2},
   {3, 3, 3, 3, 3},
   {4, 1, 1, 1, 4},
  };
 f(A,r);
 std::cout << r << "\n";
 f(B,r);
 std::cout << r << "\n";
}

Suggest int a,b,c,u,s=r=m.size()F instead of int s=r=m.size(),a,b,c F, u=0;r*=s==A.size()&&a==A[a]F instead of r*=s==A.size()&&A[a]==a;int u=0 F, r*=s>A[b]F instead of r*=A[b]<s F and ~u+(1<<s) instead of u-(1<<s)+1

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Name the Brag Hand
Background
Brag is a card game similar in concept to, but simpler than, poker. A hand in brag consists of three cards and is ranked as follows from highest to lowest:

Three of a kind - all three cards the same rank. Named as "three Kings" etc.
Running flush aka straight flush. All three cards of same suit and of consecutive ranks. The hand is named by the three cards in ascending order followed by the words "on the bounce" to distinguish from a simple run/straight, eg "ten-jack-queen on the bounce". Note an ace is either high or low but not both - "king-ace-two" is not a run.
Run aka straight. As above but without the requirement to match suits. Named simply as eg "ten-jack-queen".
Flush - all three cards the same suit, named after the highest rank eg "Ace flush".
Pair - two cards the same rank together with a third of another version rank. Named as "pair of threes" etc.
Any other combination, named after the highest rank eg "ace high".

Challenge
Given three playing cards, output the name of the brag hand they output.
The cards will be input either as three 2-character strings or concatenated as a single 6-character string (whichever your implementation prefers), where the first of each pair is the rank (2...9, T, J, Q, K, A) and the second signifies the suit (H, C, D, S).
Standard golfing rules apply - write a program or function which accepts this input and outputs the name of the hand as detailed above.
You can assume the input will be valid (ranks and suits in the above range, no repeated card) and in whatever case you prefer, but will not be in any particular order.
Output must be either in all capitals, all lower case, or a sensible capitalisation eg title case or sentence case. Numeric ranks should be spelled out eg "tens" not 10s.
Sample inputs & outputs:
2H3C2D => "pair of twos"

TD8C9C => "eight-nine-ten"

4SKS9S => "king flush"

4D4H4S => "three fours"

5H3H2C => "five high"

2D3DAD => "ace-two-three on the bounce"

6D6C6H => "three sixes"

This is my first attempt at a challenge on this site, please do suggest improvements but be gentle :)

Related. Related.

Welcome to PPCG! I've only skimmed the challenge so far, but it looks decent for a first challenge. That said, writing good challenges is hard and for the future I'd recommend posting ideas in the sandbox first where you can get feedback and improve details of the specification before risking downvotes, close votes and answers that might be invalidated by later changes to the challenge.

@MartinEnder thanks! I'll certainly have been a look at the sandbox next time.

Can we get input as arrays of tuples? Also, can we shorten output like 'king flush' to 'fk'?

@MatthewRoh input as tuples, yes. Shortened output, no - the challenge isn't called "give a cryptic abbreviation of the brag hand" :)

@IanF1 Many languages seem to suffer the lack of compressing strings into shorter code- unless Jelly, of course

@MatthewRoh I'm not anticipating 6-byte answers :)

BTW, this doesn't look much different from other related challenges Martin posted. But I don't know if I should flag as a dupe.

@MatthewRoh Thanks for the feedback. I see it as a different balance between the two tasks involved - the calculation (what hand is this) and the efficient returning of strings, as the hands in this case are simpler than in poker.

@MatthewRoh btw if the community consensus is that it is a dupe, I'll understand.

@IanF1 The community consensus is, if it is easily solvable by editing an answer from another challenge, it's a dupe. But seeing those two 'Related' posts are not dupe hammered each other, I'm confused if I should dupe flag or not.

please add "6D6C6S" as a test case since six is an odd plural

@NotthatCharles Great shout - adding this now!

Ruby, 384, 320
Accepts an array of two-char strings.
Translates the pip values into hex values and identifies hands based on how many distinct pip values there are.
->*d{u=d.map{|x|*u=x[1]}==u*3
g=d.map{|x|(x[0].tr'TJQKA','ABCDE').hex}.sort
g=1,2,3if[2,3,14]==g
_,l,h=a=g.map{|x|%w{king queen jack ten nine eight seven six five four three two ace}[-x%13]}
[*g[0]..2+g[0]]==g ?a*?-+(u ?' on the bounce':''):u ?h+' flush':[h+' high','pair of '+l+=l[?x]?'es':?s,'three '+l][-g.uniq.size]}

Annotated:
->*d{
    # u is "Is this a flush?"" (see if you have more than one suit)
    u=d.map{|x|u=x[1]}==[u]*3

    # g is the sorted card values in integer (convert to base 16)
    g=d.map{|x|x[0].tr('TJQKA','ABCDE').hex}.sort

    # use Ace == 1 if we have a low straight
    g=[1,2,3]if[2,3,14]==g

    # a is the names of all the cards
    a=g.map{|x|%w{ace two three four five six seven eight nine ten jack queen king ace}[x-1]}

    # l is for "plural" - just choose the middle card because we
    #                     only care about plurals for 2s or 3s
    l=a[1].sub(?x,'xe')+?s

    # if [g[0],g[0]+1,g[0]+2] == g, we have a run
    # possibly "on the bounce"
    ([*g[0]..g[0]+2]==g) ? (a * ?-) + (u ? ' on the bounce' : '') :

    # if we have a flush, we can't have three-of-a-kind, so try that first
    u ? a[2]+' flush' :

    # otherwise, dedupe your hand. if there's:
    # 3 values, x high; 2 values, pair; 1 value, three
    [a[2]+' high','pair of '+l,'three '+l][-g.uniq.size]
}

Python 2, 788, 715, 559, 556, 554, 546, 568, 522 bytes
*now passes the 'sixes'
* thanks to Ben Frankel for saving 46 Bytes!

import re
d,m,n=dict(zip('JQKA',range(10,15))),'pair of %ss','%s-%s-%s'
C=lambda s:int(d.get(s[0],s[0]))
z,x,c=sorted(re.findall('..',raw_input()),key=C)
q,w,e=C(z),C(x),C(c)
A=[0,0,'two','three','four','five','six','seven','eight','nine','ten','jack','queen','king','ace']
I,O,U=A[e],A[w],A[q]
a,k='%s high'%I,e-w+q
if k==13:a=n%(I,U,O)
if k==w:a=n%(U,O,I)
if q==w or e==w or e==q:a=m%O
if k==e==w:a='three %ss'%I
if'x'in a:a=a[:-1]+'es'
if z[-1]==x[-1]==c[-1]:
 if'-'in a:a+=' on the bounce'
 else:a='%s flush'%I
print a

Try it online!
Thanks for a cool first challenge!

Some whitespace golfing suggestions: TIO

Thanks! I knew the white space was adding a lot of bytes but I thought it required 4 spaces. Edited! @math_junkie

@user7686415 Or you could use actual tabs instead.

@mbomb007 I did the whole thing on an iPad, idk how to tab or if it's even possible to do so

Hey, welcome to the site! Hope you stick around!

@user7686415 http://apple.stackexchange.com/q/83302

this may fail "sixes"

Golfing suggestion: d=dict(zip(['A23456789TJQKHDSC',values])) where values is the list [['ace',14],['two',2],...]. That saves 37 characters on quotes and colons. You can also save another 5 characters by defining f with a lambda, i.e., f=lambda s:d[s[0]][1].

@BenFrankel I decided to get rid of the large dict completely, and managed to chop off well over 100 bytes. I want to use lambda somehow but I cannot for the life of me think of how to implement it now(or if i even should) Thanks for your comment!

@NotthatCharles fixed it!

@Stephen, you can still shave off 5 bytes by using dict(zip('...',range(10,15))), and you can shave off some more by defining C with a lambda, C=lambda s:int(d.get(s[0],s[0]))

@BenFrankel can you explain the C function? I'm a bit confused as to how it works. How does it work when an s gets passed through that isn't in the d dict? Thanks for the help!

@Stephen, Sure. D.get(a, b) means access the value in the dict D at key a, with default value b if the key is not found. It's the same as writing D[a] if a in D else b, which is the same as writing D[a] if a in D.keys() else b.

@BenFrankel thank you for the explanation! I tried for the better part of 2 hours to try and figure out how I could reduce that part. I did not know Python had a dict.get() function that allowed for a default value, I can see so many uses for this haha. I kept trying to find a way to have an if statement in a lambda function because I kept getting an error with the key not existing. Thank You!

PHP, 413 405 398 409 408 406 398 bytes
Unfortunately, PHP does not support nested array referencing inside strings;
that would have saved another 6 5 bytes.
for(;$a=$argn[$i++];)$i&1?$v[strpos(_3456789TJQKA,$a)]++:$c[$a]++;$k=array_keys($v);sort($k);$n=[two,three,four,five,six,seven,eight,nine,ten,jack,queen,king,ace];echo($m=max($v))<2?($k[!$d=count($c)]+2-($h=$k[2])?$k[1]>1|$h<12?"$n[$h] ".[flush,high][$d++/2]:"ace-two-three":$n[$k[0]]."-".$n[$k[1]]."-$n[$h]").[" on the bounce"][$d^1]:($m<3?"pair of ":"three ").$n[$v=array_flip($v)[$m]].e[$v^4].s;

Run with echo <hand> | php -nR '<code> or test it online.
breakdown
for(;$a=$argn[$i++];)$i&1?      # loop through input
    $v[strpos(_3456789TJQKA,$a)]++  # count values on even positions [0,2,4]
    :$c[$a]++;                      # count colors on odd positions [1,3,5]
$k=array_keys($v);sort($k);     # $k=ascending values
$n=[two,three,four,five,six,seven,eight,nine,ten,jack,queen,king,ace];
echo($m=max($v))<2              # three different values:
?($k[!$d=count($c)]+2-($h=$k[2])    # test normal straight ($d=color count, $h=high card)
    ?$k[1]>1|$h<12                      # test special straight
        ?"$n[$h] ".[flush,high][$d++/2]     # flush if one color, high card if not
                                            #   ($d++ to avoid " on the bounce")
        :"ace-two-three"                    # special straight
    :$n[$k[0]]."-".$n[$k[1]]."-$n[$h]"  # normal straight
).[" on the bounce"][$d^1]          # if straight: straight flush if one color
:($m<3?"pair of ":"three ")     # pair or triplet
    .$n[$v=array_flip($v)[$m]]      # card name
    .e[$v^4].s                      # plural suffix
;

Requires PHP>=5.6 (for e[...])

this may fail "sixes"

@NotthatCharles: That cost me 11 bytes ... but I golfed them back. :)

Python 2 - 583 bytes
I'm too new to be able to comment posts, so I just post my version of python solusion.
Fixed issue with 'es' for pair and three of sixes. Thanks to Not that Charles
d={'A':['ace',14],'2':['two',2],'3':['three',3],'4':['four',4],'5':['five',5],'6':['six',6],'7':['seven',7],'8':['eight',8],'9':['nine',9],'T':['ten',10],'J':['jack',11],'Q':['queen',12],'K':['king',13]}
r=input()
j=1
i=lambda x:d[x][j]
v=sorted(r[::2],key=i)
z,y,x=v
s=r[1::2]
e='es'if i(y)==6else's'
j=0
a=i(x)
if z==y or y==x:r="pair of %s"%i(y)+e
if s[0]*3==s:r="%s flush"%a
t="%s-%s"%(i(z),i(y))
j=1
u=" on the bounce"if r[-1]=='h'else ""
if i(z)+i(x)==2*i(y):r=t+"-%s"%a+u
if ''.join(v)=="23A":r="%s-"%a+t+u
if [z]*3==v:r="three %s"%d[z][0]+e
if len(r)==6:r="%s high"%a
print r

A bit more readable with some comments
# first of all we don't need to keep suits
d={'A':['ace',14],'2':['two',2],'3':['three',3],'4':['four',4],'5':['five',5],'6':['six',6],'7':['seven',7],'8':['eight',8],'9':['nine',9],'T':['ten',10],'J':['jack',11],'Q':['queen',12],'K':['king',13]}
r=input()                           # input placed in r, to safely check r[-1] later in code
j=1                                 # j toggles reading from dictionary: 0-string, 1-value
i=lambda x:d[x][j]                  # lambda used to access dictionary
v=sorted(r[::2],key=i)              # take values from input and sort
z,y,x=v                             # variables to compact code
s=r[1::2]                           # take suits from input
e='es'if i(y)==6else's'             # choose ending 'es' for six and 's' for others (for pair and three)
j=0                                 # toggle reading from dictionary to string
a=i(x)                              # get string of top most value
if z==y or y==x:                    # check only two pairs as values are sorted
    r="pair of %s"%i(y)+e
if s[0]*3==s:                       # compact check if all string characters are equal to detect flush
    r="%s flush"%a
t="%s-%s"%(i(z),i(y))               # part of straight output - first two values
j=1                                 # toggle reading from dictionary to values
u=" on the bounce"\                 # addon to output in case of possible straight flush
if r[-1]=='h'else ""                # detected by checking last character in r
                                    # which would be 'h' if flush was detected
if i(z)+i(x)==2*i(y):               # check straight - three sorted numbers a,b,c would be in line if a+c == 2*b
    r=t+"-%s"%a+u
if ''.join(v)=="23A":               # check special case with straight, started from Ace
    r="%s-"%a+t+u
j=0                                 # toggle reading from dictionary to string
if [z]*3==v:                        # check three equal values (almost the same as flush check)
    r="three %s"%d[z][0]+e
if len(r)==6:                       # if r was never modified, then it's just one high card
    r="%s high"%a
print r                             # output r

Also may change in last rows
j=0; if [z]*3==v:r="three %ss"%i(z)
to
if [z]*3==v:r="three %ss"%d[z][0]
But it saves just 1 byte

this may fail "sixes"

@NotthatCharles Yeah, thank you for noticing. I've added fix

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Code golf for my real friends

...and real golf for my code friends.

This is a challenge based on a one year old XKCD comic which consists mostly of toasts (parodies of the first in the comic) following a distinct pattern, but with some slight variation.
Your task is to write a program (or function) that takes the first half of any toast from the comic (everything up to and including the friends) as input (via stdin or a function argument) and outputs (or returns) the precise text of the second half. You do not have to handle invalid input, standard loopholes apply, shortest code in bytes wins.
Examples
To help those who don't want to copy the toasts from anywhere else, here are all of them, separated into input and output.
Input: Champagne for my real friends
Output: and real pain for my sham friends!

Input: Pseudopods for my real friends
Output: and real pods for my pseudo-friends!

Input: Petticoats for my real friends
Output: and real coats for my petty friends.

Input: Loosestrife for my real friends
Output: and real strife for my loose friends!

Input: Ladybugs for my real friends
Output: and real bugs for my lady friends!

Input: Single-payer for my real friends
Output: and RealPlayer for my single friends.

Input: Tumbleweeds for my real friends
Output: and real weed for my Tumblr friends!

Input: Fauxhawks for my real friends
Output: and real hawks for my faux friends!

Input: Platonic solids for my real friends
Output: and real solids for my platonic friends!

I think you have a typo at Single-payer (instead of Single-player).

Kevin: No. It really is Single-payer.

@KevinCruijssen - It might be a typo, but if so it's Randall@XKCD's, not ivzem.   There's a discussion of it on Explain xkcd.  Also, ivzem - as soon as I saw the title in the HNQ list, I was sure you were referencing that comic.  Well done!

Retina, 119 bytes
The previous version didn't manage correctly the space in "platonic solids", this one works and is shorter :)
ew
rw
eds
ed
(\w+) ?([^oatr ]\w{3}.+)real
and real $2$1
C
S
gne
in
o
o-
ti
ty
T`TL`Tl
p\w+y.+
$&.
s$
s!
real -p
RealPl

Try it online!
This transforms the input into the output through a series of substitutions.
The most interesting part is this substitution (kind of a regex golf):
(\w+) ?([^oatr ]\w{3}.+)real
and real $2$1

Which does almost all the job, by splitting the first word, placing its pieces in the right places, removing extra spaces, and building the structure of the output. To work correctly on the "Tumbleweeds" test case this depends on the previous substitution "eds"->"ed".
The rest is mostly composed by substitutions that deal with special cases. Other interesting parts are:
T`TL`Tl

This turns everything except "T" (for Tumblr) to lowercase.
p\w+y.+
$&.
s$
s!

This places a "." at the end of each sentence containing a word with a "y" some letters after a "p" ("petty" and "payer" in practice). Then places a "!" at the end of all sentences ending with an "s" (all the others).

This prints an extra space after platonic. Suggested fix: TIO (+5 bytes)

@math_junkie Thank you, I've uploaded a new version which fixes the problem with spaces and is even shorter :)

Python 2, 291 269 293 255 247 bytes
Thanks to Erik the Outgolfer for saving 22 bytes!
+24 bytes to account for some outputs ending in . instead of !
lambda x:'and '+['real '+'pain%ssham ,pods%spseudo-,coats%spetty ,strife%sloose ,bugs%slady ,weed%sTumblr ,hawks%sfaux ,solids%splatonic '.split(',')['noarsekc'.find(x[7])],'RealPlayer%ssingle ']['-'in x]%' for my '+x[-7:]+'!.'['-'in x or'tt'in x]

Simple solution to start things off. Checks the eighth letter of the input, as suggested in the comments, and looks up the corresponding output in a dictionary an array.
Try it Online!

You might have forgotten Single-payer for my real friends...

@MathieuRodic No, that is quite intentional. RealPlayer is a special case

Oops, sorry, read too quickly.

Python 3, 788, 403, 359 396  bytes
Latest Version
This is now my fifth attempt. I've managed to half the size of my original program. It now includes the missing "-" and I believe is a complete solution. Still I suspect on the bulky side; but much closer to the goal. I've had a lot of help. Thanks for all the helpful guidance.
s=input()
x=0
l= "Ch,pain,Sham,Ps,pods,psuedo-,Pe,coats,petty,Lo,strife,loose,La,bugs,lady,Si,RealPlayer,single,Tu,weed,Tumblr,Fa,hawks,faux,Pl,solids,platonic".split(",")
a,b,c,d,e,f,g,h = " and real","for my","friends",".!","print(a,l[p+1],b,l[p+2]",",c+d[0])","+c+d[1])",",c+d[1])"
for p in range(0,27,3):
 x+=1
 if s[:2] == l[p]:
  if x == 2: eval(e+g)
  else: eval(e+f if x in(3,6) else e+h)

Try it online!

Original Posting
This is my first post on code golf so apologies in advance for my clumsy program. Can't see how a program could be made to convert "Champagne" to "pain", "sham" by parsing the words. However I would like to see someone else solve that. So, as my level of ability dictates that my program needs to know in advance that "Champagne" is "pain", "sham", there seemed little point in actually coding an input request. As a result I've left it out and been a bit literal with my print output. Hope that's ok : )
phraseList= [   ("Champagne","pain","Sham"),
                ("Psudeopods","pods","psuedo-"),
                ("Petticoats","coats","petty"),
                ("Loosestrife","strife","loose"),
                ("Ladybugs","bugs","lady"),
                ("Single-payer","coats","petty"),
                ("Petticoats","RealPlayer","single"),
                ("Tumbleweeds","weed","Tumblr"),
                ("Fauxhawks","hawks","faux"),
                ("Platonic solids","real solids","platonic")
                ]

for phrase in phraseList:
    print("Input: ",phrase[0], "for my real friends.")
    if "-" in phrase[2]:
        print("Output: and real", phrase[1], "for my", phrase[2]+ "friends!")
    else:
        print("Output: and real", phrase[1], "for my", phrase[2], "friends!")

From the Help Center: All solutions to challenges should: [...] Be a serious contender for the winning criteria in use. For example, an entry to a code golf contest needs to be golfed, and an entry to a speed contest should make some attempt to be fast.

Hello and welcome to the site.  This is a [tag:code-golf] question which requires you to make an effort to minimize the length of your code.  You should remove unnecessary whitespace and rename variables to be 1 character long.

You can put the whole phraseList in one line, reduce the indention to one space, put the prints together in one line with if and else, and the whitespace in the prints isn't necessary. Anyway, I do not know if you're allowed to just print all outputs ;)

Hello! It seems like this is your first code golf answer. Unfortunately, you seem to have misunderstood the question, especially the "Examples" table at the bottom, which just shows how each input should map to a respective output. Currently, your program just prints that table.Also, it is standar practice to place your code in a code block (select it and click the {}) for better readability and to mention your language of choice and byte count, as this site is more like a competition than a Q&A site. Wheat Wizard already did that, so that's better

Hi and welcome to PPCG. You could lose a lot of bytes by removing spaces and using single letter variables. I remember when I first started here it took some time to get used to. I guess you are like me. You spend a lot of time writing readable code. As I said, welcome to PPCG and a new world ;)

Here is a golf of your answer.  I just has a few trivial reductions to your existing code.  Feel free to include it or not.

Thnx, I added in all the improvements suggested. It did end up bigger as I'd forgotten to deal with the "-" in "pseudo-friends". However I think it now does everything. Which is quite pleasing.

You can save a byte by replacing all commas in L with spaces and .split()

Röda, 299 292 288 259 bytes
4 bytes saved thanks to @fergusq for using , instead of .. in the push statements
Bytes saved thanks to @fergusq showing me the way of indexOf
h a{r=indexOf(a[7:8],"noarspekc")A="pain>pods>coats>strife>Player>bugs>weed>hawks>solids>sham >pseudo->petty >loose >lady >single >Tumblr >faux >platonic >!>!>.>!>!>.>!>!>!"/">";["and "];["Real"]if[r=4]else["real "];[A[r]," for my ",A[r+9],"friends",A[r+18]]}

Try it online!
So close to Python... so close.... Your move, Python.
Explanation
h a{
  r=indexOf(a[7:8],"noarspekc")  /*Gets the index of the character in this string*/
  /*Variable A contains all the unique words for each test case*/
  A="pain>pods>coats>strife>Player>bugs>weed>hawks>solids>sham >pseudo->petty >loose >lady >single >Tumblr >faux >platonic >!>!>.>!>!>.>!>!>!"/">"
  ["and "]
  ["Real"]if[r=4]else["real "]   /*RealPlayer*/
  [A[r]," for my ",A[r+9],"friends",A[r+18]]   /*Print everything using var A*/
}

Can you save one byte by using string interpolation in the last statement? Edit: actually the shortest way is probably to push many strings to the stream instead of one, ie. replace .. with ,.

Also you can just use r=indexOf(a[7:8],"noarspekc").

@fergusq Ah, I didn't know such a builtin existed. Thanks!

SOGL, 143 bytes
_╔x⅜²‘,8WWAa"⅞+1Tλ²⅞ƨ◄…χŗbdŗu8ņ∑Ι⅓I‼hzΔμō┘═q‼xΘ▼²ηpG⅔─┌¡↕+wd÷[≈┐α┌ļ○(‚δΦEΤα{‚φ▒k׀:╚s&⅛↑»‘ |Θwθ1w"ρ└⁸‘S∆∫⁴‘a1>*+oo"¤Ε○Φr‘o2w _@ŗo"æn‘o"χ}49⁶‘aWT

This uses this string as the main part. "|" are the splitters and "_" are space placeholders so split would work correctly.
RealPlayer single_|weed Tumblr_|strife loose_|bugs lady_|pods pseudo-|pain sham_|solids platonic_|coats petty_|hawks faux_

Input example: "Platonic solids for my real friends"
Explanation:
..‘,8WWAa"..‘ |Θwθ1w"..‘S∆∫⁴‘a1>*+oo"..‘o2w _@ŗo"..‘o"..‘aWT  strings shortened
..‘                                                           push "personcake" (the indexing string) ["personcake"]
    8W                                                        get the 8-th char
   ,                                                           from the input                         ["personcake", "c"]
      W                                                       get its in "personcake" (1-indexed)     [7]
       Aa                                                     save on variable A                      [7]
         "..‘                                                 push the long string                    [7, "RealPlayer...faux_"]
              |Θ                                              split on "|"                            [7, ["RealPlayer single_", ..., "hawks faux_"]]
                w                                             get the Ath item of the array           [["..."], "solids platonic_"]
                 θ                                            split on spaces                         [["..."], ["solids", "platonic_"]]
                  1w                                          get the 1st item                        [["..."], ["solids", "platonic_"], "solids"]
                    "..‘                                      push "and "                             [["..."], ["solids", "platonic_"], "solids", "and "]
                        S∆∫⁴‘                                 push "real "                            [["..."], ["solids", "platonic_"], "solids", "and ", "real "]
                             a1>*                             multiply by A(index) > 1                [["..."], ["solids", "platonic_"], "solids", "and ", "real "]
                                 +                            join together                           [["..."], ["solids", "platonic_"], "solids", "and real "]
                                  o                           output                                  [["..."], ["solids", "platonic_"], "solids"]
                                   o                          output (the 1st item of the array)      [["..."], ["solids", "platonic_"]]
                                    "..‘o                     output " for my "                       [["..."], ["solids", "platonic_"]]
                                         2w                   get the 2nd item of the array           [["..."], ["solids", "platonic_"], "platonic_"]
                                            _@ŗ               replace "_" with " "                    [["..."], ["solids", "platonic_"], "platonic "]
                                               o              output that                             [["..."], ["solids", "platonic_"]]
                                                "..‘o         output "friends"                        [["..."], ["solids", "platonic_"]]
                                                     "..‘     push ".!!!!!!.!"                        [["..."], ["solids", "platonic_"], ".!!!!!!.!"]
                                                         aW   get the Ath item                        [["..."], ["solids", "platonic_"], "!"]
                                                           T  output, disabling implicit output       [["..."], ["solids", "platonic_"]]

JavaScript (ES6), 230 228 221 216 bytes
s=>'and '+((n='paonrsekc'.search(s[7]))?'real ':'')+'RealPl740s5 /450p3y /540p5-/pain0s3 /460l4 /340l3 /540T4r /350f3 /860p7 '.split`/`[n].replace(/\d\d?/g,n=>s.substr(n/10+1,n%10)||' for my ')+'friends'+'.!'[+(n>1)]

Test

let f =

s=>'and '+((n='paonrsekc'.search(s[7]))?'real ':'')+'RealPl740s5 /450p3y /540p5-/pain0s3 /460l4 /340l3 /540T4r /350f3 /860p7 '.split`/`[n].replace(/\d\d?/g,n=>s.substr(n/10+1,n%10)||' for my ')+'friends'+'.!'[+(n>1)]

console.log(f("Champagne for my real friends"));
console.log(f("Pseudopods for my real friends"));
console.log(f("Petticoats for my real friends"));
console.log(f("Loosestrife for my real friends"));
console.log(f("Ladybugs for my real friends"));
console.log(f("Single-payer for my real friends"));
console.log(f("Tumbleweeds for my real friends"));
console.log(f("Fauxhawks for my real friends"));
console.log(f("Platonic solids for my real friends"));

Perl, 173 168 bytes
Removing newlines and indentations, this becomes 173 bytes of Perl5 code. Shamelessly stole first regexp from Leo's Retina answer. (Mine was a few chars longer)
sub f{
  my($_)=@_;
  s,(\S+[oieyxm ])(\S{4}.+)real,and real $2\l$1,;
  s,gne,in,;
  s,ch,sh,;
  s,ti,ty,;
  s,eds,ed,;
  s,tumble,Tumblr,;
  s,real -p,RealPl,;
  s,o ,o-,;
  s,c ,c,;
  /ng|tt/?"$_.":"$_!"
}

For perl5 version >= 5.14 another 5 bytes can be shaved off with eval and the new /r regexp substitution modifier. Ending up with 168 bytes:
sub f{my($_)=@_;eval's,(\S+[oieyxm ])(\S{4}.+)real,and real $2\l$1Xgne,inXch,shXti,tyXeds,edXtumble,TumblrXreal -p,RealPlXo ,o-Xc ,c,;/ng|tt/?"$_.":"$_!"'=~s/X/,;s,/gr}

Try it online!

PHP, 202 220 204 203 bytes
and real <?=[pods,solids,hawks,strife,RealPlayer,pain,bugs,weed,coats][$q=md5($argv[1].LnI)%9].' for my '.[pseudo,platonic,faux,loose,single,sham,lady,Tumblr,petty][$q].' -'[!$q].friends.'.!'[!$q||$q&3];

Java 7, 585 553 bytes
import java.util.*;String c(String s){Map m=new HashMap(){{put("Ch","pain");put("Ps","pods");put("Pe","coats");put("Lo","strife");put("La","bugs");put("Si","Player");put("Tu","weed");put("Fa","hawks");put("Pl","solids");put("Ch1","sham ");put("Ps1","pseudo-");put("Pe1","petty ");put("Lo1","loose ");put("La1","lady ");put("Si1","single ");put("Tu1","Tumblr ");put("Fa1","faux ");put("Pl1","platonic ");}};String r=s.substring(0,2);int c=r.charAt(1);return"and "+(c=='i'?"Real":"real ")+m.get(r)+" for my "+m.get(r+1)+"friends"+(c=='i'|c=='e'?'.':'!');}

-32 bytes thanks to @Zircon.
Can definitely be golfed by using something different than a Map..
Explanation:
import java.util.*;            // Import required for the Map & HashMap
String c(String s){            // Method with String parameter and String return-type
  Map m=new HashMap(){{        //  The Map
    put("Ch","pain");put("Ps","pods");put("Pe","coats");put("Lo","strife");put("La","bugs");put("Si","Player");put("Tu","weed");put("Fa","hawks");
                               //  Add mapping from first two characters with first word
    put("Ch1","sham ");put("Ps1","pseudo-");put("Pe1","petty ");put("Lo1","loose ");put("La1","lady ");put("Si1","single ");put("Tu1","Tumblr ");put("Fa1","faux ");put("Pl1","platonic ");
                               //  Add mapping from first two characters + "1" with second word (+ space or '-' for edge-case `pseudo-friends`)
  }};                          // End of Map initialization
  String r=s.substring(0,2);   //  Get the first two characters of the input String
  int c=r.charAt(1);           //  Get the second character
  return "and "                //  return "and "
    + (c=='i'?"Real":"real ")  //   + "Real" or "real " for edge-case `RealPlayers`
    + m.get(r)                 //   + first word from Map
    + " for my "               //   + " for my "
    + m.get(r+1)               //   + second word from Map
    + "friends"                //   + "friends"
    + (c=='i'|c=='e' ? '.'     //   + '.' for edge-cases 'Petticoats' and 'Single-player
      : '!');                  //     or '!' for all other cases
}                              // End of method

Test code:
Try it here. (ideone.com is bugged lately, so I'm using TIO now..)
import java.util.*;
class M{
  static String c(String s){Map m=new HashMap();m.put("Ch","pain");m.put("Ps","pods");m.put("Pe","coats");m.put("Lo","strife");m.put("La","bugs");m.put("Si","Player");m.put("Tu","weed");m.put("Fa","hawks");m.put("Pl","solids");m.put("Ch1","sham ");m.put("Ps1","pseudo-");m.put("Pe1","petty ");m.put("Lo1","loose ");m.put("La1","lady ");m.put("Si1","single ");m.put("Tu1","Tumblr ");m.put("Fa1","faux ");m.put("Pl1","platonic ");String r=s.substring(0,2);int c=r.charAt(1);return"and "+(c=='i'?"Real":"real ")+m.get(r)+" for my "+m.get(r+1)+"friends"+(c=='i'|c=='e'?'.':'!');}

  public static void main(String[] a){
    System.out.println(c("Champagne for my real friends"));
    System.out.println(c("Pseudopods for my real friends"));
    System.out.println(c("Petticoats for my real friends"));
    System.out.println(c("Loosestrife for my real friends"));
    System.out.println(c("Ladybugs for my real friends"));
    System.out.println(c("Single-player for my real friends"));
    System.out.println(c("Tumbleweeds for my real friends"));
    System.out.println(c("Fauxhawks for my real friends"));
    System.out.println(c("Platonic solids for my real friends"));
  }
}

I think you can save bytes by using double-brace initialization and put instead of m.put.

C, 367 bytes
Didn't end up as short as it seemed it would.
i,j,c;f(char*s){c=s[7]-97;char t[9],u[200];char*r=s;s+=j=c&&c-17?c-10&&c-18?c-2?5:8:3:4;for(i=0;*++s-32;t[i++]=*s);t[c-4?i:i-1]=0;for(i=0;*r++-t[0];)u[i++]=*(r-1);u[i]=32;u[i+1]=0;u[0]+=32;u[c?i:i-1]=c?c-2?c-14?32:45:0:121;printf("and %s%s for my %sfriends%c",c-15?"real ":"RealPlayer",c-15?c-13?t:"pain":"",c-13?c-4?c-17?u:"loose ":"Tumblr ":"sham ",c&&c-15?33:46);}

C (gcc), 311 bytes
Clear patterns, but so many exceptions. Still, there must be a better way than this!
f(char*s){char*t="\"5$#(=931",*r[]={"pain", "sham","pods","pseudo","coats","petty","strife","loose","bugs","lady","Player","single","weed","Tumblr","hawks","faux","solids","platonic"};int i=strchr(t,*s^s[2])-t;printf("and %s%s for my %s%cfriends%c",i^5?"real ":"Real",r[i*2],r[i*2+1],i^1?32:45,i^5&&i^2?33:46);}

Try it online!

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Count how many distance sequences are far from all others
The Hamming distance between two strings of equal length is the number of positions at which the corresponding symbols are different.
Let P be a binary string of length n and T be a binary string of length 2n-1.  We can compute the n Hamming distances between P and every n-length substring of T in order from left to right and put them into an array (or list).
Example Hamming distance sequence
Let P = 101 and T = 01100. The sequence of Hamming distances you get from this pair is 2,2,1.
Definition of closeness
Now let's consider two such sequences of Hamming distances. Say x = (0, 2, 2, 3, 0) and y = (2, 1, 4, 4, 2) as examples.  We say that x and y are close if y <= x <= 2*y or if x <= y <= 2*x.  Here the scalar multiplication and inequality are taken elementwise.   That is to say,  for two sequences A and B, A <= B iff A[i] <= B[i] for all indices i.
Note that sequences of Hamming distances form a partial order under this way of comparing them.  In other words, many pairs of sequences are neither greater than or equal nor less than or equal to each other.  For example (1,2) and (2,1).
So using the example above, (0, 2, 2, 3, 0) <= 2*(2, 1, 4, 4, 2)  = (4, 2, 8, 8, 4) but (0, 2, 2, 3, 0) is not bigger than (2, 1, 4, 4, 2). Also (2, 1, 4, 4, 2) is not smaller than or equal to 2*(0, 2, 2, 3, 0) = (0, 4, 4, 6, 0).  As a result x and y are not close to each other.
Task
For increasing n starting at n=1, consider all possible pairs of binary strings P of length n and T of length 2n-1.  There are 2^(n+2n-1) such pairs and hence that many sequences of Hamming distances.  However many of those sequences will be identical . The task is to find the size of the largest set of Hamming distance sequences so that no two sequences are close to each other.
Your code should output one number per value of n.
Score
Your score is broadly speaking the highest n your code reaches on my machine in 5 minutes (but read on).   The timing is for the total running time, not the time just for that n.
In order to give scores for non-optimal answers, because finding optimal answers is likely to be hard, we will need a slightly subtle scoring system. Your score is the highest value of n for which no one else has posted a higher correct answer for any size which is smaller than equal to this.  For example, if you output 2, 4, 21 and someone else outputs 2, 5, 15 then you would only score 1 as someone else has a better answer for n = 2.  If you output 2, 5, 21 then you would score 3 no matter what anyone else outputs because those answers are all optimal.  Clearly if you have all optimum answers then you will get the score for the highest n you post. However, even if your answer is not the optimum, you can still get the score if no one else can beat it.
Example answers and worked example
(This answers are as yet unchecked. Independent verification would be gratefully received.)
Thanks to  ETHproductions:

n = 1 gives 2.
n = 2 gives 5.
n = 3 gives 21.

Let's look at n = 2 in more detail. In this case the full list of Hamming distance sequences (represented by tuples here) is:
[(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0), (2, 1), (2, 2)]

We can see that (0,0) is not close to any other tuple. In fact if we take (0, 0), (0, 1), (1, 0), (2, 1), (1,2) then none of those tuples are close to any of the others. This gives a score of 5 for n  = 2.
For n = 3 the full list of distinct Hamming distance sequences is:
 [(0, 0, 0), (0, 0, 1), (0, 1, 1), (0, 1, 2), (0, 1, 3), (0, 2, 1), (0, 2, 2), (0, 2, 3), (0, 3, 0), (0, 3, 1), (1, 0, 0), (1, 0, 1), (1, 0, 2), (1, 1, 0), (1, 1, 1), (1, 1, 2), (1, 1, 3), (1, 2, 0), (1, 2, 1), (1, 2, 2), (1, 2, 3), (1, 3, 0), (1, 3, 1), (1, 3, 2), (2, 0, 1), (2, 0, 2), (2, 0, 3), (2, 1, 0), (2, 1, 1), (2, 1, 2), (2, 1, 3), (2, 2, 0), (2, 2, 1), (2, 2, 2), (2, 2, 3), (2, 3, 1), (2, 3, 2), (2, 3, 3), (3, 0, 2), (3, 0, 3), (3, 1, 0), (3, 1, 1), (3, 1, 2), (3, 2, 0), (3, 2, 1), (3, 2, 2), (3, 3, 2), (3, 3, 3)]

Of those 48 sequences, we can pick out a set of size 21 so that no pair in that set are close to each other.
Languages and libraries
You can use any available language and libraries you like. Where feasible, it would be good to be able to run your code so please include a full explanation for how to run/compile your code in Linux if at all possible.
My Machine The timings will be run on my 64-bit machine. This is a standard ubuntu install with 8GB RAM, AMD FX-8350 Eight-Core Processor and Radeon HD 4250.  This also means I need to be able to run your code.
Leading answer

Score of 4 for 2, 5, 21, 83, 361 by Christian Sievers. C++
Score of 5 for 2, 5, 21, 83, 372 by fəˈnɛtɪk. Javascript

After looking at your question, it shows some similarities to spies, revised on hackerrank, which is a NP-complete problem

@fəˈnɛtɪk Great!  Note that my question doesn't require optimal solutions to get a good score.

@fəˈnɛtɪk Can you also confirm the answers for 1,2,3 in  the question?

@fəˈnɛtɪk I very much doubt it is NP-hard. You would have to encode Set Packing or another NP-complete problem into a single integer with only a polynomial change in problem size.

297 unique hamming arrays for 4, 2040 unique arrays for 5

The graphic representation of the possible sequences is a n-dimensional hypercube with side length n

bash: echo -e "2\n5\n21\n81"; yes 356 ;-) - Starting from the fourth entry, these are just lower bounds...

@ChristianSievers Nice try my friend :)

Not good enough. So I do s/81/83/, but there is a lot of work to do before I can change the 356.

@ChristianSievers Do you have code you could post as an answer?

I'll later continue to work on that

C++ using the igraph library
Thanks for a nice opportunity to learn a new library!
This program now computes 2, 5, 21, 83, 361 fast.
You can control printing of the nodes with the PRINTNODES constant.
The graph used has extra edges between nodes corresponding to distance vectors where one is near (but not equal) to the other one reversed. That speeds up the computation, and any independent set found is of course also one of the original graph. Also, even if it is not completely enforced, the computed independent set is closed under reversion. I believe there always exists a maximal independent set with that property. At least there is one for n<=4. (I'm sure I can show 83 is optimal.)
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
#include<igraph.h>

using vect = std::vector<int>;

constexpr int MAXDIRECT=100;
constexpr int PRINTNODES=1;

std::set<int> avoid{};
igraph_t graph;
std::vector<vect> distance_vectors{};
int count;

int close_h(const vect &a, const vect &b ){
  // check one direction of the closeness condition
  for(auto i=a.begin(), j=b.begin(); i!=a.end(); i++,j++)
    if ( (*i > *j) || (*j > 2 * *i))
      return 0;
  return 1;
}

int close(const vect &a, const vect &b ){
  return close_h(a,b) || close_h(b,a);
}

vect distances(int n, int p, int t){
  vect res{};
  for (int i=0; i<n; ++i){
    int count = 0;
    for (int j=0; j<n; ++j)
      count += 1 & ((p>>j)^(t>>j));
    res.push_back(count);
    t >>= 1;
  }
  return res;
}

void print_vect( vect &v ){
  std::cout << "(";
  auto i=v.begin();
  std::cout << *i++;
  for( ; i!=v.end(); ++i)
    std::cout << "," << *i ;
  std::cout << ")\n";
}

void use_node( int n ){
  if(PRINTNODES)
    print_vect( distance_vectors[n] );
  ++count;
  avoid.insert( n );
  igraph_vector_t neighs;
  igraph_vector_init( &neighs, 0 );
  igraph_neighbors( &graph , &neighs, n, IGRAPH_OUT );
  for(int i=0; i<igraph_vector_size( &neighs ); ++i)
    avoid.insert( VECTOR(neighs)[i] );
  igraph_vector_destroy( &neighs );
}

void construct(int n){
  std::set<vect> dist_vects;
  for(int p=0; p>>n == 0; ++p)
    for(int t=0; t>>(2*n-2) == 0; ++t)   // sic! (because 0/1-symmetry)
      dist_vects.insert(distances(n,p,t));
  int nodes = dist_vects.size();
  std::cout << "distinct distance vectors: " << nodes << "\n";

  distance_vectors.clear();
  distance_vectors.reserve(nodes);
  std::copy(dist_vects.begin(), dist_vects.end(),
            back_inserter(distance_vectors));

  igraph_vector_t edges;
  igraph_vector_init( &edges, 0 );
  igraph_vector_t reversed;
  igraph_vector_init_seq( &reversed, 0, nodes-1 );
  for (int i=0; i<nodes-1; ++i){
    vect &x = distance_vectors[i];
    vect xr ( x.rbegin(), x.rend() );
    for(int j=i+1; j<nodes; ++j){
      vect &y = distance_vectors[j];
      if( xr==y ){
        VECTOR(reversed)[i] = j;
        VECTOR(reversed)[j] = i;
      }else if( close( x, y ) || close( xr, y) ){
        igraph_vector_push_back(&edges,i);
        igraph_vector_push_back(&edges,j);
      }
    }
  }
  std::cout << "edges: " << igraph_vector_size(&edges)/2 << "\n";

  igraph_create( &graph, &edges, nodes, IGRAPH_UNDIRECTED);
  igraph_vector_destroy( &edges );

  igraph_cattribute_VAN_setv( &graph, "r", &reversed );
  igraph_vector_destroy( &reversed );

  igraph_vector_t names;
  igraph_vector_init_seq( &names, 0, nodes-1 );
  igraph_cattribute_VAN_setv( &graph, "n", &names );
  igraph_vector_destroy( &names );

}

void max_independent( igraph_t *g ){
  igraph_vector_ptr_t livs;
  igraph_vector_ptr_init( &livs , 0 );
  igraph_largest_independent_vertex_sets( g, &livs );

  igraph_vector_t *nodes = (igraph_vector_t *) VECTOR(livs)[0];
  igraph_vector_t names;
  igraph_vector_init( &names, 0 );
  igraph_cattribute_VANV( g, "n", igraph_vss_vector( nodes ), &names );

  for(int i=0; i<igraph_vector_size(&names); ++i)
    use_node( VECTOR(names)[i] );
  igraph_vector_destroy( &names );
  igraph_vector_ptr_destroy_all( &livs );
}

void independent_comp( igraph_t *g );

void independent( igraph_t *g ){
  if(igraph_vcount( g ) < MAXDIRECT){
    max_independent( g );
    return;
  }
  igraph_vector_ptr_t components;
  igraph_vector_ptr_init( &components, 0 );
  igraph_decompose( g, &components, IGRAPH_WEAK, -1, 1);
  for(int i=0; i<igraph_vector_ptr_size( &components ); ++i)
    independent_comp( (igraph_t *) VECTOR(components)[i] );
  igraph_decompose_destroy( &components );
}

void independent_comp( igraph_t *g ){
  if (igraph_vcount( g ) < MAXDIRECT){
    max_independent( g );
    return;
  }
  igraph_vector_t degs;
  igraph_vector_init( &degs, 0 );
  igraph_degree( g, &degs, igraph_vss_all(), IGRAPH_OUT, 1 );
  int maxpos = igraph_vector_which_max( &degs );
  igraph_vector_destroy( &degs );

  int name = igraph_cattribute_VAN( g, "n", maxpos );
  int revname = igraph_cattribute_VAN( g, "r", maxpos );
  int rev = -1;
  if(name!=revname){
    igraph_vector_ptr_t reversed_candidates_singleton;
    igraph_vector_ptr_init( &reversed_candidates_singleton, 0 );
    igraph_neighborhood( g, &reversed_candidates_singleton,
                         igraph_vss_1(maxpos), 2, IGRAPH_OUT );
    igraph_vector_t * reversed_candidates =
      (igraph_vector_t *) VECTOR(reversed_candidates_singleton)[0];
    igraph_vector_t names;
    igraph_vector_init( &names, 0 );
    igraph_cattribute_VANV( g, "n", igraph_vss_vector( reversed_candidates ),
                        &names );
    long int pos;
    igraph_vector_search( &names, 0, revname, &pos );
    rev = VECTOR(*reversed_candidates)[pos];
    igraph_vector_destroy( &names );
    igraph_vector_ptr_destroy( &reversed_candidates_singleton );
  }
  igraph_vs_t delnodes;
  igraph_vs_vector_small( &delnodes, maxpos, rev, -1 );
  igraph_delete_vertices( g, delnodes );
  igraph_vs_destroy( &delnodes );

  independent( g );
}

void handle(int n){
  std::cout << "n=" << n << "\n";
  avoid.clear();
  count = 0;
  construct( n );
  independent( &graph );
  // try all nodes again:
  for(int node=0; node<igraph_vcount( &graph ); ++node)
    if(avoid.count(node)==0)
      use_node(node);
  std::cout << "result: " << count << "\n\n";
  igraph_destroy( &graph );
}

int main(){
  igraph_i_set_attribute_table( &igraph_cattribute_table );
  for(int i=1; i<6; ++i)
    handle(i);
}

To compile on debian, install libigraph0-dev and do
g++ -std=c++11 -Wall -O3 -I/usr/include/igraph -o ig ig.cpp -ligraph.
Old description:
The igraph library has a function to compute the maximal size of an
independent vertex set of a graph. It can handle this problem up to
n=3 in less than a second and does not terminate in days for n=4.
So what I do is decompose the graph into connected components, and let
the library handle the small (less than MAXDIRECT nodes) components.
For the other components, I select a vertex and delete it. In the best
case, this splits the graph into several components, but usually it
doesn't. Anyway, the components (maybe only one) are smaller, and we can
use recursion.
Obviously the selection of the vertex is important. I just take one of
maximal degree. I found that I get better result (but only for n=4)
when I use a reversed node list. That explains the magic part of the
construct function.
It might be worth while improving the selection. But it seems more important
to reconsider the deleted nodes. Right now, I never look at them again.
Some of them may be unconnected to any of the selected nodes. The problem is
that I don't know which nodes form the independent set. For one, deleting
nodes renumbers the remaining nodes. That can be handled by attaching
attribtes to them. But worse, the computation of the independence number
just gives this number. The best alternative the library offers is to
compute all largest independent sets, which is slower
(how much seems to depend on the graph size).
Still, this seems the immediate way to go. Much more vaguely, I also
think it might be useful to consider if we can use the special way the
graph is defined.
The case n=6 might become reachable (at all, not necessarily in 5 minutes) if I replace the recursion with a loop
using a queue for the remaining components.
I found it interesting to look at the components of the graphs.
For n=4, their sizes are
168, 2*29, 2*28, 3, 4*2, 4*1. Only the biggest one can not be handled directly.
For n=5, the sizes are
1376, 2*128, 2*120, 119, several <=6.
I expect those double sizes to correspond to isomorphic graphs,
but using this doesn't seem worth while because there is always
one single dominating biggest component:
For n=6, the biggest component contains 11941 nodes
(from a total of 15425),
the next two biggest components have size 596.
For n=7, these numbers are 107593 (125232), 2647.

Could you let me know what the set is for 83, I want to know why my algorithm doesn't get that high for 4 but somehow gets higher for 5 :P

It has to be g++ -std=c++11 -Wall -O3 -I/usr/include/igraph -o sievers sievers.cpp  -ligraph . It matters where -ligraph is.

@ChristianSievers How does the generation of edges work in the code?

@ChristianSievers I was wondering how it determines what each vertex should connect to. Reversing the array might be screwing that up.

@fəˈnɛtɪk The distance vectors seem to come sorted out of the set I use to avoid duplicates, but I didn't even think about their ordering when I wrote that code. The inner loop starting at i+1 just avoids looking at a pair and also its swapped version which is not needed, and is the easiest way to avoid loops (edges (a,a)). It doesn't depend on the order in which the nodes come, I don't care if I get (a,b) or (b,a).

My greedy algorithm is suboptimal but it works well for 5

@fəˈnɛtɪk My algorithm is more suboptimal! I think I have to be content with having pushed you to 83...

Getting 83 for 4 takes longer than getting 372 for 5 :P

@fəˈnɛtɪk Oh that's interesting! In the new version I get the 4 case without any need for special casing.

Javascript, Seq: 2,5,21, 81 83,372  67,349
Managed to increase the value for 4 by using random removal of elements at the start of my search. Oddly enough, removing 20 elements with more than 6 connections was faster than removing 5 elements with more than 8 connections...
This sequence is probably not optimal for 5 and might not be optimal for 4. None of the nodes are close to another in the set though.
Code:
input=4;
maxConnections=6;
numRand=20;

hammings=[];
h=(x,y)=>{retVal=0;while(x||y){if(x%2!=y%2)retVal++;x>>=1;y>>=1}return retVal};
for(i=1<<(input-1);i<1<<input;i++){
  for(j=0;j<1<<(2*input);j++){
    hamming=[];
    for(k=0;k<input;k++){
      hamming.push(h((j>>k)%(1<<input),i));
    }
    equal=0;
    for(k=0;k<hammings.length;k++){
      if(hamming.join("")==hammings[k].join("")){
        equal=1;
        break;
      }
    }
    if(!equal)hammings.push(hamming);
  }
}
adjMat=[];
for(i=0;i<Math.pow(input+1,input);i++){
  row=[];
  for(j=0;j<Math.pow(input+1,input);j++){
    row.push(0);
  }
  adjMat.push(row);
}
nodes=[]
for(i=0;i<Math.pow(input+1,input);i++){
  nodes[i]=0;
}
for(i=0;i<hammings.length;i++){
  sum=0;
  chkNodes=[[]];
  for(j=0;j<input;j++){
    chkVal=[];
    t=Math.pow(input+1,j);
    sum+=t*hammings[i][j];
    tmp=[];
    for(r=0;r<chkNodes.length;r++){
      for(k=hammings[i][j];k<=Math.min(hammings[i][j]*2,input);k++){
        stor=[]
        for(s=0;s<chkNodes[r].length;s++){
          stor.push(chkNodes[r][s])
        }
        stor.push(k)
        tmp.push(stor);
      }
    }
    chkNodes=[];
    for(r=0;r<tmp.length;r++){
      chkNodes.push(tmp[r])
    }
  }
  nodes[sum]=1;
  for(j=0;j<chkNodes.length;j++){
    adjSum=0
    for(k=0;k<input;k++){
      adjSum+=Math.pow(input+1,k)*chkNodes[j][k]
    }
    if(adjSum!=sum)adjMat[sum][adjSum]=adjMat[adjSum][sum]=1
  }
}
t=nodes.length;
for(i=0;i<t;i++){
  if(!nodes[i]){
    for(k=0;k<t;k++){
      adjMat[i][k]=adjMat[k][i]=0
    }
  }
}
sum=(a,b)=>a+b;
console.log(nodes.reduce(sum))
connections=x=>x.reduce(sum)
counts=adjMat.map(connections);
stor=[];
for(i=0;i<t;i++){
  stor.push(nodes[i]);
}
maxRemainder=0;

greater=[]
for(i=0;i<t;i++){
  if(nodes[i]&&counts[i]>maxConnections){
    greater.push(i);
  }
}

if(input==4){
  for(w=0;w<greater.length*numRand;w++){
    for(i=0;i<t;i++){
      nodes[i]=stor[i];
    }
    counts=adjMat.map(connections);
    toRemove=Math.floor(Math.random()*numRand*2)
    for(i=0;i<toRemove&&i<greater.length;i++){
      rand=Math.floor(Math.random()*greater.length);
      if(nodes[greater[rand]]){
        nodes[greater[rand]]=0;
        for(j=0;j<t;j++){
          if(adjMat[rand][j]){
            counts[j]--;
          }
        }
      }
    }

    for(i=0;i<t*t;i++){
      max=0;
      maxLoc=0;
      for(j=0;j<t;j++){
        if(counts[j]>=max&&nodes[j]){
          max=counts[j];
          maxLoc=j;
        }
      }
      if(max>0){
        for(j=0;j<t;j++){
          if(adjMat[maxLoc][j]){
            counts[j]--;
            if(counts[j]<max-1&&stor[j]&&!nodes[j]){
              nodes[j]=1;
              for(k=0;k<t;k++){
                if(adjMat[j][k])counts[k]++;
              }
            }
          }
          nodes[maxLoc]=0;
        }
      }
      else{
        break;
      }
    }
    maxRemainder=Math.max(maxRemainder,nodes.reduce(sum))
    //console.log(nodes.reduce(sum));
  }
  console.log(maxRemainder);
}
else{
  for(i=0;i<t*t;i++){
    max=0;
    maxLoc=0;
    for(j=0;j<t;j++){
      if(counts[j]>=max&&nodes[j]){
        max=counts[j];
        maxLoc=j;
      }
    }
    if(max>0){
      for(j=0;j<t;j++){
        if(adjMat[maxLoc][j]){
          counts[j]--;
          if(counts[j]<max-1&&stor[j]&&!nodes[j]){
            nodes[j]=1;
            for(k=0;k<t;k++){
              if(adjMat[j][k])counts[k]++;
            }
          }
        }
        nodes[maxLoc]=0;
      }
    }
    else{
      break;
    }
  }
  console.log(nodes.reduce(sum));
}

Try it online!
Snippet that can be added the end of the program to show what Hamming distance sequences each selected Hamming distance sequence
for(i=0;i<t;i++){
  if(nodes[i]){
    tmp=[]
    for(j=0;j<input;j++){
      tmp.unshift(Math.floor(i/Math.pow(input+1,j))%(input+1))
    }
    console.log(tmp.join(""))
    output=""
    for(j=0;j<t;j++){
      if(adjMat[i][j]&&stor[j]){
        outArr=[]
        for(k=0;k<input;k++){
          outArr.unshift(Math.floor(j/Math.pow(input+1,k))%(input+1))
        }
        output+=" "+outArr.join("");
      }
    }
    console.log(output)
  }
}

Explanation:
First, the code generates all unique hamming distances from the substrings.
input=3;
hammings=[];
h=(x,y)=>{retVal=0;while(x||y){if(x%2!=y%2)retVal++;x>>=1;y>>=1}return retVal};
for(i=1<<(input-1);i<1<<input;i++){
  for(j=0;j<1<<(2*input);j++){
    hamming=[];
    for(k=0;k<input;k++){
      hamming.push(h((j>>k)%(1<<input),i));
    }
    equal=0;
    for(k=0;k<hammings.length;k++){
      if(hamming.join("")==hammings[k].join("")){
        equal=1;
        break;
      }
    }
    if(!equal)hammings.push(hamming);
  }
}

Next, the code converts this list into an undirected graph
adjMat=[];
for(i=0;i<Math.pow(input+1,input);i++){
  row=[];
  for(j=0;j<Math.pow(input+1,input);j++){
    row.push(0);
  }
  adjMat.push(row);
}
nodes=[]
for(i=0;i<Math.pow(input+1,input);i++){
  nodes[i]=0;
}
for(i=0;i<hammings.length;i++){
  sum=0;
  chkNodes=[[]];
  for(j=0;j<input;j++){
    chkVal=[];
    t=Math.pow(input+1,j);
    sum+=t*hammings[i][j];
    tmp=[];
    for(r=0;r<chkNodes.length;r++){
      for(k=hammings[i][j];k<=Math.min(hammings[i][j]*2,input);k++){
        stor=[]
        for(s=0;s<chkNodes[r].length;s++){
          stor.push(chkNodes[r][s])
        }
        stor.push(k)
        tmp.push(stor);
      }
    }
    chkNodes=[];
    for(r=0;r<tmp.length;r++){
      chkNodes.push(tmp[r])
    }
  }
  nodes[sum]=1;
  for(j=0;j<chkNodes.length;j++){
    adjSum=0
    for(k=0;k<input;k++){
      adjSum+=Math.pow(input+1,k)*chkNodes[j][k]
    }
    if(adjSum!=sum)adjMat[sum][adjSum]=adjMat[adjSum][sum]=1
  }
}

Finally, the code cycles through this graph, removing the vertex with the most connections each cycle before restoring any nodes that would now have less connections than the current maximum. When it has finished with this cycle it outputs the number of remaining nodes
t=nodes.length;
for(i=0;i<t;i++){
  if(!nodes[i]){
    for(k=0;k<t;k++){
      adjMat[i][k]=adjMat[k][i]=0
    }
  }
}
sum=(a,b)=>a+b;
counts=adjMat.map(x=>x.reduce(sum));
stor=[];
for(i=0;i<t;i++){
  stor.push(nodes[i]);
}
for(i=0;i<t*t;i++){
  max=0;
  maxLoc=0;
  for(j=0;j<t;j++){
    if(counts[j]>=max&&nodes[j]){
      max=counts[j];
      maxLoc=j;
    }
  }
  if(max>0){
    for(j=0;j<t;j++){
      if(adjMat[maxLoc][j]){
        counts[j]--;
        if(counts[j]<max-1&&stor[j]&&!nodes[j]){
          nodes[j]=1;
          for(k=0;k<t;k++){
            if(adjMat[j][k])counts[k]++;
          }
        }
      }
      nodes[maxLoc]=0;
    }
  }
  else{
    break;
  }
}
console.log(nodes.reduce(sum));

Sets:
1:
0 1

2:
00 01 10 12 21

3:
000 001 011 013 030 031 100 101 110 111 123 130 132 203 213 231 302 310 312
321 333

4:
0000 0001 0011 0111 0124 0133 0223 0230 0232 0241 0313 0320 0322 0331 0403
0412 1000 1001 1013 1021 1100 1102 1110 1111 1134 1201 1224 1233 1243 1304
1314 1323 1330 1332 1342 1403 1413 1420 1422 2011 2033 2124 2133 2140 2142
2214 2230 2241 2303 2313 2320 2331 2411 3023 3032 3040 3041 3101 3114 3123
3130 3132 3141 3203 3213 3220 3231 3302 3310 3312 3321 3334 3343 3433 4031
4113 4122 4131 4210 4212 4221 4311 4333

5:
00000 00001 00011 00111 00123 01112 01235 01244 01324 01343 02111 02230
02234 02333 02342 02432 02441 02522 02530 02531 03134 03142 03220 03224
03233 03241 03314 03323 03331 03403 03412 03421 03520 04133 04141 04214
04223 04232 04303 04313 04322 05042 05050 05051 05132 10000 10001 10011
10122 10212 10221 10245 11000 11001 11013 11022 11100 11112 11120 11121
11202 11211 11345 11353 11443 12012 12111 12201 12245 12253 12335 12344
12352 12425 12430 12434 12442 12513 12532 13033 13042 13244 13252 13325
13330 13334 13342 13404 13424 13433 13441 13520 13522 13531 14032 14051
14140 14152 14225 14230 14234 14241 14243 14304 14315 14324 14332 14413
14420 14422 14431 15041 15050 15125 15133 15142 15215 15223 15232 20112
20135 20211 20253 20334 20352 21012 21021 21102 21110 21111 21201 21245
21344 21352 21430 21433 21442 21514 21523 22011 22101 22135 22244 22252
22325 22334 22340 22343 22405 22415 22424 22441 22520 22522 22531 23041
23144 23150 23152 23225 23234 23240 23243 23251 23304 23315 23324 23333
23341 23403 23413 23420 23432 23521 24031 24050 24125 24130 24134 24142
24151 24215 24224 24233 24303 24314 24320 24323 24331 24412 24421 25123
25132 25141 25203 25214 25222 25231 25302 25312 25321 30234 30243 30252
30324 30333 30340 30342 30414 30423 30430 30432 31011 31235 31244 31253
31325 31334 31340 31343 31405 31415 31424 31432 31441 31504 31521 32025
32034 32100 32144 32152 32225 32234 32240 32243 32251 32304 32315 32324
32330 32333 32342 32403 32414 32423 32512 33024 33031 33033 33125 33134
33140 33143 33151 33215 33224 33230 33233 33242 33303 33314 33320 33323
33332 33412 33431 34124 34133 34203 34214 34223 34232 34241 34310 34313
34322 34411 35202 35213 35221 35311 40323 40332 40341 40431 40505 40513
41135 41144 41240 41243 41252 41324 41330 41333 41342 41403 41414 41423
41512 42033 42134 42143 42230 42233 42242 42303 42310 42314 42323 42332
42341 42413 42422 42431 43023 43124 43130 43133 43142 43203 43220 43223
43232 43241 43302 43313 43322 43331 43421 44114 44123 44132 44210 44213
44222 44231 44312 44321 50413 50422 50504 51233 51242 51251 51323 51332
51341 51413 51422 52023 52133 52142 52151 52223 52232 52241 52313 52322
52331 52421 53102 53114 53122 53210 53213 53321 54201 54212 54221 54311

Thanks for giving the first answer!  Could you give a step by step guide for idiots on how to run your code in Linux please?

Maybe fəˈnɛtɪk could turn his code into a stack snippet?

@mbomb007 for some reason, making this into a snippet causes the error 0 is not a function... in the line for(j=0;j<t;j++)

Maybe you could try JSFiddle?

If you have chrome you can copy paste the code into the console and run it by pressing enter. Not entirely sure about other browsers. Chrome runs the code faster than the online systems for me. Managed to get a 5th value of 349

Firefox also has a console but I can't get it to run for an input of 5.

You may have to run this more than once to get the desired result of 83 for input of 4. Under current conditions it only randomly removes 20 elements 3684 times. As a result, it will sometimes get 82 and sometimes get 83.

Can you put the 372 list  on bpaste.net ?

@Lembik I don't have access to filesharing right now due to firewall. I have attached all the sets of hamming distances that are not close to one another.

@fəˈnɛtɪk Very interesting, thanks!


text:
Is one string contained within the other?
Given two inputs, you should print or return whether the characters in the first string are - in order - inside the second string.
For example, we want to check whether the string hello, taken as the first input, and the sample text (the second input) is abhcedddldddloallllll.
This should output a truthy value, as the first input is in the second input. I will highlight it like this:
abhcedddldddloallllll
Examples:
hello
abhcedddldddoallllll

0 (not enough 'l's - the last few 'l's don't count because they're after the 'o')

hello
ahaecldleldo

1 (the multiple 'l's are fine)

foo
adasdasdsadasdasdasdasfsadasdasoddddddo

1

bar
aaabaaaarrrrra

1

bob
bob

1

You may, of course use other truthy or falsy values, and, of course, exclude text in brackets in your output.
You will only receive printable ASCII characters as input (that is, no whitespace or characters such as µ)
The shortest answer in bytes wins!

And the result of that example would be…?

Welcome on PPCG. As it's currently written, the challenge is very unclear, and lack a victory criterion. I recommend you have a look at other challenges on this site to see how it's done usually, and then post your challenge in the Sandbox to get help from the community to improve it.

Not sure whether unclarity (sounds pretty clear he wants 'abcnjhgahgjhfhaljhrkhgrbhjbevfho'[/n.*a.*g.*a.*r.*r.*o/]) is the biggest issue. The challenge looks very familiar, just can't find its duplicate.

I made some relatively major changes, feel free to edit if I did anything wrong.

Duplicate.

@MartinEnder Now that it's no longer "unclear", can the close reason be changed to "duplicate"?