tenpai by nn(2233445566778->258, 4567999->478, 3334567->24578)

R=/^(.)\1\1/
function F(s){n=s[0]
return s[3]?R(s)&&F(s.slice(3))||n>0&&(m=s.match('.'+S+ ++n+S))&&(m=(m[1]+m[2]).match(S+ ++n+S))&&F(m[1]+m[2]):!s||R(s)||R(209-~s)}function G(s){for(r=0;x=/(.)\1/g(s);)r+=(m=s.match(S+x[0]+S))&&F(m[1]+m[2])
return r}function H(s){m=/(.*)(.)\2(.*)/(s)
return m?H(m[1]+m[3]):s}for(S='(.*)';l=readline(a=[b=c=h=0]);print(a.join('|')[r='replace'](/P/(l)?0:25,5)[r](478,47)[r](/^1/(l)?78:0,67))){for([i,v]in s=l.split('|'))v[-1]%3?v[-1]%3>1&&G(v)?h-=~i:0:c+=!F(v)
for([i,v]in s){z=''
if(c?(w=H(v),v[-1]%2?z=b||w[1]?'':w[0]:b+=+w,0):(u=v[-1]%3)?u%2||h+~i:0)for([,w]in'123456789ESW')(u%2?G:F)((v+w).split('').sort().join(''))?z+=w:0
a[i]=z}}

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page