# Hacker’s Terminal

<figure><img src="https://3546595727-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoRne7ThJaBZiwCpSKT7V%2Fuploads%2FwnHhvLpleLK7WmGReDnD%2Fhackerterminal-removebg-preview.png?alt=media&#x26;token=1a73d83e-9bad-4892-bea2-5c6347463d7d" alt=""><figcaption></figcaption></figure>

```lua
-- Hackers Terminal Lock
RegisterCommand('testhacker', function()
    local challenge = [[
    Write a function that checks if a number is even or odd.
    The function should:
    - Take a single number parameter
    - Return "even" for even numbers
    - Return "odd" for odd numbers
    - Handle negative numbers as well

    Example:
    isEvenOrOdd(4) should return "even"
    isEvenOrOdd(3) should return "odd"
    isEvenOrOdd(-2) should return "even"
    isEvenOrOdd(-3) should return "odd"
    ]]

    local testCases = {
        { input = {4}, expected = "even" },
        { input = {3}, expected = "odd" },
        { input = {-2}, expected = "even" },
        { input = {-3}, expected = "odd" }
    }

    -- Expected Response
    --[[
        return function(n)
            if n % 2 == 0 then
                return "even"
            else
                return "odd"
            end
        end
    ]]

    exports['moon-ui']:OpenHackersTerminal(
        'lua', -- language
        challenge, -- challenge description
        300, -- time limit in seconds (5 minutes)
        testCases, -- test cases
        function(success)
            if success then
                -- Handle successful hack
                print('Hack successful!')
            end
        end,
        function(message)
            -- When time Is Up
            print('Time Is Up')
        end
    )
end)
```

{% file src="<https://3546595727-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoRne7ThJaBZiwCpSKT7V%2Fuploads%2FvACAZlio5qjrdCN98kH9%2Fhackerterminalexamples.md?alt=media&token=abab2c0e-5c59-4cac-b577-4f1287262731>" %}
Example For More Codes
{% endfile %}
