Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

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

Packages

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.

Behavior

Auto Save

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.

HTML

              
                script(src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js")
h1 Sudoku
div.container
  -var box=1
  -var x;
  while box<=9
    -x = 'box-' 
    -x += box
    
    if box==1||box==4||box==7
      -col=1
    else if box==2||box==5||box==8
      -col=4
    else
      -col=7
    
    if box<=3
      -row=1
    else if box<=6
      -row=4
    else
      -row=7
    
    - box++
    div.big-box.box(class=x)
      -r=row
      while row<=r+2
        -c=col
        while col<=c+2
          -x = 'row-' + row
          -x += ' col-' + col
          div.small-box.box(class=x)
          -col++
        -col=c
        - row++
      -row=r
.loading-screen
  .loading loading...
              
            
!

CSS

              
                @import url(https://fonts.googleapis.com/css?family=Open+Sans:100,300,400);
@import url(https://fonts.googleapis.com/css?family=Quicksand:100,300,400);
$b:1px solid #000;
$b-rad: 1em;

html{
  background:linear-gradient(180deg, #c00062 0%, #ea9600 100%);
  min-height:100%;
}
@media all and(max-width:720px){
  body{
    font-size:0.8em;
  }
}
@media all and(max-width:480px){
  body{
    font-size:0.6em;
  }
}
h1{
  font-family:"Quicksand";
  font-weight:600;
  font-size:4.5em;
  margin:auto;
  text-align:center;
  
}
.container{
  width:30em;
  margin:0em auto 2em;
  height:30em;
  border:$b;
  border-radius:$b-rad;
  box-shadow:0em 0.2em 0.5em 0.3em black;
  background:linear-gradient(180deg,
    #F973B7, #FFCE76 100%);
}
.box{
  font-family:'Open Sans';
  text-align:center;
 
  border:$b;
  float:left;
  box-sizing:border-box;
}
.big-box{
  height:10em;
  width:10em;
  border:2px solid #000;
}
.small-box{  
  padding-top:0.36em;
  font-size:1.5em;
  height:calc((100% / 3) + 1px); //for some reason it doesn't render correctly without the +1px
  width:calc(100% / 3); 
}

.box-1{
  border-top-left-radius:$b-rad;
  .row-1.col-1{
    border-top-left-radius:$b-rad/2;
  }
}
.box-3{
  border-top-right-radius:$b-rad;
  .row-1.col-9{
    border-top-right-radius:$b-rad/2;
  }
}
.box-7{
  border-bottom-left-radius:$b-rad;
  .row-9.col-1{
    border-bottom-left-radius:$b-rad/2;
  }
}
.box-9{
  border-bottom-right-radius:$b-rad;
  .row-9.col-9{
    border-bottom-right-radius:$b-rad/2;
  }
}

.loading-screen{
  position:fixed;
  top:0;
  left:0;
  height:100%;
  width:100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  resize: vertical;
  overflow: auto;
  background:rgba(200,200,200,0.7);
}
.loading{
  font-family:quicksand;
  font-size:8em;
  font-weight:300;
  color: white;
  padding: 0px;
  overflow: hidden;
  margin-top:0.6em;
  padding-bottom:0.5em;
  width:100%;
  text-align:center;
  text-shadow:0em 0em 0.2em black, 0em 0em 0.2em black, 0em 0em 0.2em black
}
              
            
!

JS

              
                
function init(){
  $(document).ready(function(){
    var theUltimate;
    var theInit = setInterval(function(){init()},20)
    var initCount = 0;
    function init(){
      $('.small-box').text('');
      function randNum(){
        return Math.ceil(Math.random()*9);
      } 
      var boxNum = new Array();
      var rowNum = new Array();
      var colNum = new Array();
      var box = {
        'box-1':[],'box-2':[],'box-3':[],
        'box-4':[],'box-5':[],'box-6':[],
        'box-7':[],'box-8':[],'box-9':[],
      }
      var row = {
        'row-1':[],'row-2':[],'row-3':[],
        'row-4':[],'row-5':[],'row-6':[],
        'row-7':[],'row-8':[],'row-9':[],
      }
      var col = {
        'col-1':[],'col-2':[],'col-3':[],
        'col-4':[],'col-5':[],'col-6':[],
        'col-7':[],'col-8':[],'col-9':[],
      }

      begin();
      function begin(){
        for(var v = 1; v <= 9; v++){
          a = fillBoxes(v);
          if(a==false){console.log("failure")}}
      }

      function fillBoxes(b){
        $('.box-'+b+' .small-box').each(function(){
          var t = $(this); 
          var x;
          var clss = t.parent().attr('class');
          boxNum = clss[16];
          var clss = t.attr('class'); 
          rowNum = clss[18];
          colNum = clss[24]; 
          x = randNum();
          i=0;

          while(box['box-'+boxNum].indexOf(x)>=0||row['row-'+rowNum].indexOf(x)>=0||col['col-'+colNum].indexOf(x)>=0) {
            i++;
            if(i>40){
              if(b<9){return init();} 
              else{fillBoxes(b);}
            } 
            x = randNum();
          } 
          box['box-'+boxNum].push(x);
           row['row-'+rowNum].push(x);
           col['col-'+colNum].push(x);
          if(i<=41)t.text(x);
          else{ 
            i=0;
            while(box['box-'+boxNum].indexOf(x)>=0||
                  row['row-'+rowNum].indexOf(x)>=0||
                  col['col-'+colNum].indexOf(x)>=0){
              i++;
              if(i>50){t.stop();return false;}
              x = randNum();
            }      
          }
          return true;
        });
      }; 
      clearInterval(theInit);
      var ck = 0;
      theUltimate = true;
      console.log('YAAAAYY');
      setTimeout(function(){
        $('.small-box').each(function(){
          var x = $(this);
          var num = Number(x.text());
        });
        removeCells();
      },300);


      function removeCells(){
        $('.small-box').each(function(){
          var x = $(this);
          var n = Math.random()*9;
          if(n<=3.5) {
            x.text('')
            x.attr('contenteditable','true');
          }
          x.css('background','none')

        })
      };
      $("*").show();
      $(".loading-screen").hide()

      checkAll();

    };

  ///////////////////////////////////////////////////////////////
  });////////////////////////////////////////////////////////////
}
init();
              
            
!
999px

Console