#Challenge

1 messages · Page 1 of 1 (latest)

mossy wolf
#

@severe steppe

You cannot overwrite or redefine 'table' **directly **or indirectly by any syntax.

severe steppe
#

modification isn't redefining?

mossy wolf
#

yes

#

at the end values must be in the table

#

but you can't do table[3] = 2

#

and any local a = table a[3] = 2

severe steppe
#

can we modify __index?

mossy wolf
#

that's metatable

severe steppe
#
local table = {};

-- v SOLUTION BELOW v ----------------------------------
local output = {
  [1] = "Hello World",
  [2] = 1,
  [3] = 2,
  [4] = 3
}
table.__index = function(self, key)
  return output[key]
end
table.__len = function()
  return 4
end
setmetatable(table, table)
-- ^ SOLUTION ABOVE ^ ----------------------------------

assert(table[3] == 2)
assert(table[4] == 3)
assert(table[2] == 1)
assert(#table == 4)

print(table[1])
#

this works but its cheeting

#

cheating*

mossy wolf
#

no you are setting meta

severe steppe
#

yes cheating

mellow obsidian
#

yeah thats what he said

severe steppe
versed furnace
#

u gotta look for some debug code i guess

severe steppe
#

yea its gotta be some weird ass way of adding values

#

no table library

#

or rawset

flint gyro
#

wtf can you even do

#

you can't assign anything, you can't fuck with metatable

versed furnace
#

i think there is a way but not sure which function to use

#

youre just not supposed to recreate the table

#

all you gotta do is keep it the same table but different values

flint gyro
#

@mossy wolf is it intentional that real lua table is being shadowed

versed furnace
#

seems like a debug job

flint gyro
#

:

local table = {};

#

here

#

in start

mossy wolf
#

yes

#

actually no

versed furnace
#

you are not able to use table lib anyway

mossy wolf
#

could be any tabl

#

the challenge is to pass asserts

#

for any table

flint gyro
#

then just
table.insert(solution_table, "hello, world")
table.insert(<blablaba>

severe steppe
#

bruh

#

no using table lib

topaz wraith
#

you cant use table lib

flint gyro
#

oh wait

#

yeah i'm retarded

mossy wolf
#

* You cannot use assignment (table[2] = 1), the table library, rawset or any other function to add values to the table.

flint gyro
#

'any other function to add to the table'

severe steppe
#

does it have something to do with chunks?

flint gyro
#

like wtf are you supposed to do

severe steppe
#

like bypass assert returning

#

because of chunk shit?

mossy wolf
#

this is just a clever way

flint gyro
#

because the only thing i see is hijacking metatables but alas, you can't do that

mossy wolf
#

very hacky

severe steppe
#

so its just adding values

#

in a super impractical way

mossy wolf
#

maybe

flint gyro
#

any other function to add values to the table. bro...

mossy wolf
#

yeah

flint gyro
#

it clearly says any function that adds values is illegal

severe steppe
#

by redefining do you mean table = a

mossy wolf
#

yes

severe steppe
#

ok

versed furnace
#

yeah

#

that makes it unoriginal

flint gyro
#

what's the context

#

is it just a 5.3 interpreter or gmod

mossy wolf
#

I think any 5.*

topaz wraith
#

i assume setfenv'ing it is illegal because it technically redefines the table?

mossy wolf
#

hm, actually challenge doesn't tell that, maybe yes it's valid

topaz wraith
#

:S

severe steppe
#

bruh

#

so change _G

#

lmao

topaz wraith
#

the table is a local

severe steppe
#

still assert

#

wouldn't work?

#

oh

#

wait

#

is debug.setlocal() banned?

topaz wraith
#

yes

#

if ur affecting the table yes

severe steppe
#

ah indirectly

mossy wolf
#

well depends how you use iy

severe steppe
#
local table = {};

-- v SOLUTION BELOW v ----------------------------------
local output = {
  [1] = "Hello World",
  [2] = 1,
  [3] = 2,
  [4] = 3
}
debug.setlocal(1, 1, output)
-- ^ SOLUTION ABOVE ^ ----------------------------------

assert(table[3] == 2)
assert(table[4] == 3)
assert(table[2] == 1)
assert(#table == 4)

print(table[1])
#

like I'm guessing thats banned

vast escarp
topaz wraith
topaz wraith
vast escarp
#

what kinda shit can u do with debug.setlocal?

topaz wraith
#

set local variables

vast escarp
#

does this mean you could access the os.* lib within gmod?

topaz wraith
#

no

severe steppe
#

bruh what

vast escarp
#

gonna disappear back into the void

severe steppe
#

guessing some weird setupvalue shit would also not be allowed

mossy wolf
#

but using debug.setlocal is close

severe steppe
#

hmm

#

you can't set indices of a table with it can u?

#

plus that would break that one rule

mossy wolf
#

you can but only in hacky way

severe steppe
#

hmm

#

ahah

#

I think I found it

#

well I can read it

#

hmm

#

setting it might be tricky

mossy wolf
#

i will say in advance, in the end the code will assign values to that table, but not in the way you know

untold marsh
#

wtf

mossy wolf
#

it should assign them otherwise how the assert will work

#

Tell me when you quit

untold marsh
#

I just woke up and am meant to be doing school, but this mf is going to distract me for the whole 6 hours

mossy wolf
#

basically asking @severe steppe

severe steppe
#

no I'm still looking

#
  local _, val = debug.getlocal(1, 1)
  val[1] = "Hi"
```still cheating?
mossy wolf
#

yes

severe steppe
#

I give up

#

tough challenge

mossy wolf
#

alright

severe steppe
#

I was trying some wack shit like this

local table = {};

-- v SOLUTION BELOW v ----------------------------------
local _, val = debug.getlocal(1, 1)
local h = val[1]
debug.setlocal(1, 4, 1)

-- ^ SOLUTION ABOVE ^ ----------------------------------
#

but I forgot its just a reference type

mossy wolf
#

I warned that it's really doing table[3] = 2
but it just... doesn't use syntax you can make

#

@topaz wraith

#
local foo = { ({debug.setlocal(1, 2, table), "Hello, World!"})[2], 1, 2, 3 }
#

@flint gyro

topaz wraith
#

oh wow

mossy wolf
#

so basically

#

it creates a table at index 2

flint gyro
#

o = {...

#

bro..

topaz wraith
#

the rules are very strict though, they become confusing because this kind of looks like you're "redefining" the table

mossy wolf
#

then its first key replaces index 2 to 1

severe steppe
#

yea its tough

flint gyro
#

You cannot use assignment,,,,

mossy wolf
#

directly

#

or indirectly by any syntax

#

i specifically added that

severe steppe
#

yea

#

isn't that assignment?

mossy wolf
#

that is, but not "indirectly by syntax"

#

and not directly

severe steppe
#

bruh

#

ok

mossy wolf
#

it's kind of directly in the bytecode but anyway

severe steppe
#

fair

mossy wolf
#

When setlocal changes index 2 to 1, foo becomes table

#

table constructor continues to build up

#

and adds all values

#

i know the rules are not clear, I told the same to the author

untold marsh
#

Who is the author?

mossy wolf
untold marsh
#

epic name

topaz wraith
#

roblox exploiters

#

great

#

magnitudes worse than gmod exploiters like @flint gyro

#

||lolez||

untold marsh
#

0572 seems like he'd be a roblox exploiter too

topaz wraith
#

zing

#

@flint gyro how are you going to recover

severe steppe
#

brb

#

coding for french roblox gamemodes

#

I wonder if they get backdoor'ed too

hushed forge
#

E

placid cliff
#

this works aswell

#

i really was thinking something like this like you create your own table and instantiating variables in it instead of adding values and set it to the expected table but idk why i couldn't think of the solution

flint gyro
untold marsh
flint gyro
#

i'm not briish
i'm not french
i'm not american

#

should be proof enough

untold marsh
#

@flint gyro

flint gyro
#

NOOOO