P352 Hurkle

Back to General discussions forum

gardengnome     2023-06-13 05:20:35
User avatar

Q: Do we choose the position of the hurkle ourselves, or is it stored in some global variables?

I get the error attempt to perform arithmetic on a nil value (global 'x') and thus wondering ...

Rodion (admin)     2023-06-13 06:11:10
User avatar

Thanks for hint, I emphasized the words implement playable version of the game and added pick random coordinates for Hurkle to the step 2.

As a side note, I wanted to publish both problems (this and its opposite) simultaneously, but noticed yesterday at night you have logged into the site and suspected you've seen TestUser's attempts against the problem anyway, so opened it earlier :)

UPD so I quickly published the second part now... and as I see our new colleague tzyLee already made some progress on the first, wow...

gardengnome     2023-06-13 17:39:02
User avatar

Thanks, understood.

gardengnome     2023-06-14 20:22:23
User avatar

Philosophical question: in the original game description, locations can have integer x and y values between 0 and 10. Is that a 10x10 or a 11x11 grid?

Rodion (admin)     2023-06-14 21:07:30
User avatar

Also stumbled over this on first reading the description. Applying my meek archaeology skills :) found the bit surprising answer - probably about lines 285-286 here - it seems to be 0..9 range, a bit unnatural for non-programmer's perception (unless I'm missing something).

gardengnome     2023-06-19 19:27:28
User avatar

PyCharm users: you can download and install Lua from here, and then install the EmmyLua plugin in PyCharm - that allows you to develop and run Lua programs directly within PyCharm.

Rodion (admin)     2023-06-20 11:12:54
User avatar

(thanks! added this advice to lua-quickstart instruction)

Enrico Pilz     2023-09-20 18:14:01

Don't know if this is part of the challenge, but I can't read the numbers with io.read().

Here the smallest source reproducible:

print('ready')
X, Y = io.read('*n', '*n')
print(X .. ' ' .. Y)

This fails for all tried names (X, x, ix, aaaix) for X, Y with:

/opt/lua: /test-ground/test.lua:3: attempt to concatenate a nil value (global 'y')
stack traceback:
    /test-ground/test.lua:3: in main chunk
    [C]: in ?

On local machine it works with lua5.3 and lua5.4.

What am I doing wrong?

TestUser     2023-09-20 18:39:55
User avatar

Enrico, Hi!

Do you mean when running it with "sandbox" (i.e. clicking Lua button below the code) or when submitting?

As for the button, it looks like working - just we need to keep in mind that input is read from the "Test Data" box.

example on running lua with input on codeabbey sandbox

P.S. and when running your submission, I guess, the checker will magically feed some (unknown) input by itself, as if human enters data...

Enrico Pilz     2023-09-20 20:24:46

Hi TestUser,

thank you very much! This is the cause. With hindsight it's so obvious :/

Please login and solve 5 problems to be able to post at forum