Problem of the Week
This page lists the "problems of the week" - extra programming problems meant to help people practice their programming skills.
These will be at a variety of different levels. Some support is provided in the CS Online Lab team in Microsoft Teams. You can go to the team, go to the Problem of the Week channel, and fire away your questions.
Note that many of these problems can be solved in any programming language. The CS Online Lab will support assistance in Python, C, C++, and R. Some problems may be easier to implement in some languages than others.
Problems are listed in "reverse chronological order" within each section/subsection (new problems are added to the top of the section). A date of posting is listed for each problem.
Note that some "classic" programming problems are listed. You should work to solve these on your own, not by simply looking up the solutions online. You learn and improve your skills by making the solutions yourself.
factor 5/20/2020 - read an integer from standard input (keyboard), output its prime factorization.
Example input: 12 Example output: 2 * 2 * 3 Example input: 5 Example output: 5
primes 5/20/2020 - read an integer from standard input, output all prime numbers <= that number.
Example input: 19 Example output: 2 3 5 7 11 13 19
stats 5/20/2020 - read an integer n and then n integers from standard input, output the min, max, mean.
Example input: 5 7 3 2 10 -5 Example output: -5 10 3.4
Data Structures and Algorithms
sorts 5/20/2020 - first command-line argument is either bubble, insertion, selection. Read from standard input until EOF, output the number of steps (number of comparisons) to sort the numbers. If second command-line argument is "verbose", also print the numbers in sorted order. As a first attempt, assume there will be exactly 10 numbers and do just one of the sorting algorithms. As a second attempt, assume there will be at most 1000 and add in one of the other sorting algorithms. Finally, make the program work no matter how many numbers there are and for all three sorting algorithms.
Example input (bubble): 1 2 3 4 Example output: # steps to sort: 3 Example input (bubble verbose): 4 3 2 1 Example output: # steps to sort: 6 1 2 3 4
binaryTree 5/20/2020 - read integers from standard input until EOF, output the number of steps to build a binary tree out of the numbers. If second command-line argument is "verbose", also print the tree.
rpn 5/20/2020 - evaluate the command line integer arguments as an RPN expression. Note that you will need to keep a stack (linked list) of the values (since this is how RPN is evaluated).
Example input (command-line args): 1 2 3 "*" + Example output: 7 Example input: 3 5 7 - / Example output: -1