Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $x = true;
- $tries = 0;
- while($x):
- $numbers = array(1,2,3,4,5,6,7,8,9);
- shuffle($numbers);
- $matriz = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i');
- $num = 0;
- foreach($matriz as $key => $value):
- $new_matriz[$value] = $numbers[$num];
- $$value = $numbers[$num];
- $num = $num + 1;
- endforeach;
- if( $a + $b + $c == 15 &&
- $d + $e + $f == 15 &&
- $g + $h + $i == 15 &&
- $a + $d + $g == 15 &&
- $b + $e + $h == 15 &&
- $c + $f + $i == 15 &&
- $a + $e + $i == 15 &&
- $g + $e + $c == 15 ){
- echo "<br>".$a . $b . $c ."<br>";
- echo $d . $e . $f ."<br>";
- echo $g . $h . $i ."<br><br>";
- echo 'Tentantivas: '.$tries."<br>";
- $x = false;
- }else{
- $tries = $tries + 1 ;
- $x = true;
- }
- endwhile;
Add Comment
Please, Sign In to add comment