20 Algorithmic Style Coding Problems/Questions for Practice

Hey there developers!

This is a Coding Resource Pack containing 20 algorithmic style programming questions for you to practice along with their solutions! You can solve these questions in any programming/scripting language you want!

Difficulty Level

The difficulty level increases as you go! The questions will get harder as you go! The average difficulty is Medium.

Questions and Overview

Difficulty - Easy


Difficulty - Medium


Difficulty - Hard


Where do I get it?

Click me to get the resource pack and start testing yourself!

How do I submit my approach?

You can submit your approach for any amount of questions you solved down below, by publishing your edited scripts to Roblox as a model and share the link down below! Or make a Github Repository containing your scripts and pasting the link down below!

Where do I find the solutions?

{Soon} Here are the solutions for each problem. Honesty is the best policy. Attempt the questions honestly without cheating. Testing your knowledge and learning is better than copy pasting code! If you are unable to solve a problem, feel free to check out my own clean approach for the same!

Thanks a lot! Good luck!


I can’t use studio rn so I don’t know what the challenges are about, but what makes square root hard?


Welp, thats just the name of the problem. The problem itself is hard. If you read the question, you’ll get to know :smiley:

that’s why I asked because I can’t read it yet :sweat_smile:
just curious is all

1 Like

also it is interesting how you say first “k” instead of first “n”
does k stand for something?

also shouldn’t this be #resources:community-tutorials???
not sure tho

‘k’ here is a separate integer variable and not the length of the array.

i don’t understand english too much so i only can answer 1 to 3

local foo = 0
foo = 1
  1. – forgot how to use metatable
local foo = {amogus = "sussy"}
local bar = {amogus2 = "baka"}

local barf = foo

for index, value in next, bar do
  barf[index] = value
local array = {"sussy", "baka"}

local clone = array -- ???

Its completely fine! Language barriers exist. The 1st and the 3rd solution of yours is the incorrect way of solving the question. You might not have read the questions correctly, but its completely fine :grin:


1 Like

I won’t get on studio until July 4th, bet I can do them all


1st one is correct! Time complexity is also O(n). 4th question is correct too! Shortened code -

function cloned (a, b)
     for i = #a,1,-1 do
		if a[i] ~= b[i] then
			return false
     return true

For the second question. Instead of merging two arrays. You replaced the first one with the other.

Here’s what I meant by merging.

Given two arrays {14,5,6} and {5,6,6,8} your task is to merge the 2nd array to the 1st one. So array1 becomes {14,5,6,5,6,6,8} and then simply return the array1!

1 Like

Oh well I read the code in an incorrect manner. My bad. All your solutions are correct so far!

For question 4:

You need to call a function multiple times to fill in the array. Here is my approach

local added = 0; --this number increases by 1 each time we pass in the function
local array = {};
function a (n, array) --n is the number we start the pattern with and we pass in an empty table
     if #array >= 10 then return array end; --we have got 10 numbers in our pattern. We no longer need to run the function again!
    if #array ~= 0 then
        array[#array + 1] = array[#array] + added; 
        array[#array + 1] = n;
    added += 1;
    a(n, array); --calling the same function again with editied values


If we consider ‘n’ to be 1 then the output of the above code will be as follows -


Which is exactly the pattern we want! :slightly_smiling_face:


Also. I checked your solution for Question 2 and it doesnt quite work. And the reason is…

You had a small silly mistake in the line -

a[i] = v;

Just replace it with -

a[#a + i] = v;

And it shall work perfectly! All we do here is increase the array’s length and add the value!

The final code will be -

function merge (a, b)
	for i,v in pairs(b) do
		a[#a + i] = v
	return a;

Great job!

1 Like

ur thread is getting cluttered and some ppl might want to like scroll and see wht the whole thing is bout so how bout u make a seperate place where ppl can post answers like a notice board or smthg

1 Like

That works as well! But its not exactly recursion!

1 Like

I just went through the advanced questions and i feel you did an amazing job coming up with these. also: if there are any sources pls mention not saying tht it looks like there is but if since i feel these are a good exercise

1 Like

it doesnt take me to a seperate site when i click on it

Still working on it :grin: Not yet functional.

Edit: It has been setup. Functional :slight_smile:

1 Like

put it up in the github page instead pls

when I come back I think to save space I’ll just post them on all GitHub


This was rather fun to complete, thank you for putting this out for the community! Here’s all of my solutions, packed in an RBXM.
file.rbxm (12.1 KB)