Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7188657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:07:59+00:00 2026-05-28T19:07:59+00:00

My code works perfectly on my computer, on all my browsers (including ie), But

  • 0

My code works perfectly on my computer, on all my browsers (including ie), But I can’t manage to make it work on jsFiddle.

The problem seems to be on:

    window.onload=function(){
        document.body.innerHTML+=brd+log;
    }

But I have tried both with and without the window.onload. I am totally clueless and I am starting to lose all hope

CSS (optional):

        *{margin:0;padding:0;}
        #brd{margin:15px auto;}
        #brd,#brd td,#log{border:1px solid #000;}
        #brd td{height:47px;width:45px;text-align:center;font-size:30px;}
        #brd span{font-size:12px;}
        #log{margin:15px auto;padding:20px;width:385px;max-height:150px;overflow:auto;background:#F0F0F0;color:#000;}

JavaScript:

        var i,sdk,rem,log,perf,brd,bxes=[["11","12","13","21","22","23","31","32","33"],["14","15","16","24","25","26","34","35","36"],["17","18","19","27","28","29","37","38","39"],["41","42","43","51","52","53","61","62","63"],["44","45","46","54","55","56","64","65","66"],["47","48","49","57","58","59","67","68","69"],["71","72","73","81","82","83","91","92","93"],["74","75","76","84","85","86","94","95","96"],["77","78","79","87","88","89","97","98","99"]];

        /*Array Find*/
        function arrFind(fnd,frm,bol){
            var ii,len,rtn=-1;

            for(ii=0,len=frm.length;ii<len;ii++){
                if(frm[ii]==fnd){
                    rtn=ii;
                    break;
                }
            }
            return bol?rtn>-1:rtn;
        }

        /*To RC*/
        function toRC(val){
            var ii,len,aa=[];

            val=val.split(",");

            for(ii=0,len=val.length;ii<len;ii++){
                aa.push(Math.ceil((parseInt(val[ii])+1)/9)+""+((parseInt(val[ii])%9)+1));
            }

            return aa.join(",");
        }

        /*To AV*/
        function toAV(rc){
            var ii,len,aa=[];

            rc=rc.split(",");

            for(ii=0,len=rc.length;ii<len;ii++){
                aa.push((((parseInt(rc[ii].charAt(0))-1)*9)+(parseInt(rc[ii].charAt(1))-1))+"");
            }

            return aa.join(",");
        }

        /*Get Box*/
        function getBox(av,bol){
            var ii,jj,len,ss,zz,aa=[];

            if(!bol){
                av=toRC(av);
            }

            av=av.split(",");

            for(ii=0,len=av.length;ii<len;ii++){
                ss=av[ii];
                for(jj=0;jj<9;jj++){
                    zz=window.bxes[jj];
                    if(arrFind(ss,zz,true)){
                        aa.push(zz);
                        break;
                    }
                }
            }

            return aa.join(",");
        }

        /*Get Row*/
        function getRow(av,bol){
            var ii,len,ss,aa=[];

            if(!bol){
                av=toRC(av);
            }

            av=av.split(",");

            for(ii=0,len=av.length;ii<len;ii++){
                ss=av[ii].charAt(0);
                aa.push(ss+"1",ss+"2",ss+"3",ss+"4",ss+"5",ss+"6",ss+"7",ss+"8",ss+"9");
            }

            return aa.join(",");
        }

        /*Get Column*/
        function getCol(av,bol){
            var ii,len,ss,aa=[];

            if(!bol){
                av=toRC(av);
            }

            av=av.split(",");

            for(ii=0,len=av.length;ii<len;ii++){
                ss=av[ii].charAt(1);
                aa.push("1"+ss,"2"+ss,"3"+ss,"4"+ss,"5"+ss,"6"+ss,"7"+ss,"8"+ss,"9"+ss);
            }

            return aa.join(",");
        }

        /*Get Value*/
        function getVal(av,bol){
            var ii,len,ss,aa=[];

            if(bol){
                av=toAV(av);
            }

            av=av.split(",");

            for(ii=0,len=av.length;ii<len;ii++){
                ss=window.sdk[parseInt(av[ii])];
                if(ss.length==1){
                    aa.push(ss);
                }
            }

            return aa.join(",");
        }

        /*Get Candidates*/
        function getCand(av,bol){
            var ii,len,ss,zz,aa=["1","2","3","4","5","6","7","8","9"];

            if(bol){
                av=toAV(av);
            }

            if(window.sdk[parseInt(av)].length==1){
                return [];
            }

            zz=getVal(getBox(av)+","+getRow(av)+","+getCol(av),true).split(",");

            for(ii=0,len=zz.length;ii<len;ii++){
                ss=arrFind(zz[ii],aa);
                if(ss>-1){
                    aa.splice(ss,1);
                }
            }

            return aa.join(",");
        }

        /*New Sudoku*/
        function newSudoku(str){
            var ii,len,ss;

            window.perf=new Date().getTime();
            window.log="";
            window.sdk=[];
            window.rem=[];

            for(ii=0,len=str.length;ii<len;ii++){
                ss=str.charAt(ii);
                if(ss!="0"){
                    window.log+=ss+" on "+toRC(ii+"")+"<br>";
                    writeNumber(ss,ii+"");//wn
                }else{
                    window.sdk[ii]=[];
                    window.rem.push(ii+"");
                }
            }
        }

        /*Write Number*/
        function writeNumber(val,av,bol){
            if(bol){
                av=toAV(av);
            }

            window.sdk[parseInt(av)]=[val];
            return delCand(val,av);
        }

        /*Delete Candidates*/
        function delCand(val,av,bol){
            var ii,jj,len,jen,ss,zz,cc,xx,xo,dd=[];

            if(bol){
                av=toAV(av);
            }

            zz=toRC(av);

            xx=new RegExp(","+zz+",","g");//below bol

            ss=toAV((getBox(av)+","+getRow(av)+","+getCol(av)).replace(xx,",").replace(zz+",","").replace(","+zz,"")).split(",");

            for(ii=0,len=ss.length;ii<len;ii++){
                cc=window.sdk[ss[ii]];
                if(!cc||cc.length<2){
                    continue;
                }
                zz=arrFind(val,cc);
                if(zz>-1){
                    window.sdk[parseInt(ss[ii])].splice(zz,1);
                    if(window.sdk[parseInt(ss[ii])].length==1){

                        window.log+=window.sdk[parseInt(ss[ii])][0]+" on "+toRC(ss[ii])+"<br>";
                        xo=delCand(window.sdk[parseInt(ss[ii])][0],ss[ii]);//wn

                        jen=xo.length;
                        if(jen>0){
                            for(jj=0;jj<jen;jj++){
                                dd.push(xo[jj]);
                            }
                        }
                        dd.push(ss[ii]);
                    }
                }
            }
            return dd;
        }

        /*Delete Remaining*/
        function delRem(arr){
            var ii,len,ss;

            for(ii=0,len=arr.length;ii<len;ii++){
                ss=arrFind(arr[ii],window.rem);
                if(ss>-1){
                    window.rem.splice(ss,1);
                }
            }
        }

        /*Solve Sudoku*/
        function solSudoku(){
            var ii,jj,ll,yy,len,jen,ss,zz,cc,dd,xo;

            for(ll=0;ll<1;ll++){

                dd=[];
                for(ii=0,len=window.rem.length;ii<len;ii++){

                    zz=window.sdk[parseInt(window.rem[ii])];

                    if(zz.length==0){
                        ss=getCand(window.rem[ii]).split(",");

                        if(ss.length==1&&ss[0]!=""){

                            window.log+=ss[0]+" on "+toRC(window.rem[ii])+"<br>";
                            xo=writeNumber(ss[0],window.rem[ii]);//wn

                            jen=xo.length;
                            if(jen>0){
                                for(yy=0;yy<jen;yy++){
                                    dd.push(xo[yy]);
                                }
                            }
                            dd.push(window.rem[ii]);

                            ll=-1;
                        }else{
                            if(ss.length>1){
                                window.sdk[parseInt(window.rem[ii])]=ss;
                            }
                        }
                    }else if(zz.length==1){
                        alert("solSudoku warning");
                        dd.push(window.rem[ii]);
                    }
                }
                delRem(dd);
            }
            if(window.rem.length!=0){
                //failed to solve by simple solving
                //start advanced solving
            }
        }

        //============================================================================

        newSudoku("032060007000008290000509000000300016800000002610002000000405000045800000700010530");

        solSudoku();
        //000124039007093056390000200040708000008050400000201060005000078270980300980517000
        //032060007000008290000509000000300016800000002610002000000405000045800000700010530


        //delCand("5","55",true);

        //alert("["+sdk.join("][")+"]");

        log+="--- Time: "+(new Date().getTime()-perf)+" milliseconds ---";

        brd="<table id=\"brd\" cellpadding=\"0\" cellspacing=\"0\"><tbody><tr>";

        for(i=0;i<sdk.length;i++){
            if(i%9==0){
                if(i!=0&&i!=80){
                    brd+="</tr><tr>";
                }
            }
            if(sdk[i].length==0){
                brd+="<td>&nbsp;</td>";
            }
            if(sdk[i].length==1){
                brd+="<td>"+sdk[i]+"</td>";
            }
            if(sdk[i].length>1){
                brd+="<td><span>"+sdk[i].join(" ")+"</span></td>";
            }
        }

        brd+="</tr></tbody></table>";
        log="<div id=\"log\">"+log+"</div>";

        window.onload=function(){
            document.body.innerHTML+=brd+log;
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T19:08:01+00:00Added an answer on May 28, 2026 at 7:08 pm

    It works ok, see here

    PS: You should select the no wrap (head) option.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently have a problem that my java code works perfectly ok on my
I have the following code which works perfectly, but I want to allow access
I have some code here which works perfectly in firefox but not in chrome
The following piece of code works perfectly in script/console but returns the following error
The following javascript code works perfectly in Opera(v10.5x), but fails miserably in Firefox(v3.6) and
I developed an office tool and it works perfectly in my computer. But when
This code works perfectly in Ubuntu, Windows, and Mac OS X. It also works
This code works perfectly except when you click on a link, The page is
The following code works perfectly. public class StaticClass { public static void main(String[] args)
I am using ASP.NET to transmit a .jar file. This code works perfectly on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.