10 algorithm challenges for an absolute beginner

faith ojeabulu
4 min readNov 7, 2020

After learning the basics of python, it was difficult for me to solve significant algorithm problems in python.so I had to do thorough research on the website that are beginner-friendly and can get algorithm challenges that will help me as a beginner improve in programming,

I came across a few of them and reviewed most of them, and with this, I was able to gather these 10 questions in their level of difficulty, and I believe as a beginner you should be able to solve this algorithm problem.

“Reading the best books will give you zero-knowledge unless you put the written word to practice.”

these algorithms include:

1)FIZZ BUZZ TEXT(EASY)

Write a program that returns a list of all the numbers from 1 to an integer argument. But for multiples of three use “Fizz” instead of the number and the multiples of five use “Buzz”. For numbers which are multiples of both three and five use “Fizz Buzz”.

EXAMPLE: fizz buzz(9) ➞ [1, 2, “Fizz”, 4, “Buzz”, “Fizz”, 7, 8, “Fizz”]

ANSWER:

def fizz buzz(maximum):

lst =[]

for i in range(1, maximum + 1):

if i % 3 == 0 and i % 5 == 0:

lst.append(“FizzBuzz”)

elif i % 3 == 0:

lst.append(“Fizz”)

elif i % 5 == 0:

lst.append(“Buzz”)

else:

lst.append(i)

return lst

2)ENCRYPTION ALGORITHM

Make a function that encrypts a given input with these steps Reverse the input,Replace all vowels using the following chart:

a => 0,e => 1,i => 2,o => 2,u => 3 , and Add “aca” to the end of the word.

EXAMPLE: encrypt(“banana”) ➞ “0n0n0baca”

ANSWER:

def encrypt (word):

s = word[::-1]

word1 = s.maketrans(‘aeou’, ‘0123’)

return s.translate(word1) + “aca”

3)CENSORED STRING

Someone has attempted to censor my strings by replacing every vowel with a *, l*k* th*s. Luckily, I’ve been able to find the vowels that were removed. Given a censored string and a string of the censored vowels, return the original uncensored string.

EXAMPLE: uncensored(“*PP*RC*S*”, “UEAE”) ➞ “UPPERCASE”

ANSWER:

def uncensor(string, vowels):

new_ = “”

counter = 0

for i in range(len(string)):

if string[i] == “*”:

new_ += vowels[counter]

counter += 1

else:

new_ += string[i]

return new_

4)RECURSION

The recursive function for this challenge should return the factorial of an inputted integer. If anyone needs a refresher, factorials in mathematics are represented by an exclamation point placed to the right of a number: 4! = 4 x 3 x 2 x 1 = 24

5)SQUARE EVERY DIGIT

Create a function that squares every digit of a number.

6)LETTER SHIFTING

Create a function that takes a string and shifts the letters to the right by an amount n but not the whitespace.

7)BLOCK THE SQUARES IN A TIC TAC TOE

Create a function that returns a number which can block the player from reaching 3 in a row in a game of Tic Tac Toe. The number given as an argument will correspond to a grid of Tic Tac Toe: top left is 0, top right is 2, bottom left is 6, and bottom right is 8.

· Create a function that takes two numbers a, b, and returns another number.

· This number should be the final one in a line to block the player from winning.

EXAMPLE: block_player(0, 3) ➞ 6

8)PHRASE OR WORD INVERSE

Create a function that inverts words or the phrase depending on the value of the parameter type. A “P” means to invert the entire phrase, while a “W” means to invert every word in the phrase. See the following examples for clarity.

EXAMPLE: inverter(“This is Valhalla”, “P”) ➞ “Valhalla is this”

inverter(“This is Valhalla”, “P”) ➞ “Valhalla is this”

9)CHECKING THE PALINDROME STRING USING STACK

Create a function that takes a string and checks if it’s a palindrome using Stack. The stack class is created for you.

EXAMPLE: is_palindrome(“radar”) ➞ True

10)PASCAL’S TRIANGLE

The goal of this challenge is to return Pascal’s triangle up to number 29. Pascal’s triangle is the sum of the two upper corners.

Create a function that returns a row from Pascal’s triangle. To find the row and column you can use n!/(k!*(n-k)!) where n is the row down and k is the column.

EXAMPLE: pascals triangle(1) ➞ “1 1”

In summary, I would like to say challenge yourself !!!. being able to solve more algorithm increase your level and your ability to apply programming in solving a real-life problem and then you gradually move from being a beginner to an intermediate programmer

--

--