Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.




    margin:50px auto;
  border-radius: 25px;


                var lignes = [0,0,0,0,0,0,0,0,0,0]; // dix lignes vides
var pieces = ["1","1","1","1","11","11","11","111","111","1111","11111"]; // mes pièces
var colors = ["#F60","#60F","#556","#112","#ccd"]; // mes couleurs
var ligneWidth = 10; // la longueur des lignes
var loop = 500; // le nombre d'itérations

/* un chiffre entier entre 0 et max-1 */
function getRandomInt(max) {
  return Math.floor(Math.random() * Math.floor(max));

/* une valeur random du tableau */
function getRandom(arr){ 
  var max = (arr.length);
  var randIndex = getRandomInt(max);
  return arr[randIndex];

/* test, placement x/y et couleur */
function construire(ligne,piece,color,x){
  if(ligneWidth - x - piece.length<0) {
    return false; // ça dépasse en x, on sort de la function
  var pieceInti = parseInt(piece,2) << (ligneWidth - x - piece.length); // on ajoute des 0 selon x -> 111000000
  var ligneInt = parseInt(lignes[ligne],2); // la ligne "000011100000" en chiffre
  if((pieceInti | ligneInt) !== (pieceInti ^ ligneInt)){ // test de la place
    return false;  // pas de place, on sort
  lignes[ligne] = (pieceInti | ligneInt).toString(2); // mise à jour de la ligne 
  /* dessin et coloriage */
  var el = document.createElement("div"); = color; = (x+1)+" / span "+piece.length; = ligne+1 + " / span 1";  

/* on lance n fois */
for(var i = 0;i<loop;i++ ){
  var l = getRandomInt(10);
  var c = getRandom(colors);
  var p = getRandom(pieces);
  var x = getRandomInt(ligneWidth);