Please subscribe to the official Codeforces channel in Telegram via the link ×

RodionGork's blog

By RodionGork, history, 2 months ago, In English

Hi Friends!

I know you all are probably busy solving some ongoing contest or preparing to some upcoming. But in case you have half an hour to spend on funny problem without clear solution, I invite you to try Jewels at my site.

You may know this game as "Match-3" or "Bejeweled". Now the question is to write small function to "auto-play" it - i.e. to suggest some good move. Code is accepted in Python or Lua (supposedly many of us know Python anyway — and who don't, I recommend investing 15 minutes in learning Lua — there is "intro" link included).

Writing naive implementation of about dozen lines which iterates over the board and tries to find any valid move probably won't take more than another 15 minutes from you. However running time is limited to 1 second so that it probably is not possible to carefully and slowly examine all possible moves at each step. This means you can try some fancy ideas of "inexact" solution.

bejeweled game screenshot

  • Vote: I like it
  • +31
  • Vote: I do not like it