Start count!
Stop count!
Reset count!
00:00:00
Click the start count to record the time you spend to solve the problem.
Click the stop count to pause the timer and resume the time by click the start count.
Click the reset count and the start count to reset the timer.
Math Puzzles
数学谜题
Try to solve the problem by moving names of occupations into the boxes.
试一下!
//var n=1; //initial settings var xx=200,yy=150,P1,P2,P3,P4,P5,P6; var min1=1; var max1=1; var min2=12; var max2=50; var GONews; var grid; //counter var h=0; var m=0; var s=0; var c = 0; var t; var timer_is_on = 0; function timedCount() { s=s+1; if (s==60){ m=m+1; s=0; } if(m==60){ h=h+1; m=0; } document.getElementById("txt").innerHTML = h + ":" + m + ":" + s; if (h<10){ document.getElementById("txt").innerHTML = "0"+h + ":" + m + ":" + s; if (s<10&&m<10)document.getElementById("txt").innerHTML = "0"+h + ":0" + m + ":0" + s; if (s>10&&m<10)document.getElementById("txt").innerHTML = "0"+h + ":0" + m + ":" + s; if (s<10&&m>10)document.getElementById("txt").innerHTML = "0"+h + ":" + m + ":0" + s; }else if(m<10){ document.getElementById("txt").innerHTML = h + ":0" + m + ":" + s; if (s<10)document.getElementById("txt").innerHTML = h + ":0" + m + ":0" + s; } //c = c + 1; t = setTimeout(timedCount, 1000); } function startCount() { if (!timer_is_on) { timer_is_on = 1; timedCount(); } } function stopCount() { clearTimeout(t); timer_is_on = 0; } function resetCount() { clearTimeout(t); timer_is_on = 0; s=0; m=0; h=0; document.getElementById("txt").innerHTML = "00:00:00"; } function setHTML(id,text){ var e=document.getElementById(id); if (e==null) return; e.innerHTML=text; } function showHint() { if (hButton.sel===0) return; var str; if (lang==0){ str="Start from Mr. Carpenter, you should be able to logically derive the occupations of each of them."; }else{ str="从木匠先生开始,然后你会逻辑推导出他们每个人的职业.."; } hButton.hText.text=str; hButton.hText.draw(ctx); } function gravity (x){ x=Math.floor(x/50)*50; return x+25; } class Movable { static DOWN=1; static UP=2; static mouse=2; static x1=0; static y1=0; static ctx; static list=new Array(); static list1=new Array(); static list2=new Array(); static selected=null; constructor(x,y){ this.x0=x; this.y0=y; this.fixed=false; } inside(x,y){ return true; } draw (ctx1){ ; } move (e){ if (this.fixed==true) return; var dx=e.offsetX-Movable.x1; var dy=e.offsetY-Movable.y1; this.x0+=dx; this.y0+=dy; Movable.x1=e.offsetX; Movable.y1=e.offsetY; this.draw(Movable.ctx); } fixPosition(x,y){ this.x0=x; this.y0=y; this.fixed=true; } static mouseUp() { Movable.mouse=Movable.UP; /*if (Movable.selected!=null){ Movable.selected.x0=gravity(Movable.selected.x0)+25; Movable.selected.y0=gravity(Movable.selected.y0)+25; }*/ } static mouseDown(e) { Movable.mouse=Movable.DOWN; Movable.x1=e.offsetX; Movable.y1=e.offsetY; } static isMouseDown() { if (Movable.mouse==Movable.DOWN) return true; return false; } static isInside (e){ for (var i=0;i
=0 && x<=this.w && y>=0 &&y<=this.h) return true; return false; } draw (ctx){ /*ctx.fillStyle="blue"; ctx.fillRect(this.x0, this.y0, this.w, this.h); ;*/ ctx.strokeStyle=this.color; ctx.beginPath(); ctx.rect(this.x0, this.y0, this.w,this.h); ctx.stroke(); } } class MyRectText extends MyRect2 { constructor (txt,x,y,w,h){ super (x,y,w,h); //this.w=w; //this.h=h; this.text=txt; } inside(x,y){ x-=this.x0; y-=this.y0; if(x>=0 && x<=this.w && y>=0 &&y<=this.h) return true; return false; } draw (ctx){ /*ctx.fillStyle="blue"; ctx.fillRect(this.x0, this.y0, this.w, this.h); ;*/ ctx.strokeStyle=this.color; ctx.beginPath(); ctx.rect(this.x0, this.y0, this.w,this.h); ctx.stroke(); ctx.fillStyle="black"; ctx.fillText(this.text,this.x0+this.w/2, this.y0+this.h/2); } } class MyCircle extends Movable { constructor (xx,y,r,id){ super (xx,y); this.r=r; //this.h=h; this.id=id; } setlocation (x,y){ this.x0=x; this.y0=y; } inside(x,y){ if(this.fixed==true) return false; x-=this.x0; y-=this.y0; var r=this.r; if((x*x+y*y)<(r*r)) return true; return false; } /*move (e){ var x=Math.floor(e.offsetX/50)*50; var y=Math.floor(e.offsetY/50)*50; //var dx=e.offsetX-Movable.x1; //var dy=e.offsetY-Movable.y1; super.move(e); var dx=x-Movable.x1; var dy=y-Movable.y1; this.x0+=dx; this.y0+=dy; Movable.x1=e.offsetX; Movable.y1=e.offsetY; this.draw(Movable.ctx); var newx0=this.x0-300; var newy0=this.y0-200; var angleP=Math.atan2(newy0,newx0); this.x0=300+75*Math.cos(angleP); this.y0=200+75*Math.sin(angleP); }*/ draw (ctx){ ctx.strokeStyle="brown"; ctx.beginPath(); ctx.fillStyle="red"; if (this.fixed==true) ctx.fillStyle="black"; ctx.font="20px Arial"; ctx.textAlign = "center"; ctx.fillText(""+this.id,this.x0, this.y0+0); //if (Math.abs(this.x0-200)<=50 &&Math.abs(this.y0-300)<=50) ctx.fillText(""+this.id,this.x0+300, this.y0+17); //if (Math.abs(this.x0-300)<=50 &&Math.abs(this.y0-300)<=50) ctx.fillText(""+this.id,this.x0+300, this.y0+17); //if (Math.abs(this.x0-400)<=50 &&Math.abs(this.y0-300)<=50) ctx.fillText(""+this.id,this.x0+300, this.y0+17); ctx.stroke(); } } class MyContainer { constructor (x,y,r,type, color){ //constructor (x,y,w, h,color){ this.x0=x; this.y0=y; this.r=r; this.type=type; this.color=color; } inside(x,y){ x-=this.x0; y-=this.y0; var r=this.r; if((x*x+y*y)<(r*r)) return true; return false; } draw (ctx){ ctx.strokeStyle=this.color; ctx.beginPath(); ctx.arc(this.x0, this.y0, this.r,0,2*Math.PI); ctx.stroke(); } isOK(n){ if (this.inside(n.x0,n.y0)==false) return 0; var re=0; switch (this.type) { case 1: if (n.id%2==1) re= 1; break; case 2: if (n.id%2==0) re= 1; break; case 3: if (n.id%3==0) re= 1; break; } } } function doMouseDown(event) { //alert("mouse is down"); //var m=document.getElementById("mouseInfo"); //m.innerHTML="mouse is down"; Movable.mouseDown(event); Movable.isInside(event); } function doMouseUp(event) { if (hButton.inside(event.offsetX, event.offsetY)===true) redraw(ctx); //alert("mouse is up"); //var m=document.getElementById("mouseInfo"); //m.innerHTML="mouse is up"; Movable.mouseUp(); //Movable.positionOK(); var inGrid=0; for (var i=0;i
3) { // ?p=min1,max1,min2,max2 var s=paraStr.substring(3).split(/[=,]+/); // alert(paraStr+" s[0]="+s[0]+" s["+(s.length-1)+"]="+s[s.length-1]); if (s.length==2) { //N=parseInt(s[0]); //min1=parseInt(s[0]); //max1=parseInt(s[1]); //min2=parseInt(s[2]); //max2=parseInt(s[3]); } // alert("min1="+min1+" "+max1+" "+min2+" "+max2); } var hButton = new ToggleButton((canvas.width>>1)-100,canvas.height-30,200,30,"Show Hint", "Hide Hint",ctx,"green"); hButton.visible=true; hButton.hText=new MyTextArea(500,350,300,"this is the hint","20px Arial","blue"); getRandomPara(); redraw(ctx); showOrHide('foot',lang); showOrHide('title1',lang); showOrHide('title2',lang); showOrHide('title3',lang); ) processed by MyLexV4 -->