Created
December 13, 2012 15:43
-
-
Save Marlinc/4277265 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$peuken = 4 + 4 + 16 + 13; | |
$sigarreten = 2 + 9; | |
$gerookt = 0; | |
echo "Sigaretten: " . $sigarreten . " - Peuken: " . $peuken . " - Gerookt: " . $gerookt . PHP_EOL; | |
while (true) { | |
// Bij 3 peuken: 1 sigaret maken | |
if ($peuken >= 3) { | |
$sigarreten += 1; | |
$peuken -= 3; | |
echo "Sigaretten: " . $sigarreten . " - Peuken: " . $peuken . " - Gerookt: " . $gerookt . PHP_EOL; | |
usleep(250000); | |
continue; | |
} | |
// Bij 1 sigaret: 1 roken en 1 peuk overhouden | |
if ($sigarreten >= 1) { | |
$gerookt += 1; | |
$sigarreten -= 1; | |
$peuken += 1; | |
echo "Sigaretten: " . $sigarreten . " - Peuken: " . $peuken . " - Gerookt: " . $gerookt . PHP_EOL; | |
usleep(250000); | |
continue; | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
while (true) { | |
// Maak alles klaar | |
$nummers = array(1, 2, 3, 4, 5, 6); | |
$voorX = ""; | |
$naX = ""; | |
$uitkomst = ""; | |
// Zet nummers in andere volgorde | |
shuffle($nummers); | |
// Neem 1 nummer voor het cijfer voor de keer | |
for ($i = 1; $i <= 1; ++$i) { | |
$voorX .= array_pop($nummers); | |
} | |
// Neem 2 nummer voor het cijfer na de keer | |
for ($i = 1; $i <= 2; ++$i) { | |
$naX .= array_pop($nummers); | |
} | |
// Neem 3 nummer voor het cijfer als uitkomst | |
for ($i = 1; $i <= 3; ++$i) { | |
$uitkomst .= array_pop($nummers); | |
} | |
// Kijk of de som klopt | |
if (($voorX * $naX) == $uitkomst) { | |
echo $voorX . " X " . $naX . " = " . $uitkomst . PHP_EOL; | |
break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment