Get the latest tech news

Show HN: Using SQL's Turing completeness to build Tetris


Using SQL's Turing Completeness to Build Tetris. Contribute to nuno-faria/tetris-sql development by creating an account on GitHub.

For instance, if we took the CTE that generates a sequence of numbers and removed the stop condition, the query would hang and not show any output, unlike an infinite loop + print in a language such as C. Once again, a recursive CTE is used to aid this task: the base value is set to -1 and, at each iteration, it moves the piece down by one line until it collides with an existing one or reaches the end of the board. Since the default value of the work_mem parameter is relatively low (4MB), Postgres will also use temporary files to store the partial results, meaning disk usage also increases continuously.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of SQL

SQL

Photo of tetris

tetris

Photo of turing completeness

turing completeness

Related news:

News photo

SQL king Larry Ellison becomes sequel sultan with controlling interest in Paramount Global

News photo

Show HN: Node.js ORM to query SQL database through an array-like API

News photo

Why the ‘perfect game’ is still with us decades later | Tetris interview