Check over hand values for single-suited Mahjong
J (241 byes)

You need the latest version of J installed.

i=:&gt;:@i.9
q=:,/^:4&gt;@:{(i.9);(i.;i.;i.;i.)16
s=:3 :'(&gt;./((5+([:(*./)(3*i.3)&amp;e.)+(-.@:(-:~.))+((*./)@:(6&amp;&gt;:))+2*((*./)@:(6&amp;&lt;)))"1(}."1(y(-:/:~"1)"1((([:{&amp;(i,.i){.),[:,/[:{&amp;(((&gt;:@i.7)+"0 1(i.3)),|:3 9$i)}.)"1 q))#q)))+([:(*./)[:-.((1 9)&amp;e.))y'




Call the function s with a list of integers. For example, the following example script verifies the test cases above:

#!/usr/bin/jconsole
i=:&gt;:@i.9
q=:,/^:4&gt;@:{(i.9);(i.;i.;i.;i.)16
s=:3 :'(&gt;./((5+([:(*./)(3*i.3)&amp;e.)+(-.@:(-:~.))+((*./)@:(6&amp;&gt;:))+2*((*./)@:(6&amp;&lt;)))"1(}."1(y(-:/:~"1)"1((([:{&amp;(i,.i){.),[:,/[:{&amp;(((&gt;:@i.7)+"0 1(i.3)),|:3 9$i)}.)"1 q))#q)))+([:(*./)[:-.((1 9)&amp;e.))y'


echo (s 2 2 2 3 3 3 5 5 7 7 7 8 8 8)=8
echo (s 1 1 1 1 2 3 4 5 6 7 8 9 9 9)=6
echo (s 1 1 1 2 3 4 5 6 7 8 8 9 9 9)=5
echo (s 2 3 3 4 4 4 5 5 5 6 6 7 8 8)=7
echo (s 3 3 3 3 4 4 4 4 5 5 5 5 6 6)=8
echo (s 1 1 1 2 2 2 3 3 3 7 7 7 9 9)=7
echo (s 1 2 3 4 4 5 5 6 6 7 8 8 8 9)=8
echo (s 1 1 3 4 4 5 5 6 6 7 8 9 9 9)=5
echo (s 2 2 2 3 3 3 4 4 4 5 5 5 6 6)=8
echo (s 1 1 1 1 2 2 3 3 3 4 4 5 5 5)=5

exit''