Alexander Brock: welche Farben gibt es mit #....

Beitrag lesen

Hallo Gunnar,

Davon gibt es 2^24, etwa 16 Millionen. Sie jetzt alle aufzuzählen, führe zu weit.

Wieso denn? Johanna muss doch nur folgendes Script ausführen:

<?php
header("Content-Type: text/html; charset=utf-8");
ob_start("ob_gzhandler");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
 <head>
  <title>
   Alle Farben, die der Monitor darstellen kann
  </title>
  <style type="text/css">
   div {
    text-align: middle;
    min-width: 3.8em;
   }
  </style>
 </head>
 <body>
  <div>
<?php
$hex4 = array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f");

$hex8 = array();

foreach ($hex4 as $value1) {
 foreach ($hex4 as $value2) {
  $hex8[] = $value1.$value2;
 }
}

foreach ($hex8 as $value1) {
 foreach ($hex8 as $value2) {
  echo '<div style="float:left">';
  foreach ($hex8 as $value3) {
   echo '<div style="background-color:#'.$value1.$value2.$value3.'">#'.$value1.$value2.$value3.';</div>
   ';
  }
  echo '</div>';
 }
}

?>
  </div>
 </body>
</html>

Und schon bekommt sie eine ~750 MB große HTML-Ausgabe,
in der wunderhübsch alle Farben in einer Tabellen-ähnlichen
Form gelistet sind.

Oder, wenn sie heute noch fertig werden will:

<?php
header("Content-Type: text/html; charset=utf-8");
ob_start("ob_gzhandler");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
 <head>
  <title>
   Alle Farben, die der Monitor darstellen kann
  </title>
  <style type="text/css">
   div {
    text-align: middle;
    min-width: 3.8em;
   }
  </style>
 </head>
 <body>
  <div>
<?php
$hex4 = array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f");

$hex4 = array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f");

$hex8 = array();

#foreach ($hex4 as $value1) {

foreach ($hex4 as $value2) {

#  $hex8[] = $value1.$value2;

}

#}

$hex8 = $hex4;

foreach ($hex8 as $value1) {
 foreach ($hex8 as $value2) {
  echo '<div style="float:left">';
  foreach ($hex8 as $value3) {
   echo '<div style="background-color:#'.$value1.$value2.$value3.'">#'.$value1.$value2.$value3.';</div>
   ';
  }
  echo '</div>';
 }
}

?>
  </div>
 </body>
</html>

Das erzeugt eine 200KB große Ausgabe dauert nur eine Sekunde.

Gruß
Alexander Brock

--
SelfCode: ie:{ fl:( br:> va:) ls:[ fo:) rl:( n4:? ss:| de:> js:( ch:| sh:( mo:} zu:}
http://againsttcpa.com