Gearing up to build the future.
The following programming problems are programming language agnostic. That is, they can be solved using any programming language of your liking. Solving interesting programming challenges is a great way to develop your programming and problem solving skills. It is also a lot of fun and can be very fulfilling.
Feel free to adapt and modify these problems to suit your skill level/ interest. If you think a particular challenge is interesting but a little too difficult, or not difficult enough, then maybe you only solve part of the problem, or think of ways to take it even further.
If you are currently only doing text based output with your programming many of the more graphical based challenges can easily be adapted to text output with a little creativity.
(Note: I do not provide solutions to these problems. Please don't email me asking for solutions or help with your code.)
Want to push things a bit further. Why not challenge your friends to a round of Code golf. The aim is to come up with the shortest possible working solution.
In no particular order.
Build a game of Tic Tac Toe. I would suggest you start off building a two player version then if you want a little extra challenge see if you can build a version where you get to challenge the computer.
Build a game of Mastermind.
Create a program which will read in a file containing HTML and identify lines with incorrectly nested tags. This is an example of correctly nested tags:
<H1>This is my <span>heading</span></H1>
And this is an example of incorrectly nested tags:
<H1>This is my <span>heading</H1></span>
Regular expressions can be useful here.
Write a program which will print out a Pascal triangle.
Create a program which will accept a series of numbers (these could for instance be a series of marks for an assessment) and then produce a quick report. The report should include the mean, mode and median. You could also include standard deviations if you're up to it. Your report should also include a histogram of the values, eg:
1 | *** 2 | * 3 | ******* 4 | **** 5 | **
Create a program which accepts two numbers then prints out a random number somewhere between those two numbers. Make sure you write your own code to generate the random number (ie. don't use the built in random function).
You can be quite creative in how you achieve this but a common approach is to make use of the current time as part of your method.
Write a program which will acctept a date in either long hand or short hand (eg. either 25/6/2017 or 25th June, 2017 ) and work out if the given date is valid. eg. 14/13/2017 is clearly not valid.
Time is often recorded within computers as something called a timestamp. Write a program which will accept two timestamps and tell you the difference between them in human readable form. eg:
Enter timestamps: 1498361922 1498367202 1 hour 28 minutes
Create a program which will accept the Cartesian coordinates for two triangles. It will then identify if the two triangles overlap, are one inside the other, or are separate.
Write a program which will accept a line of text and tell you if any of the words appear within any of the other words in the line. Here is an example:
Enter sentence: There is a palm tree on the island. The word is appears in the word island
Write a program which will accept a line of text and tell you if any of the words are made up of the same letters. Here is an example:
How can you listen if you are not silent?
A simple game of maths and psychology. In this game a number of people submit a number (full number, no fractions) between 0 and 100 (inclusive). Each persons number is a guess at what 2/3 of the average of all guesses will be. The person whos guess is the closest wins.
You can play an on-line version (agains the last 100 visitors) to get a feel for how it works.
Create a program which will allow a group of people to play the game.
Calculating 2/3 of the average isn't too difficult. Obtaining the guesses whilst keeping everyones guesses secret is a little trickier however.
A large part of what Google uses to rank websites is something called PageRank. Effectively each page gets a value based upon how many other pages link to it. The value that those pages have influence the value of the page that is linked to as well. A link from a highly ranked page could be worth more than several links from lower ranked pages for example.
Let's do similar for Tweets and create a PersonRank. Say we have a file and in it are a series of Tweets. Each line begins with the handle of the person making the tweet, followed by a tab, then the actual tweet. Every time a person is mentioned in a tweet we can consider that a vote for that person.
See if you can write a program to read in the tweets from the file and then calculate each persons PersonRank. Print out the results in order of the PersonRank.
You can find a description of the algorithm you'll need to implement in the link to PageRank above.
You are given the digits 1,2,3,4,5,6,7,8,9. You may add '+' and '-' operations inbetween any of the digits. You may also join digits together to form a bigger number. The digits must stay in the original order however. Your aim is to do this in such a way that the result of the equation is a number that the user provides. Create a program which will ask the user for a number then find every possible solution. Here is an example that results in 50:
1 - 2 + 34 + 5 + 6 + 7 + 8 - 9 = 50
You could solve this by brute force (trying every possible combination) but it may be better to look at dynamic programming.