entropy[ps_List] := -N[Total[(#*Log[2,#])& /@ ps]]

entropy[{0.5, 0.25, 0.25}]

l=Length[perms = Permutations[Range[0,9], {4}]]

Mark[p1_List, p2_List] := Module[
{b = Count[MapThread[Equal, {p1, p2}], True]},
10*b + Length[Intersection[p1,p2]]-b
];
Mark[i_Integer, j_Integer] := Mark[i,j] = Mark[perms[[i]], perms[[j]]]

p1={1,3,4,5}; p2={1,4,3,7}

Mark[p1,p2]

Mark[20, 200]

perms[[{20, 200}]]

entropy[i_, s_List] := entropy[(Last /@  Tally[Mark[i, #]& /@ s])/Length[s]]

i=100; s= Range[l];

n=Length[s]

Log[2, Last[#]]& /@ Tally[Mark[i, #]& /@ s]

entropy[(Last /@  Tally[Mark[i, #]& /@ s])/Length[s]]

entropy[7, Range[l]]

cons[s_List, m_Integer,g_Integer]:=Select[s,Mark[g,#]==m&];
cons[s_List,m_Integer,g_List]:=cons[s,m,Position[perms,g][[1,1]]]

guess[s_List]:=perms[[s[[Ordering[entropy[#,s]&/@s,-1]]][[1]]]]

a0=Range[l];

a1=cons[a0,1,{1,2,3,4}];

guess[a1]

perms[[5037]]

perms[[569]]

a2=cons[a1,11,{9,8,7,3}];

guess[a2]

a3=cons[a2,20,{6,3,7,5}]

guess[a3]

a4=cons[a3,20,{6,4,7,9}]

guess[a4]

a5=cons[a4,11,{8,4,7,5}]

First[b1=cons[a0,1,{1,2,3,4}]]

First[b2=cons[b1, 11, {0,1,5,6}]]

First[b3=cons[b2, 2, {0,3,6,7}]]

First[b4=cons[b3, 2, {2,0,8,6}]]

First[b5=cons[b4, 11, {3,6,5,8}]]

b5

b4

a4

a3

b3

a2

b2

Length[a2]

Length[b2]

Last[a1]