background preloader

Code and Programming

Facebook Twitter

Non Recursive Implementation Algorithm.. The binary numbers, considered in numerical order, comprise a set of sequential moves that will allow you to solve the game of the Tower of Hanoi with the minimum number of moves, specifically 2n - 1 where n is the number of disks.

Non Recursive Implementation Algorithm..

Each binary number is read from the right until the first "1" is encountered. The position of that "1" from the right indicates the disk to move. If there is no other "1" in the binary number, that disk is moved to an empty peg. The second "1" from the right indicates the location of the reference disk. A few examples for five disks follow: The table below lists the 25- 1 = 31 sequential moves required for a tower with five disks. Dear Guest, Spend a minute to Register in a few simple steps, for complete access to the Social Learning Platform with Community Learning Features and Learning Resources.

Linux

We Are Typists First, Programmers Second. Remember last week when I said coding was just writing?

We Are Typists First, Programmers Second

I was wrong. As one commenter noted, it's even simpler than that. [This] reminds me of a true "Dilbert moment" a few years ago, when my (obviously non-technical) boss commented that he never understood why it took months to develop software. "After all", he said, "it's just typing. " Like broken clocks, even pointy-haired managers are right once a day. So if you want to become a great programmer, start by becoming a great typist. I can't understand why professional programmers out there allow themselves to have a career without teaching themselves to type. I had a brief email exchange with Steve back in March 2007, after I wrote Put Down The Mouse, where he laid that very same Reservoir Dogs quote on me. I was trying to figure out which is the most important computer science course a CS student could ever take, and eventually realized it's Typing 101.The really great engineers I know, the ones who build great things, they can type.

PHP Login script tutorial. We have a login form in step 2, when a user submit their username and password, PHP code in checklogin.php will check that this user exist in our database or not.

PHP Login script tutorial

If user has the right username and password, then the code will register username and password in the session and redirect to "login_success.php". If username or password is wrong the system will show "Wrong Username or Password". ############### Code $host="localhost"; // Host name $username=""; // Mysql username $password=""; // Mysql password $db_name="test"; // Database name $tbl_name="members"; // Table name mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; (more detail about MySQL injection) $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword);

15 very useful PHP code snippets for PHP developers. Following are list of 15 most useful PHP code snippets that a PHP developer will need at any point in his career.

15 very useful PHP code snippets for PHP developers

Few of the snippets are shared from my projects and few are taken from useful php websites from internet. You may also want to comment on any of the code or also you can share your code snippet through comment section if you think it may be useful for others. 1. Send Mail using mail function in PHP 2. 3. The above code will not work in case your client is behind proxy server. 4. This function will return the duration of the given time period in days, hours, minutes and seconds. e.g. secsToStr(1234567) would return “14 days, 6 hours, 56 minutes, 7 seconds”

Udacity - Educating the 21st Century. What Every Computer Scientist Should Know About Floating-Point Arithmetic. Deep C.