Perl script to solve games of Set