Introduction to Computer Science
CompSci 101 : Spring 2014

Problem Solving

After you have worked out an algorithm for solving a problem, write a program that implements your algorithm. When finished, test your programs.

  1. Validating Passwords

    Passwords are ubiquitous and choosing a good one is important to prevent identity theft. A password that is simply a word that can be looked up in a dictionary, no matter how obscure, is no longer considered a "good" password. Mixing capitalization, letters and numbers, and using multiple words allow for passwords that ae harder for computers to crack but still reasonable for people to remember.

    This problem models checking a password's "strength" to ensure it has these features for safety and security. Design an algorithm which checks whether a given string, representing a password, is at least eight characters long, has at least one number (0 - 9), at least one capital letter, and does not have any spaces. If all of these requirements are fulfilled, return True; if the password fails one or more criteria, return False.

    • Does the order in which you check the password's features matter?
    • When can you know the password is not valid? What about when it is valid?
    • How would you change the code to require two capital letters? Three?
    • How strong is your password?

     

  2. Cleaning Words

    Words are unqiue sequences of characters that give meaning. However, in everyday written language, it is often the case that words are bordered by various punctuation marks and whitespace, yet we still unconsciously parse and recognize these sequences of characters as words. Your function should perform this unconscious parsing by taking in a string of characters, removing the surrounding, not internal, whitespace and punctuation and returning the cleaned string.