Find Related products on Amazon

Shop on Amazon

The Prospero Challenge

Published on: 2025-10-05 19:04:43

The Prospero Challenge prospero.vm is a plain-text file containing 7866 math expressions. It begins as follows: # Text of a monologue from The Tempest _0 const 2.95 _1 var-x _2 const 8.13008 _3 mul _1 _2 _4 add _0 _3 If you evaluate the expression with (x,y) values in the ±1 square, then color pixels black or white based on their sign, you get the following image: The "challenge" is simple: render the image as quickly as possible. A basic renderer is 28 lines of Python, using Numpy for pixel parallelism: import numpy as np with open('prospero.vm') as f: text = f.read().strip() image_size = 1024 space = np.linspace(-1, 1, image_size) (x, y) = np.meshgrid(space, -space) v = {} for line in text.split(' '): if line.startswith('#'): continue [out, op, *args] = line.split() match op: case "var-x": v[out] = x case "var-y": v[out] = y case "const": v[out] = float(args[0]) case "add": v[out] = v[args[0]] + v[args[1]] case "sub": v[out] = v[args[0]] - v[args[1]] case "mul": v[out] = v[ar ... Read full article.