Return to Snippet

Revision: 1309
at September 27, 2006 11:02 by gdonald


Updated Code
#!/usr/bin/php
<?php

    for ($x=1;$x < 10; $x++) {
        for ($y=1;$y < 10; $y++) {
            for ($z=1;$z < 10; $z++) {
                if (($x + $y + $z == 15) && (($x != $y) && ($x != $z) && ($y != $z))) {

        for ($a=1;$a < 10; $a++)
        for ($b=1;$b < 10; $b++)
        for ($c=1;$c < 10; $c++)
                if (($a + $b + $c == 15) && (($a != $b) && ($a != $c) && ($b != $c)))    
        for ($i=1;$i < 10; $i++)
        for ($o=1;$o < 10; $o++)
        for ($p=1;$p < 10; $p++)
                if (($i + $o + $p == 15) && (($i != $o) && ($i != $p) && ($o != $p)))    
        if (($x + $a + $i == 15) && (($x != $a) && ($x != $i) && ($a != $i))) 
        if (($y + $b + $o == 15) && (($y != $b) && ($y != $o) && ($b != $o))) 
        if (($z + $c + $p == 15) && (($z != $c) && ($z != $p) && ($c != $p)))
        if (($x != $b) && ($x != $c) && ($x != $o) && ($x != $p))
        if (($y != $a) && ($y != $i) && ($y != $c) && ($y != $p))
        if (($z != $b) && ($z != $a) && ($z != $o) && ($z != $i)) {
            echo "$x $y $z\n";
            echo "$a $b $c\n";
            echo "$i $o $p\n\n";
            flush();
        //return;
        }
                }
            }
        }
    }
    
?>

Revision: 1308
at September 27, 2006 11:02 by gdonald


Initial Code
#!/usr/bin/php
<?php

    for ($x=1;$x < 10; $x++) {
        for ($y=1;$y < 10; $y++) {
            for ($z=1;$z < 10; $z++) {
                if (($x + $y + $z == 15) && (($x != $y) && ($x != $z) && ($y != $z))) {

        for ($a=1;$a < 10; $a++)
        for ($b=1;$b < 10; $b++)
        for ($c=1;$c < 10; $c++)
                if (($a + $b + $c == 15) && (($a != $b) && ($a != $c) && ($b != $c)))    
        for ($i=1;$i < 10; $i++)
        for ($o=1;$o < 10; $o++)
        for ($p=1;$p < 10; $p++)
                if (($i + $o + $p == 15) && (($i != $o) && ($i != $p) && ($o != $p)))    
        if (($x + $a + $i == 15) && (($x != $a) && ($x != $i) && ($a != $i))) 
        if (($y + $b + $o == 15) && (($y != $b) && ($y != $o) && ($b != $o))) 
        if (($z + $c + $p == 15) && (($z != $c) && ($z != $p) && ($c != $p)))
        if (($x != $b) && ($x != $c) && ($x != $o) && ($x != $p))
        if (($y != $a) && ($y != $i) && ($y != $c) && ($y != $p))
        if (($z != $b) && ($z != $a) && ($z != $o) && ($z != $i)) {
            echo "$x $y $z\n";
            echo "$a $b $c\n";
            echo "$i $o $p\n\n";
            flush();
        //return;
        }
                }
            }
        }
    }
    
?>

Initial URL

                                

Initial Description

                                

Initial Title
PHP sudoku solver

Initial Tags

                                

Initial Language
PHP