Still have questions? Join our Discord server and get real time help.
Log in to vote

How to find most common occurrence?

Asked by 2 months ago
Edited 2 months ago

So I have a function that loops through a 3D array and inserts all the values in the 3d array into a normal 1D array, but I would like to be able to find the most common occurrence between the numbers and I am not sure how to do that.

Here is my code.

local array3d = {


{1, 2, 3, 4}, {1, 2, 2, 2, 4}



local commonOccurrence = { }

local function commonValue(tab, common)

for i = 1, #tab do

for v = 1, #tab[i] do

for k = 1, #tab[i][v] do

common[i] = tab[i][v][k]





commonValue(array3d, commonOccurrence)

Answer this question