I think a lot of people learning to program would find it useful if there was resource of coding exercises in varying difficulties that was easily printed and in a simple format. I've done a bit of search and haven't really found what I was particular after. With that in mind I've started this thread in the hope that some of you coding gurus could add your own exercises using the format below.
1. Reversing a string.
Write a function were you enter a text string which is then output in reverse order.
Input = "RaspberryPi" Output = "iPyrrebpsaR"
Input = "Keep It Simple" Output = "elpmiS tI peeK"
2. Determining the factorial for a given number.
Write a function that accepts a number being passed to it and returns the factorial (i.e. if num = 4, return (4 * 3 * 2 * 1)). For the test cases, the range will be between 1 and 10.
Input = 4 Output = 24
Input = 8 Output = 40320
3. Determining the largest word in a sentence.
Write a function that accepts a text string parameter being passed and return the largest word in the string. If there are two or more words that are the same length, return the first word from the string with that length. Ignore punctuation and assume the string will not be empty.
Input = "this is fun" Output = "this"
Input = "I love cake" Output = "love"
Input = "Lets Party!" Output = "Party"
BONUS : Add validation so that an empty string cannot be entered, a message is displayed and the input is requested again.
4. Manipulating characters in a string based off their positions in the alphabet.
Create a function that takes the string parameter being passed and modify it using the following algorithm.
Replace every letter in the string with the letter following it in the alphabet (i.e. c becomes d, z becomes a). Then capitalize every vowel in this new string (a, e, i, o, u) and finally return this modified string.
Input = "hello*3" Output = "Ifmmp*3"
Input = "fun times!" Output = "gvO Ujnft!"
5. Adding up all the numbers from 1 to a certain argument.
Create a function SimpleAdding(num) to add up all the numbers from 1 to num. For the test cases, the parameter num will be any number from 1 to 1000.
Input = 12 Output = 78
Input = 140 Output = 9870
6. Determine how many hours and minutes from a value supplied in minutes.
Create a function TimeConvert(num) take the num parameter being passed and return the number of hours and minutes the parameter converts to (ie. if num = 63 then the output should be 1:3). Separate the number of hours and minutes with a colon.
Input = 126 Output = "2:6"
Input = 45 Output = "0:45"
For info the inspiration and first few examples came from http://coderbyte.com/
but format is not what I was after, please visit for other examples.