Exercises
- Write a function that takes as input a list of integers and returns the maximum integer stored in the list.
- Write a function that takes as input a string and returns true if the string is a palindrome and false otherwise. A palidrome is a string that reads the same forward and backward. Radar, kayak, and A man, a plan, a canal, Panama are examples of palindromes.
- Write a function that prints the first 10 powers of 2.
- Write a method that takes as input two lists of integers (l1 and l2) and returns the number of positions such that li[position] == l2[position].
- Write a method that takes as input a list of lists of characters representing a tic-tac-toe board and returns true if there is a winner -- that is, there are three of the same character in the same row, column, or diagonal.
- Write a program that will read from a file a tic-tac-toe board configuration and will determine whether there is a winner for the given configuration. An example file would look as follows, where '-' means that no one has played in that space:
XX-
O--
OX-
- Write a program to keep track of an inventory for a clothing store. Define a class InventoryItem that keeps the name, quantity, and price of a single item. Your program will keep a list of InventoryItem objects. Create a menu that will allow the user to enter new items, change the quantity of an item in the inventory, and view the total value of all items in the inventory.
- Write a program that reads the contents of a file, removes all instances of the words 'and', 'the', and 'or', and writes the resulting text to a new file.
Sami Rollins