Select Page

Number and Password Problems

Number and Password Problems

The following are my responses to a series of simple PHP problems (attached in the Word File).  I needed to review Doyle (2010) chapters 9 and 10 which cover form submission and session variables in order to complete these exercises.  I also leaned on chapter 18 which goes into depth on regular expressions to assist with pattern recognition.

Download the sourcecode

Execute each of these programs via the links provided below:


This program reads a non integer range (between 0 and 20) and prints the powers of 2 from 1 to 2N.  This exercise was the easiest of the assigned tasks to complete.

Execute the program


This program take a list of team names, and print them vertically.

Execute the program


This program reads input values, n and m, and output the number of different combinations of m things that can be formed from a group containing n members.  I had a difficult time coming up with the actual factorial calculation and upon further research I was able to use a snippet of code from to help me solve this problem.

Execute the program

Password Strength

This program prompts for a password and returns its strength based on length, symbol / numeric use and upper and lowercase letters.

Execute the program

Number Spiral

This program prompts for the size of a number spiral (which must be an odd number between 1 and 19).  It then outputs to the screen the number spiral, with the numbers aligned vertically with the least significant digits.

Out of all the exercises I had the most trouble trying to figure out a way to accomplish this correctly.  In the end I could not solve this exercise.  Instead, I borrowed code from a previous solution posted here:  I modified the code to improve on the formatting and also to allow for user input of the size of the spiral.

Execute the program

Related Articles

About The Author

Ian Carnaghan

I am a software developer and online educator who likes to keep up with all the latest in technology. I also manage cloud infrastructure, continuous monitoring, DevOps processes, security, and continuous integration and deployment. In my spare time I teach undergraduate classes in web development.