Okay, so I’ve been headscratching for this problem for hours now. The idea is simple. I want to be able to see if two given tables have the same values, no matter the configuration inside their brackets.
Here’s the script I currently have, and it’s safe to say that it doesn’t work.
local function CompareTables(t1, t2)
for i=1,#t1 do
if not (type(t1[i])=="table") then
if not table.find(t2,t1[i]) then
return false
end
else
for ie=1,#t2 do
if type(t2[ie])=="table" then
print('ya')
if #t2[ie]>0 then
CompareTables(t1[i],t2[ie])
end
else
end
end
end
end
return true
end
local t1 = {{"a"}}
local t2 = {{"b"}}
print(CompareTables(t1,t2))
-- Supposed to print false, but prints true
So, I need your assistance.
Using this table, you can test your algorithm and see if the results match all my values. If it does, please send me the script.
t1 = {
1,
2
}
t2 = {
2,
1
}
--true
t1 = {
{1}
}
t2 = {
{1}
}
--true
t1 = {
{},
2,
{1,{}}
}
t2 = {
{2},
{},
{{},1}
}
--false
t1 = {
{"a",1,{}},
{"b",2,{}}
}
t2 = {
{"a",2,{}},
{"b",1,{}}
}
--false
t1 = {
{"a",1,{}},
{"b",2,{}}
}
t2 = {
{"a",1,{}},
{"b",2,{}}
}
--true
t1 = {
{"a",1,{}},
{"b",1,{}}
}
t2 = {
{"a",1,{}},
{"b",2,{}}
}
-- false
t1 = {
{"b",2,{}},
{"a",1,{}}
}
t2 = {
{"b",2,{}},
{"a",1,{}}
}
--true