473,398 Members | 2,113 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

What does whichkey>=48...<= 57 mean in a 3x3 sudoku game?

tpgames
785 512MB
In a 3x3 sudoku JavaScript with images, what is 48? and 57?
I'm trying to convert a 3x3 sudoku to a 2x2. I don't understand why 48 can't be say, 46 or 45; why 57 can't be 54, etc. Its the numbers I don't understand.

Expand|Select|Wrap|Line Numbers
  1. function KeyDown(whichkey)
  2. { if (IsOver) return;
  3.   if (I_Sel==-1) return;
  4.   if ((whichkey>=48)&&(whichkey<=57))
  5.   { Fld[I_Sel][J_Sel][K_Sel][L_Sel]=48-whichkey;
  6.     window.document.images[4*I_Sel+4*J_Sel+K_Sel+2*L_Sel].src = NPic[whichkey-48].src;
  7.     I_Sel=-1;
  8.   }
  9.    if (IsSolved())
  10.   { IsOver=true;
  11.     Now = new Date();
  12.     EndTime = Now.getTime() / 1000;
  13.     i=Math.floor(EndTime - StartTime);
  14.     if (window.opener)
  15.     { if (window.opener.SetHighscores)
  16.         window.opener.SetHighscores("Sudoku","",i,-1);
  17.     }
  18.     alert("Super, you solved this game in "+i+ " seconds !");
  19.   }
  20. }  
Thanks!
Mar 5 '07 #1
2 1858
ronverdonk
4,258 Expert 4TB
I would strongly advise you to follow some JavaScript tutorial on DOM and events before you continue with adapting that game. Because otherwise it is going to take you a very long time to get it right!

Statement if ((whichkey>=48)&&(whichkey<=57)) is simply testing the value of the key that is pressed.

Here it tests for a key greater or equal to 0 (zero, of which the decimal equivalent is 48) and a key lower or equal to 9 (nine, of which the same is 57).

So you see, you cannot just change these values to whatever you like it to be!

Ronald :cool:
Mar 5 '07 #2
iam_clint
1,208 Expert 1GB
soduko is a challenging game and to write code to play the game is also challenging this is not novice coding



For those that don't know heres how soduko works


say you have 18 squares (some already have numbers in them locked)

for each 6 squares you have to put numbers 1 - 6... 2 of the same number cant be in that column or row and not in the 6 block area... the challenge is to complete all the blocks.
Mar 5 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Arne Schirmacher | last post by:
I want to display a MySQL database field that can contain HTML markup. If I use <esql:get-string> then I get all of the database field, but all tags are escaped which is not what I want. If I use...
15
by: Mattia | last post by:
Hi! I have a <form> that can be submitted thruogh three buttons and I need to tell witch one was pressed when the form was submitted. I now do it with 3 <input type="submit" name="..."...
129
by: Torbjørn Pettersen | last post by:
I've started cleaning up my HTML and implementing CSS. So far I've used FrontPage, but am switching over to DreamWeaver. Reading a bit on W3Schools.com and W3.org I see there are a lot of HTML...
61
by: Toby Austin | last post by:
I'm trying to replace <table>s with <div>s as much as possible. However, I can't figure out how to do the following… <table> <tr> <td valign="top" width="100%">some data that will...
14
by: slim | last post by:
hi all, whilst creating a mock-up site, i am trying to follow the rules and guidelines i have been digesting over the last few months with regards to css positioning and accessibility. well,...
0
by: trexim | last post by:
Hi, I have a rpc operation in my WSDL: <operation name="My-Function"> <documentation>Some misc function of mine</documentation> <input message="tns:myFunctionRequest"/> <output...
4
by: David Lozzi | last post by:
Howdy, I'm using a WYSIWYG editor called TinyMCE. When I edit some text and then save it back to my SQL server using a SQLCommand, all HTML characters are changed to HTML code, i.e. &gt;strong&lt;...
2
by: needin4mation | last post by:
I was looking at this code, and have seen it in other code (like it): /// <summary> /// Bitmap font class for XNA /// </summary> public class BitmapFont { private SpriteBatch m_sb; private...
1
by: Shuzhen | last post by:
Hello, I came across this expression in C++ code "a >?= b". Would anyone know what this means? Thanks!
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.