This looks awesome, definitely gonna test myself with this later.
I know I said I would get back to this on the 4th, but I have been busy with my game and I still am
I will post a model showcasing the 20 solutions but I will not be making a github because I am assuming that a github will be made for everyone at a later date
That is my output when all 20 functions are ran at once
sorry if im a bit late, here is 16-20
16. not sure what is 'kāth
17. built-in math module
math.sqrt(x)
18. recursively prime number search
function prime(n, i)
i = i or 2
if i > n then return false end
return n % i == 0 or prime(n, i+1)
end
function findPrimaryInArray(tb, i)
local i = i or 1
if #tb < i then return nil end
return prime(tb[i]) and tb[i] or findPrimaryInArray(tb, i+1)
end
-- tb: table<int>, i: number (start index)
-- {0, 1, 3, 4} -> 3
print(findPrimaryInArray(intTable))
19. modify primary to another value(?)
function modifyPrimaryInArray(tb, newval, nth, i)
local i, nth = i or 1, nth or 1
if #tb < i or nth <= 0 then return tb end
if prime(tb[i]) then tb[i] = newval; nth = nth - 1 end
return modifyPrimaryInArray(tb, newval, nth, i+1)
end
-- tb: table, newval: any, nth: number (n-th occurence that should be changed), i: number (start index)
-- modifyPrimaryInArray({0, 1, 3, 4}, 6, 1) -> {0, 1, 6, 4}
20. sort table of string by char code index
local tb = {"Ab", "a", "z", "AB"}
table.sort(tb, function(a, b) return a<b end)
print(table.concat(tb, "\n"))
-- AB = 65+66, Ab = 65+98, a = 97, z = 122
+ bonus part
-- merging table without loop
local a = {0,1,2}
local b = {3, 4}
local c = {table.unpack(a), table.unpack(b), 5}
-- c: {0, 1, 2, 3, 4, 5}
all codes are tested using vanilla lua and should also work in luau.
I think I might do some of those in my free time, over the years I lost all my roblox lua knowledge and right now Iām struggling so hard to even complete the first one It would be a good chance to clean the rust away and get back into roblox scripting, anyways, using C# I was able to do them all very easily though and it was really fun!
Question 9 in easy difficulty, the function add is missing an argument, which is the element you insert into the stack, or I just misunderstood somewhere?
Your solution can be optimized a bit more
Ooh might try some of these!
Solved 20/20, pretty cool challenge!
Here are my solutions: GitHub - Zoesads/algo-style-quests: 20 Algorithmic style quests - My solutions
Did not mean to reply, sorry
Only did the easy pack (all of them), the rest seems too hard for me (I suck at math, Iāll admit it)
coding-questions-re-rev1.rbxm (10.6 KB)
You donāt really need math to solve them.
Can you please put descriptions of each problem in the thread itself?
You can check them in my GitHubās repo (along with the solutions)
Your GitHub repo isnāt linked in the original post.