Rating:

```
#!/opt/local/bin/php71
0,
'* ****** *' => 1,
'* **** * **** *' => 2,
'* * ** * ******' => 3,
'*** * *****' => 4,
'*** ** * ** ***' => 5,
'****** * ** ***' => 6,
'* * *****' => 7,
'****** * ******' => 8,
'*** ** * ******' => 9,
' * ' => '*',
' * *** * ' => '+',
' * * * ' => '-',
];

function get_digit($text) {
$text = preg_replace('%[A-Z]%', '*', $text);
return DIGITS[$text];
}

function calculate($text) {
$digits = [];
$buffer = '';

$lines = array_slice(explode("\n", $text), 4, 5);
$column = 0;
$max = strlen($lines[0]);

while (TRUE) {
if ($column >= $max) break;

$column_chars =
substr($lines[0], $column, 1) .
substr($lines[1], $column, 1) .
substr($lines[2], $column, 1) .
substr($lines[3], $column, 1) .
substr($lines[4], $column, 1);

if ($column_chars == ' ') {
if (!empty($buffer)) $digits[] = get_digit($buffer);
$buffer = '';
} else {
$buffer .= $column_chars;
}

++$column;
}

return $digits;
}

$ch = curl_init(URL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_COOKIEFILE, '');
curl_setopt($ch, CURLOPT_POST, TRUE);

foreach (range(1, 52) as $i) {
$html = curl_exec($ch);
$html = str_replace('
', "\n", $html);
$text = strip_tags($html);
echo $text;

$digits = calculate($text);
$code = '$result = ' . implode('', $digits) . ';';
eval($code);

curl_setopt($ch, CURLOPT_POSTFIELDS, 'sol=' . $result);
}
```