Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /** solving https://youtu.be/WiB2_dXSSMg */
- function reorder($a)
- {
- if(count($a) <=1)
- {
- yield $a;
- }
- else
- {
- foreach($a as $k => $v)
- {
- $x = array($k => $v);
- $b = $a;
- unset($b[$k]);
- foreach(reorder($b) as $c)
- {
- yield $c + $x;
- }
- }
- }
- }
- $n = range(1, 9);
- foreach(reorder($n) as $cn)
- {
- $a = array_values($cn);
- $s = $a[0] +13*$a[1]/$a[2] +$a[3] +12*$a[4] -$a[5] -11 +$a[6]*$a[7]/$a[8] - 10;
- /* if($s == 66) */
- if($s > 65.999 AND $s < 66.001)
- {
- echo "{$a[0]} + 13x{$a[1]}/{$a[2]} + {$a[3]} + 12x{$a[4]} - {$a[5]}";
- echo " - 11 + {$a[6]}x{$a[7]}/{$a[8]} - 10 = {$s}" . PHP_EOL;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement