Results 1 to 3 of 3

Thread: N Queens Problem with Javascript

Hybrid View

  1. #1
    Join Date
    Apr 2013

    Cool N Queens Problem with Javascript

    hi, I am new to this javascript language , and I have an assignement to do, place N queens in an N x N chess without conflicts, I hope someone could guide me as how to start making this application .thnx

  2. #2
    Join Date
    Oct 2010
    Versailles, France
    Create a new object Board with cells (an unidimensional Array is sufficient), rows, cols and diagonals (use the quotients, remainders and their sums and differences) and a method place that update the occupied lines, cols and diagonals.

    Then build a recursive searchPlace method that search the first empty line, row and diagonals or return (if the eighth queens is not in place) at the preceding step to try the following empty line, row and diagonals...

  3. #3
    Join Date
    Apr 2013
    hi everyone i got a problem with my index.php file , i cant find the error in the file , can someone please help me

    if (navigator.appName == "Microsoft Internet Explorer") { document.location = "FILL RE-DIRECT LINK HERE! ex. iehome.php";

    <? include("inc/incfiles/header.inc.php");?>
    $reg= @$_POST('reg');
    //declaring variables to prevent errors
    $fn =""; //First Name
    $ln=""; //Last Name
    $un=""; // Username
    $em=""; // Email
    $em2=""; //Email2
    $pswd=""; //Password
    $pswd2=""; //Password2
    $d=""; // Sign Up Date
    $u_check=""; // Check if username exists
    // Registration Form
    $fn= strip_tags(@$_POST['fname']);
    $ln= strip_tags(@$_POST['lname']);
    $un= strip_tags(@$_POST['username']);
    $em= strip_tags(@$_POST['email']);
    $em2= strip_tags(@$_POST['email2']);
    $pswd= strip_tags(@$_POST['password']);
    $pswd2= strip_tags(@$_POST['password2']);
    $d= date("Y-m-d"); // Year-Month-Day

    if ($reg){
    if ($em=$em2) {
    // Check if user already exists
    $u_check= mysql_query("SELECT username FROM users WHERE username='$un'");
    // Count the amount of rows where username = $un
    $check= mysql_num_rows($u_check);
    if ($check ==0) {
    // check all of the fields have been filed in
    if ($fn&&$ln&&$em&&$em2&&$pswd&&$pswd2) {
    // checks that password matches
    if ($pswd==$pswd2) {
    //checks the username/first name/last name does not exceeed 25 characters
    if (strlen($un)> 25 || strlen($fn)> 25 || strlen($ln)> 25 ) {
    echo "The maximum limit for username/first name /last name is 25 characters!";
    // check the maximum length of password does not exceed 25 characters and is not less than 5 chracters
    if (strlen($pswd)>30 || strlen($pswd)< 5) {
    echo" Your password must be between 5 and 30 characters long!";
    //encrypt the password and the password2 using md5 before sending the database
    $pswd=md5 ($pswd2);
    $query= mysql_query("INSERT INTO users VALUES ('','$un','$fn','$ln','$em','$pswd','$d','0')");
    die ("<h2> Welcome to Funtimeout.com</h2> Login to your account to get started...");
    else {
    echo "Your passwords dont match!";
    echo "Please fill in all the fields...";
    echo" Username already taken...";
    echo "Your E-mails dont match!";

    //Starts the session
    //checks whether the user is logged in or not

    if (!isset($_SESSION["user_login"])); {



    //Login Script
    if(isset($_POST["user_login"]) && isset($_POST["password_login"])) {
    $user_login = preg_replace('#[^A-Za-z0-9]#i','',$_POST["user_login"]);//filter everything
    $password_login = preg_replace('#[^A-Za-z0-9]#i','',$_POST["password_login"]);//filter everything but numbers and letters
    $sql = mysql_query("SELECT id FROM users WHERE username='$user_login' AND password='$md5password_login' LIMIT 1");// query the person

    //Check for their existence

    $userCount= mysql_num_rows($sql); //Count the number of rows returned
    if($userCount==1) {

    exit("<meta http-equip=\"refresh\"0>\");
    echo 'The information is incorrect, try again';
    <div id="wrapper">
    <br />
    <br />
    <br />
    <br />

    <div style="float:left">

    <table class="homepageTable>

    <td width="60%" valign="top">
    <h2> Already a Member ? Login below ... </h2>
    <form action="index.php" method="post" name="form1" id="form1">
    <input type="text" size="25" name ="user_login" id="user_login" placeholder"username"/>
    <input type="password" size="25" name ="password_login" id="password_login" placeholder"password"/><br/>
    <input type="submit" name="button" id="button" placeholder="Login to your account"">
    <td width="40%" valign="top">
    <h2> Sign Up below... </h2>
    <form action="#" method="post">
    <input type="text" size"25" name="fname" placeholder="First Name" value="<? echo $fn; ?>">
    <input type="text" size"25" name="lname" placeholder="Last Name" value="<? echo $ln; ?>">
    <input type="text" size"25" name="username" placeholder="Username"value="<? echo $un; ?>">
    <input type="text" size"25" name="email" placeholder="Email" value="<? echo $em; ?>">
    <input type="text" size"25" name="email2" placeholder="Repeat Email" value="<? echo $em2; ?>">
    <input type="password" size"25" name="password" placeholder="Password"">
    <input type= "password" size"25" name="password2" placeholder="Repeat Password"">
    <input type="submit" name="reg" placeholder="Sign Up"">


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center