fork download
  1. from itertools import*
  2. S=input().split(',')
  3. print([i+1for i in range(81)if eval('*'.join('(list(product(*["SML"]*4))[i][%d]%s="%s")'%('BFHE'.find(s[-1]),'!='[s[0]>'!'],s[-2])for s in S))]or 0)
Success #stdin #stdout 0.11s 10104KB
stdin
!SH,LB,!ME,SF
stdout
[58, 60, 61, 63]