This is the sample code for the answers to the coding club try out problem set. All problems are solved in Python and some in C++ Coding Club Problem Set Sorted in order of difficulty
Coding Club Quick Test Coffee Beans
-
How it works?
-
Given an input string of any length if the word Coffee or Beans occurs return the word Coffee Beans
-
If above statement is not true return 'sleepy'
-
Must work for capital or lowercase letters
-
Words will be separated with a space (' ')
-
Example input "I like coffee", "Beans on toast", "coffee beans", "I only drink tea"
-
Example output 'Coffee Beans', 'Coffee Beans', 'Coffee Beans', 'sleepy'
Coding Club Quick Test Palindrome
-
How it works?
-
Given a word (containing higher or lower case letters) if you reversed the word would it stay the same (the word is a palindrome)
-
Example input 'Bob' 'Sally' 'Anna' 'wow'
-
Example output True False True True
-
You could improve this example by allowing the input of phrases and sentences! (e.g "Taco Cat" -> True)
Coding Club Quick Test Pythagoras Therom
-
How it works?
-
a^2 + b^2 = c^2
-
Given a tuple of 2 values (a, b)
-
Find c and return (a, b, c)
-
Example input (3, 4)
-
Example output (3, 4, 5)
Coding Club Quick Test FizzBuzz
-
How it works?
-
If it is divisable by 3 say Fizz
-
If it is divisable by 5 say Buzz
-
If both of the above statements are true say FizzBuzz
-
Example output 1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz, 11, Fizz, 13, 14, FizzBuzz
Coding Club Quick Test SpongeBob
-
How it works?
-
Get the last digit of any number
-
If it is even say sponge
-
If it is divisable by 3 say bob
-
If both of the above statements are true say spongebob
-
If the number is equal to 9 ignore all the statements above and say patrick
-
Example output 10, 11, Sponge, Bob, Sponge, 15, SpongeBob, 17, Sponge, Patrick, 20
Coding Club Quick Test Prime Three
-
How it works?
-
Given an input of a list of numbers find all the numbers that meet the following criteria
- A prime number
- Contains the number 3
-
All numbers found that meet this criteria must be then sorted by how many times the number three occurs (numbers with the same number of threes should be sorted according to there numerical value)
-
Example input [2, 3, 10, 55, 37, 323, 533, 333, 22, 103, 57]
-
Example output [3, 37, 103]