|
Post by cntkillme on Jun 14, 2017 10:33:24 GMT
--- CHALLENGE 1 --- -- Every new challenge will be harder, so consider this the easiest one. -- Goal: call TestPin with a pin such that it returns true. -- Do not alter the TestPin local or your solution is invalidated. -- Your solution must work in Roblox Studio and in vanilla Lua 5.1.
local TestPin
do local _pin
local function GeneratePin() _pin = math.random(10000, 99999) end
function TestPin(pin) if pin == _pin then return true else GeneratePin() return false end end
GeneratePin() end
-- DO NOT EDIT ANYTHING ABOVE THIS LINE
TestPin(12345)
|
|
john
New Member
Posts: 11
|
Post by john on Jun 14, 2017 18:28:30 GMT
math.randomseed (0) local pin = math.random (10000, 99999) math.randomseed (0) print (TestPin (pin))
|
|
|
Post by cntkillme on Jun 14, 2017 20:02:43 GMT
Correct. There's also one more solution (which for some reason I didn't notice until my friend pointed it out) but either is valid.
|
|
|
Post by Bit on Jun 14, 2017 22:09:15 GMT
SPOILER: PART 2 math=setmetatable({random=function() return 0 end},{__index=math}) GeneratePin() print(TestPin(0))
|
|