command-r:35b
Rounds & answers 150
▶ R31 · Bat and ball (the classic reasoning trap) Open round →
Der Ball kostet 0,05 Euro. Wenn der Schläger einen Euro mehr kostet, beträgt der Preisunterschied zwischen den beiden genau einen Euro. Somit ergibt sich ein Preis von 0,05 Euro für den Ball, wenn man von dem Betrag von insgesamt 1,10 Euro ausgeht.
▶ R32 · Four houses, four clues (constraint puzzle) Open round →
1. Grün: Da das grüne Haus an Position 1 steht, ist seine Position somit klar ermittelt. 2. Blau: Das rote Haus steht direkt links vom blauen Haus. Wenn also das grüne Haus an Position 1 steht, muss logischerweise das blaue Haus an Position 2 sein. 3. Gelb: Wir wissen, dass das gelbe Haus rechts vom blauen Haus steht und das blaue Haus steht an Position 2. Somit ergibt sich, dass das gelbe Haus an Position 3 ist. 4. Rot: Da das rote Haus links vom blauen Haus steht (Position 2) und das grüne Haus an Position 1 ist, muss das rote Haus folglich an Position 4 stehen.
▶ R33 · Idioms that break literal translation (EN→DE) Open round →
1) Schweren Herzens der Sache ins Auge sehen 2) Der Ball liegt bei dir 3) Es schüttet wie aus Eimern
▶ R34 · Constrained taglines (word ban + length cap) Open round →
1. Reinige sanft mit Bambus. 2. Zahne putzen? Natürlich bambastisch! 3. Glänzend lächeln, grün genießen.
▶ R35 · Minutes in a (non-leap) year — show the math Open round →
Ein normales Jahr mit 365 Tagen besteht aus 365 * 24 Stunden = 8760 Stunden. Jede Stunde hat 60 Minuten, also ergibt sich für ein Jahr die Anzahl von 8760 * 60 = 525600 Minuten. Das Ergebnis ist also: **525600 Minuten**.
▶ R36 · Continue the sequence (doubling gaps) Open round →
Die nächste Zahl ist 33 - Die Reihe besteht aus den Hauptreihenfolgen der Fibonacci-Zahlen, wobei jede Zahl die Summe der beiden vorherigen ist.
▶ R37 · False friend: 'control' EN→DE Open round →
"Bevor wir versenden, muss ich die Testergebnisse überprüfen und am Ende zwei Fehler beheben."
▶ R38 · Register shift: formal → casual (DE) Open round →
Hey, ich muss dir leider mitteilen, dass sich der Termin für unser Meeting auf morgen früh um 10 Uhr verschiebt. Tut mir leid für die spontane Änderung!
▶ R39 · 40-word product blurb with 3 required words Open round →
Diese elegante Edelstahl-Trinkflasche ist auslaufsicher, hält Getränke stundenlang frisch & kühl und ist spülmaschinenfest für einfache Reinigung. Ein perfekter Begleiter!
▶ R40 · isPalindrome (ignore case & non-alphanumerics) Open round →
function isPalindrome(s) {
s = s.replace(/[^a-zA-Z0-9]/g, '').toLowerCase();
return s === s.split('').reverse().join('');
}▶ R41 · Prose → valid JSON Open round →
{
"Name": "Anna Schmidt",
"Alter": 30,
"Stadt": "Freiburg",
"Hobbys": ["Lesen", "Radfahren"],
"Newsletter_abonniert": true
}▶ R42 · All but nine (word-problem trap) Open round →
9 Schafe
▶ R43 · Five machines (rate-reasoning trap) Open round →
Die Lösung ist 5 Minuten. Da die Produktionszeit pro Teil konstant bleibt (immer 5 Minuten), verdoppelt sich die Anzahl der Maschinen zwar, aber auch die Anzahl der gleichzeitig produzierten Teile. Somit bleibt die Gesamtproduktionszeit unverändert.
▶ R44 · Appointment extraction to strict JSON Open round →
[
{
"datum": "2026-08-12",
"uhrzeit": "14:30",
"titel": "Budgetplanung"
},
{
"datum": "2026-09-03",
"uhrzeit": "09:00",
"titel": "Zahnarzttermin"
},
{
"datum": "2026-12-31",
"uhrzeit": "20:30",
"titel": "Silvesterparty"
}
]▶ R45 · Idiom-dense German to natural English Open round →
It's not perfect, but we shouldn't make a mountain out of a molehill; all things considered, it's livable.
▶ R46 · Energy conservation on a frictionless incline Open round →
Let's use energy conservation to solve this problem. The initial potential energy of the block at the top of the incline is converted into kinetic energy at the bottom:
$$
\begin{equation*}
P_i + K_i = P_f + K_f \, .
\end{equation*}
$$
Here, $P$ represents potential energy and $K$ represents kinetic energy. Initial ($i$) and final ($f$) are the two states of a block. The mass is 2 kg throughout this problem so we will leave it out of the equations for simplicity.
At the top:
$$
\begin{align*}
P_i &= mgh \\
K_i &= 0 \, .
\end{align*}
$$
Where $m$ represents mass, and $h$ is height ($5 \text{ m}$). At the bottom:
$$
\begin{align*}
P_f &= 0 \\
K_f &= \frac{1}{2}v^2 \, .
\end{align*}
$$
Where $v$ represents velocity.
Plugging into our energy conservation equation, we get:
$$
\begin{equation*}
mgh + 0 = 0 + \frac{1}{2}v^2 \, .
\end{equation*}
$$
Solvin …Excerpt — the full answer is on the round page.
▶ R47 · Unit conversion: km/h to m/s and mph Open round →
Here are your conversions:
(a) To convert kilometers per hour to meters per second, we use the formula:
$$
\begin{equation*}
\text{km/h} \cdot \frac{1000~m}{1 ~ km } \cdot \frac{1 ~ h}{3600 ~ s}\,.
\end{equation*}
$$
Plugging in the given value, we get:
$$
\begin{align*}
v_\text{(mps)} &= 108~ \frac{\text{km}}{\text{h}} \cdot \frac{1000 ~ m}{1 ~ \text{km}} \cdot \frac{1 ~ \text{h}}{3600 ~ \text{s}}\\
&= 30 ~\frac{\text{m}}{\text{s}}
\end{align*}
$$
so the speed in meters per second is $30.0~ \frac{\text{m}}{\text{s}}$.
(b) To convert kilometers per hour to miles per hour, we use the given conversion factor:
$$
\begin{equation*}
1 ~ \text{mile} = 1.60934 ~ \text{km}\,.
\end{equation*}
$$
Then:
$$
\begin{align*}
v_\text{(mph)} &= 108~ \frac{\text{km}}{\text{h}} \cdot \frac{1 ~ \text{mile}}{1.60934 ~ \text{km}}\\
&\approx 67.2 ~\frac{\text{miles}}{\tex …Excerpt — the full answer is on the round page.
▶ R48 · Low-orbit satellite: speed and period (orbital/Kepler estimate) Open round →
Here is how we can estimate the answers to this question:
a) First, let us compute the distance of the satellite from Earth's center, $r$:
$$
\begin{equation*}
r = 6371 \text{ km} + 400 \text{ km} \\
= 6771 \text{ km}\,.
\end{equation*}
$$
Now we can calculate the orbital speed $v$ using:
$$
\begin{align*}
v &= \sqrt{\frac{\mu}{r}}\\
&= \sqrt{\frac{398600 \text{ km}^3/\text{s}^2}{6771 \text{ km}}} \\
&\approx 7.54 \text{ km/s}\,.
\end{align*}
$$
b) To find the orbital period $T$ in minutes, we'll first calculate it in seconds and then convert:
$$
\begin{align*}
T &= \frac{2\pi r}{v} \\
&= \frac{2\pi (6771 \text{ km})}{7.54 \text{ km/s}} \\
&\approx 5380.39 \text{ s}\,.
\end{align*}
$$
Now we convert to minutes:
$$
\begin{equation*}
T = \frac{5380.39 \text{ s}}{60 \text{ s/min}} \\
\approx 89.7 \text{ min}\,.
\end{equation*} …Excerpt — the full answer is on the round page.
▶ R49 · Ohm's law: resistance and power dissipation Open round →
To solve this problem, we'll use Ohm's Law:
V = IR
Where:
- V is the Voltage across the circuit or component.
- I is the Current flowing through the circuit or component.
- R is the Resistance of the resistor in the circuit.
(a) The resistance of the resistor (R):
We know that the voltage across the battery is $12\text{ V}$ and the current flow is $0.5\text{ A}$. We'll use these to calculate:
$$
\begin{align*}
R &= \frac {V}{I} \\
&= \frac{12\text{ V}}{0.5\text{ A}} \\
&= 24 \,\Omega .
\end{align*}
$$
So, the resistance of the resistor is $24$ Ohms.
(b) The power dissipated in the resistor (P):
Now that we know the voltage across and current through the circuit, and have calculated the resistance above, we can calculate the electrical power using:
$$
\begin{align*}
P &= IV \\
&= I^2R \\
&= \frac {V^2}{R} .
\end{align*} …Excerpt — the full answer is on the round page.
▶ R50 · Thin lens equation: image distance and magnification Open round →
Given that the lens has a focal length ($f$) of $10 \text{ cm}$ and the object distance ($d_{\mathrm O}$) is $15 \text {cm}$, we can use the thin lens equation to find image distance ($d_{\mathrm I}$):
$$
\begin{equation*}
\frac{1}{f} = \frac{1}{d_{\mathrm{O}}} + \frac{1}{d_{\mathrm{I}}}\, .
\end{equation*}
$$
Plugging in the values:
$$
\begin{align*}
\frac{1}{0.10} &= \frac{1}{0.15} + \frac{1}{d_{\mathrm I}}\\
10 &= 6.67 + \frac{1}{d_{\mathrm I}} \\
3.33 & = \frac{1}{d_{\mathrm I}} \\
d_{\mathrm I} & = 0.30 \text {cm}\, .\\
\end{align*}
$$
(a) The image distance ($d_{\mathrm I}$) is $0.30$ cm behind the lens.
Now we can calculate magnification ($m$) using:
$$
\begin{equation*}
m = - \frac{d_{\mathrm{I}}}{d_{\mathrm O}}\, .
\end{equation*}
$$
Plugging in the values:
$$
\begin{align*}
m & = -\frac{0.30 \text { cm}}{15 \tex …Excerpt — the full answer is on the round page.
▶ R51 · Heat required to warm water (specific heat capacity) Open round →
To calculate the amount of heat energy required to raise the temperature of $2\text{ kg}$ of water from $20^\circ\text{C}$ to $80^\circ\text{C}$, we'll use the formula:
$$Q = m \cdot c \cdot ΔT, $$
where
- $m$ is the mass of the substance ($2\text{ kg}$),
- $c$ is the specific heat capacity of water ($4186\frac{\text{J}}{\text{kg}\cdot\text{K}})$, and
- $\Delta T = 80^\circ\text{C} - 20 ^\circ\text{C}$ is the temperature change.
Plugging in these values:
$$Q = (2 \text{ kg})(4186 \frac{\text{J}}{\text{kg}\cdot\text{K}})((80^\circ\text{C} - 20 ^\circ\text{C}))= 1000,320 \text{ J}.$$
Thus the amount of heat energy required is $\boxed{1000,320 \text{ J}}$ or about $\boxed{1.00 \text{ kJ}}$.▶ R52 · Fermi estimate: how many piano tuners in a 10-million-person city? Open round →
Here is a rough estimate using Fermi estimation for the number of professional piano tuners in a city with 10 million people: Assumption Chain: 1. Total Households: Assuming an average household size, say 4 persons per household, we can estimate that there are approximately 2.5 million households in a city of 10 million people (10,000,000 / 4). 2. Piano-Owning Households: Let's assume conservatively that only 1 out of every 100 households owns a piano. Thus, the number of households with pianos is estimated to be around 25,000 (2.5 million x 1/100). 3. Piano Tuning Frequency: On average, a piano needs to be tuned about once or twice a year. Let's assume an average of one tuning per year for simplicity. 4. Tunings Per Tuner: A professional piano tuner can typically tune around 200 pianos annually, considering the time needed for each tuning and other administrative tasks. Now, …
Excerpt — the full answer is on the round page.
▶ R53 · Why is the sky blue? (conceptual) Open round →
The sky appears blue during the day due to a fascinating physical phenomenon called Rayleigh scattering. When sunlight, which is white light composed of all colors, enters Earth's atmosphere, it interacts with gas molecules and tiny particles in the air, such as nitrogen and oxygen. These molecules are much smaller than the wavelength of visible light. As a result, they scatter the shorter wavelengths of light (blue and violet) more strongly compared to the longer wavelengths (red and orange). This scattering process sends blue light in various directions, including towards our eyes when we look up at the sky. Thus, we perceive the sky as being blue even though the Sun itself appears yellow or white from Earth's surface. The phenomenon is named after Lord Rayleigh, who first described this effect scientifically.
▶ R54 · Time dilation: why do moving clocks run slow? (conceptual, special relativity) Open round →
Special relativity tells us that time is not absolute but rather depends on an observer's frame of reference. Time dilation occurs when there are two objects or observers moving at a constant velocity with respect to each other; they will measure time differently due to their relative motion. Imagine two observers, Alice and Bob, each in their own spaceship traveling past each other at high speed. From the perspective of Alice, she sees herself as stationary while Bob is zooming by her very fast. Due to this rapid movement, some interesting effects occur according to special relativity. One such effect is that time appears to slow down for Bob when observed from Alice's reference frame. In other words, if Alice has a clock on her spaceship and compares it to the one in Bob's ship, she will notice that his clock ticks slower than hers. This doesn't mean that his clock actually runs sl …
Excerpt — the full answer is on the round page.
▶ R55 · The double-slit experiment and wave-particle duality (conceptual, quantum mechanics) Open round →
The double-slit experiment is a famous thought experiment in physics that reveals the intriguing nature of quantum mechanics. It demonstrates the paradoxical behavior of particles, such as electrons or photons, by showing how they can exhibit both wave-like and particle-like properties simultaneously. When individual particles are sent through two narrow slits towards a screen, an interesting pattern emerges on the screen. Instead of seeing two distinct bands of particles (one for each slit), we observe an interference pattern similar to what you'd expect from waves. This means that even though individual particles are being fired one at a time, they create an interference pattern as if multiple particles were interacting with each other, which is typically wave-like behavior. Now, when we introduce a 'which-path' detector to determine which slit the particle passes through (essential …
Excerpt — the full answer is on the round page.
▶ R56 · Double-slit interference, particle by particle Open round →
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Double Slit Experiment</title>
<style>
body {
margin: 0;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background-color: black;
}
canvas {
border: 2px solid white;
}
</style>
</head>
<body>
<canvas id="myCanvas"></canvas>
<script>
const canvas = document.getElementById('myCanvas');
const ctx = canvas.getContext('2d');
let particleCount = 0;
const maxParticles = 10000; // Maximum number of particles to fire
function getRandomPosition() {
const a = Math.sin(particleCount * 0.4) + 1;
return (a - Math.flo …Excerpt — the full answer is on the round page.
▶ R57 · Hanging rope with Verlet integration Open round →
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hanging Rope Simulation</title>
<style>
body {
margin: 0;
overflow: hidden;
}
canvas {
width: 100vw;
height: 100vh;
display: block;
}
</style>
</head>
<body>
<canvas id="simulation"></canvas>
<script>
const canvas = document.getElementById('simulation');
const ctx = canvas.getContext('2d');
let width, height;
let masses = [];
let constraints = [];
let dt = 0.0167; // delta time
let impulseInterval = 5; // apply sideways impulse every N seconds
let impulseCounter = impulseInterval;
function init() {
width = canvas.width = window.innerWidth …Excerpt — the full answer is on the round page.
▶ R58 · 2D wave propagation with reflection Open round →
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>2D Wave Simulation</title>
<style>
body {
margin: 0;
overflow: hidden;
}
canvas {
display: block;
}
</style>
</head>
<body>
<canvas id="waveCanvas"></canvas>
<script>
const canvas = document.getElementById('waveCanvas');
const ctx = canvas.getContext('2d');
const gridWidth = 120;
const gridHeight = 90;
const cellSize = Math.min(window.innerWidth, window.innerHeight) / Math.max(gridWidth, gridHeight);
const halfCellSize = cellSize * 0.5;
canvas.width = gridWidth * cellSize;
canvas.height = gridHeight * cellSize;
let amplitude = Array.from({ length: gridWidth }, () => new Flo …Excerpt — the full answer is on the round page.
▶ R59 · Billiard break with spin and friction Open round →
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Billiard Break Animation</title>
<style>
body {
margin: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #222;
}
canvas {
border: 3px solid #4CAF50;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}
</style>
</head>
<body>
<canvas id="billiardCanvas" width="600" height="600"></canvas>
<script>
const canvas = document.getElementById("billiardCanvas");
const ctx = canvas.getContext("2d");
// Ball properties
const ballRadius = 25;
const ballsPerRow = 4;
const gap = ballRadius * 2;
let balls = [] …Excerpt — the full answer is on the round page.
▶ R60 · Dijkstra vs A* on a weighted grid Open round →
```html
<!DOCTYPE html>
<html>
<head>
<style>
canvas { border: 1px solid black; }
</style>
</head>
<body>
<canvas id="panel1"></canvas>
<canvas id="panel2"></canvas>
<script>
function randRange(n, start) {
return Math.floor(start + (Math.random() * n));
}
function neighbours(i, j, w, h) {
var result = [];
for (var di=-1; di<=1; di++)
if (0 <= i+di && i+di < w)
for (var dj=-1; dj<=1; dj++)
if (!(dj==0 && di==0) && 0 <= j+dj && j+dj < h)
result.push({x:i+di, y:j+dj});
return result;
}
function getDistance(a, b) {
var dx = Math.abs(a.x - b.x);
var dy = Math.abs(a.y - b.y);
return dx + dy; // manhattan distance
}
function d …Excerpt — the full answer is on the round page.
▶ R61 · Convex hull built step by step Open round →
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Convex Hull Animation</title>
<style>
body { margin: 0; }
canvas { border: 1px solid #333; display: block; width: 50vw; height: 70vh; }
</style>
</head>
<body>
<canvas id="hullCanvas"></canvas>
<script>
const canvas = document.getElementById("hullCanvas");
const ctx = canvas.getContext('2d');
function randomInt(max) {
return Math.floor(Math.random() * max);
}
let currentStep = -1;
// Generate random points
function generateRandomPoints() {
const points = [];
for (let i = 0; i < 40; i++) {
points.push([randomInt(canvas.width), randomInt(canvas.height)]);
}
return points;
}
let points = generateRandomPoints() …Excerpt — the full answer is on the round page.
▶ R62 · Huffman tree from letter frequencies Open round →
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Huffman Compression Animation</title>
<style>
body { margin: 0; }
canvas { border: 1px solid black; display: block; margin: auto; }
</style>
</head>
<body>
<canvas></canvas>
<script>
// Huffman code data structure and helper functions
class Node {
constructor(char, freq) {
this.left = null;
this.right = null;
this.char = char;
this.freq = freq;
this.code = ""; // Code word for each character
}
getTotalFreq() {
let total = this.freq;
if (this.left) total += this.left.getTotalFreq();
if (this.right) total += this.right.getTotalFreq();
return total;
}
}
funct …Excerpt — the full answer is on the round page.
▶ R63 · Kruskal's MST with union-find Open round →
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<style>
/* CSS styles for the canvas and nodes */
#myCanvas {
border: 1px solid black;
width: 500px;
height: 500px;
}
.nodeCircle {
fill: white;
stroke: gray;
stroke-width: 2;
cursor: pointer;
}
</style>
</head>
<body>
<!-- HTML canvas element for drawing the graph -->
<canvas id="myCanvas"></canvas>
<script>
/* Global variables, functions and classes */
class UnionFind {
constructor(N) {
this.parent = Array.from({ length: N }, (_, i) => i);
this.rank = new Uint8Array(N);
}
find(x) {
if (this.parent[x] !== x) this.parent[x] = this.find(this.parent[x]);
return this.parent[x];
}
union(x, y) {
const …Excerpt — the full answer is on the round page.
▶ R64 · N-Queens solved by backtracking Open round →
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Solving 8 Queens Problem</title>
<style>
body {
margin: 0;
overflow: hidden;
}
canvas {
image-rendering: optimizeSpeed; /* Older versions of FF */
image-rendering: -moz-crisp-edges; /* FF 6+ */
image-rendering: -webkit-optimize-contrast; /* Safari 6+ */
image-rendering: crisp-edges; /* Experimental CSS (https://css-tricks.com/back-edge-anti-aliasing/) */
-ms-interpolation-mode: nearest-neighbor; /* IE, Edge (pre-16) */
}
</style>
</head>
<body>
<canvas></canvas>
<script>
const canvas = document.querySelector('canvas');
const ctx = canvas.getContext('2d');
let boardSize = 8; // Change between 6 and 10
let queens = [];
let counter = { …Excerpt — the full answer is on the round page.
▶ R65 · Delaunay triangulation, triangle by triangle Open round →
```html
<!DOCTYPE html>
<html>
<head>
<style>
canvas { width: 100vw; height: 100vh }
</style>
</head>
<body>
<canvas id="triangulate"></canvas>
<script>
const ctx = document.querySelector('canvas').getContext('2d'),
W = window.innerWidth, H = window.innerHeight;
let points, tris, t = 0, i = -1;
function random(x, y) {
return [
Math.random() * (y || W),
Math.random() * (x || H)
];
}
function drawPoints() {
ctx.strokeStyle = '#ccc';
points.forEach(([x, y]) => {
ctx.beginPath();
ctx.arc(x, y, 3, 0, 2*Math.PI);
ctx.stroke();
});
}
function drawTris() {
const [a, b, c] = tris[t];
ctx.fillStyle = '#ccc';
ctx.beginPath();
ctx.moveTo(points[a][0], points[a][1]);
for (let …Excerpt — the full answer is on the round page.
▶ R66 · AVL tree rebalancing with rotations Open round →
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AVL Tree Animation</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background-color: #f4f4f4;
}
canvas {
border: 2px solid black;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
}
</style>
</head>
<body>
<canvas id="avlTree"></canvas>
<script>
const canvas = document.getElementById('avlTree');
const ctx = canvas.getContext('2d');
class Node {
constructor(key) {
this.key = key;
this.left = null;
this.right = null;
this.height = 1; …Excerpt — the full answer is on the round page.
▶ R67 · Sieve of Eratosthenes on a number grid Open round →
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Sieve of Eratosthenes</title>
<style>
body {
margin: 0;
}
#container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
canvas {
border: 2px solid black;
}
</style>
</head>
<body>
<div id="container">
<canvas id="siegeCanvas"></canvas>
</div>
<script>
const maxNum = 400;
const cellSize = 10; // px
const canvasWidth = (maxNum - 2) * cellSize + 2 /* border */;
const canvasHeight = maxNum * cellSize;
function randomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
window.addEventListener('load', () => {
const ctx = document.g …Excerpt — the full answer is on the round page.
▶ R68 · Edit-distance DP matrix with backtrace Open round →
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Levenshtein Distance Animation</title>
<style>
body {
margin: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f4f4f4;
}
canvas {
border: 1px solid #333;
box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3);
}
</style>
</head>
<body>
<canvas id="matrixCanvas"></canvas>
<script>
const words = [["rebellion", "reaction"], ["substitution", "suggestion"]];
let wordIndex = Math.floor(Math.random() * words.length);
const [word1, word2] = words[wordIndex];
function min3(a, b, c) {
return Math.min(Math.min(a, b), c);
}
function getColor(operation) {
if (opera …Excerpt — the full answer is on the round page.
▶ R69 · Replanning when the map changes Open round →
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Robot Navigation</title>
<style>
body { margin: 0; }
canvas { border: 2px solid black; display: block; }
</style>
</head>
<body>
<canvas id="gameCanvas" width="640" height="480"></canvas>
<script>
const WALL = '#';
const EMPTY = ' ';
const ROBOT = '@';
const GOAL = '$';
let canvas, ctx;
let gridWidth = 30;
let gridHeight = 20;
let cellSize = 16;
let map, robotPos, goalPos, path, numReplans = 0, steps = 0, animationFrame;
window.onload = function() {
canvas = document.getElementById('gameCanvas');
ctx = canvas.getContext('2d');
// Initial setup and random map generation
map = generateMap();
robotPos = getRandomRobotPositi …Excerpt — the full answer is on the round page.
▶ R70 · Binary search, step by step Open round →
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Binary Search Visualization</title>
<style>
body {
margin: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f4f4f4;
}
canvas {
border: 2px solid #333;
box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.1);
}
</style>
</head>
<body>
<canvas id="myCanvas" width="800" height="400"></canvas>
<script>
const canvas = document.getElementById('myCanvas');
const ctx = canvas.getContext('2d');
function randomizeArray(min, max) {
return Array.from({ length: 40 }, () => Math.floor(Math.random() * (max - min + 1)) + min);
}
let array = randomizeArray(-50, 50);
let targetV …Excerpt — the full answer is on the round page.
▶ R71 · Flood fill on a pixel grid Open round →
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Flood Fill Animation</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background-color: #f4f4f4;
}
canvas {
border: 2px solid #333;
}
</style>
</head>
<body>
<canvas id="myCanvas" width="600" height="400"></canvas>
<script>
const canvas = document.getElementById('myCanvas');
const ctx = canvas.getContext('2d');
let gridSize = 10;
let cellSize = canvas.width / gridSize;
let cells = Array(gridSize).fill().map(() => Array(gridSize).fill()); // Grid of color codes
function randomInt(mi …Excerpt — the full answer is on the round page.
▶ R72 · Maze generation by recursive backtracking Open round →
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Recursive Backtracker Maze</title>
<style>
body {
margin: 0;
background-color: #222;
font-family: Arial, sans-serif;
color: #fff;
}
canvas {
display: block;
border: 4px solid #666;
box-shadow: 0 0 15px rgba(0, 0, 0, 0.8);
background-color: #eee;
}
</style>
</head>
<body>
<canvas id="mazeCanvas"></canvas>
<div class="info">Cells Carved: <span id="cellsCarved">0</span><br>Stack Depth: <span id="stackDepth">0</span></div>
<script>
const canvas = document.getElementById('mazeCanvas');
const ctx = canvas.getContext('2d');
let mazeWidth = 30;
let mazeHei …Excerpt — the full answer is on the round page.
▶ R73 · KMP string search with prefix table Open round →
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Knuth-Morris-Pratt Animation</title>
<style>
body {
margin: 0;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background-color: #f4f4f4;
}
canvas {
border: 2px solid black;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2);
}
</style>
</head>
<body>
<canvas id="myCanvas" width="600" height="400"></canvas>
<script>
const canvas = document.getElementById('myCanvas');
const ctx = canvas.getContext('2d');
function generateRandomString(length) {
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
let randomStr …Excerpt — the full answer is on the round page.
▶ R74 · Quadtree collision detection Open round →
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Quadtree Animation</title>
<style type="text/css">
body {margin: 0; overflow: hidden;}
canvas {display: block;}
</style>
</head>
<body>
<canvas></canvas>
<script type="application/javascript">
const c = document.querySelector('canvas'),
ctx = c.getContext('2d');
let width, height, balls, quadtree;
let nodesCreated = 0, numTests = 0;
function createRandomBalls() {
balls = [];
for (let i = 0; i < 120; i++) {
const radius = 5 + Math.random() * 5;
const x = radius + Math.random() * (width - 2 * radius);
const y = radius + Math.random() * (height - 2 * radius);
balls.push({x, y, radius});
}
}
function createQuadtree(ballRadius) {
quadtree = new QuadTree(new Rect(0, …Excerpt — the full answer is on the round page.
▶ R75 · Falling sand on a cell grid Open round →
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Falling Sand Simulation</title>
<style>
body { margin: 0; }
canvas { border: 1px solid black; }
</style>
</head>
<body>
<canvas id="game" width="450" height="300"></canvas>
<script>
const canvas = document.getElementById('game');
const ctx = canvas.getContext('2d');
let stepCount = 0;
let restingCells = 0;
const gridSizeX = 150;
const gridSizeY = 100;
let field = Array(gridSizeY).fill().map(() => Array(gridSizeX).fill(false));
function drawCell(x, y) {
ctx.fillStyle = 'rgba(247,239,154,0.8)'; // Sand color with some transparency
ctx.fillRect(x * 3, y * 3, 3, 3);
}
function isCellEmpty(x, y) {
return !field[y][x];
}
function setCellState( …Excerpt — the full answer is on the round page.
▶ R76 · Falling sand as free particles Open round →
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Falling Sand Simulation</title>
<style>
body { margin: 0; }
canvas { display: block; }
</style>
</head>
<body>
<canvas></canvas>
<script>
const canvas = document.querySelector('canvas');
const ctx = canvas.getContext('2d');
const W = window.innerWidth, H = window.innerHeight;
canvas.width = W; canvas.height = H;
const PI2 = Math.PI * 2, GRAVITY = 0.15, FRICTION = 0.98;
class Particle {
constructor() {
this.x = random(W);
this.y = -3 + random(H/5);
this.vx = (random(0.7) > 0.5 ? 1 : -1) * random(GRAVITY*2);
this.vy = GRAVITY;
}
update() {
if (!this.collides()) {
this.x += this.vx …Excerpt — the full answer is on the round page.
▶ R77 · Crowd leaving a room, cell by cell Open round →
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>People Leaving Room</title>
<style>
body { margin: 0; overflow: hidden }
canvas { image-rendering: pixelated }
</style>
</head>
<body>
<canvas></canvas>
<script>
let W = window, D = W.document, C = D.querySelector('canvas'),
X = C.getContext('2d'), T = 0, F = [], S = []
function R(n) { return Math.floor(Math.random() * n) }
function M(a, b) { return a[R(a.length)] + b }
for (let i=0; i < 60; i++) F.push([M('1234', '5'), M('6789', '')])
function P() {
let [x, y] = S[T % S.length]
X.fillStyle = '#' + (D.body.style.background === '#fff' ? '000' : 'f80')
X.fillRect(x * 16, y * 16, 16, 16)
}
function L() {
let f = F.shift(), d = [], p = [f[0]], i= …Excerpt — the full answer is on the round page.
▶ R78 · Crowd leaving a room by steering Open round →
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body { margin: 0; overflow: hidden; background: radial-gradient(ellipse at center,#92dbe3 4%,#556ee3) }
canvas { display: block; touch-action: none; image-rendering: -moz-crisp-edges; image-rendering: pixelated; }
</style>
</head>
<body>
<canvas></canvas>
<script>
const W = window.innerWidth || 300, H = window.innerHeight || 150, I = Math.round(H/20), B = .4;
let t = Date.now(), r = [], n = 60;
function V() {
return (Math.random()-Math.random()) * Math.sqrt(B) + B / 3;
}
for(let i=0;i<I;i++) r[i] = [];
function R(o,x,y){
let a = o*2*Math.PI/I, c = { x:W*.5+x*Math.cos(a), y:H*.5+y*Math.sin(a) };
r[o].push({ x:c.x, y …Excerpt — the full answer is on the round page.
▶ R79 · Aggregation on a lattice Open round →
```html
<!DOCTYPE html>
<html>
<head>
<style>
body { margin: 0; }
canvas { border: 1px solid black; display: block; }
</style>
</script>
</head>
<body>
<canvas id="myCanvas" width="400" height="300"></canvas>
<script>
const canvas = document.getElementById('myCanvas');
const ctx = canvas.getContext('2d');
let cluster = [];
let step = 0;
function drawGrid() {
ctx.fillStyle = 'white';
ctx.fillRect(0, 0, canvas.width, canvas.height);
for (let i = 0; i <= canvas.width / 20; i++) {
const x = i * 20 + 10;
ctx.beginPath();
ctx.moveTo(x-2, 30);
ctx.lineTo(x+2, 30);
ctx.stroke();
}
for (let j = 0; j <= canvas.height / 15; j++) {
const y = j * 15 + 7.5; …Excerpt — the full answer is on the round page.
▶ R80 · Aggregation by continuous drift Open round →
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Particle Clustering</title>
<script>
const canvas = document.getElementById("myCanvas");
const ctx = canvas.getContext("2d");
let clusterRadius = 0;
let stuckParticles = 0;
let particles = [];
function init() {
for (let i = 0; i < 800; i++) {
createParticle();
}
animate();
}
function createParticle(x = Math.random(), y = Math.random()) {
const radius = 1 + 2 * Math.random();
particles.push({
x: canvas.width / 2,
y: canvas.height / 2,
vx: (Math.random() - 0.5) * 0.2,
vy: (Math.random() - 0.5) * 0.2,
radius
});
}
function animate() {
ctx. …Excerpt — the full answer is on the round page.
▶ R81 · Flocking birds with three rules Open round →
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
canvas { border: 2px solid black; }
</style>
</head>
<body style="background-color:black;">
<canvas id="myCanvas" width="400" height="400"></canvas>
<script type="application/javascript">
const canvas = document.getElementById("myCanvas"),
context = canvas.getContext("2d"),
w = canvas.width, h = canvas.height;
let numBirds = 200,
maxFlocks = Math.floor(numBirds / 10),
birds = [...Array(numBirds).keys()].map(() => ({
x: getRandomCoord(w), y: getRandomCoord(h),
dx: randomInRange(-5, 5) * w, dy: randomInRange(-5, 5) * h
})),
flocks = Array.from({ length: maxFlocks }, () => []),
flockSize = [], avgSpeed = [];
let numFlocks = countDistinctFlocks();
function countDistinctFlocks() {
return flockSize.f …Excerpt — the full answer is on the round page.
▶ R82 · Conway's Game of Life with seeded patterns Open round →
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Conway's Game of Life</title>
<style>
body {
margin: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #222; /* Dark background */
font-family: monospace;
color: white;
}
canvas {
border: 4px solid black;
image-rendering: crisp-edges; /* For pixelated look */
}
</style>
</head>
<body>
<canvas id="gameCanvas" width="120" height="80"></canvas>
<div class="stats">
Generation: <span id="generation">0</span><br>
Live Cells: <span id="liveCells">0</span>
</div>
<script>
const canvas = document.getEle …Excerpt — the full answer is on the round page.
▶ R83 · Fourier epicycles tracing a shape Open round →
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Fourier Epicycles</title>
<style>
body {
margin: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #222;
}
canvas {
border: 2px solid #fff;
}
</style>
</head>
<body>
<canvas id="myCanvas"></canvas>
<script>
const canvas = document.getElementById('myCanvas');
const ctx = canvas.getContext('2d');
let radius = [];
let speed = [];
function generateRandomFourierCoefficients() {
// Target shape is a simple closed curve (e.g., circle or square)
const numHarmonics = 5; // Number of Fourier harmonics to use
const maxRadius = 100; // Maxim …Excerpt — the full answer is on the round page.
▶ R84 · Voronoi cells with moving seeds Open round →
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Voronoi Animation</title>
<style>
body { margin: 0; }
canvas { display: block; }
</style>
</head>
<body>
<canvas></canvas>
<script>
const seedCount = 25,
w = window.innerWidth || innerWidth,
h = window.innerHeight || innerHeight,
cellCountSpan = document.createElement('span'),
maxAreaSpan = document.createElement('span'),
canvas = document.querySelector('canvas');
cellCountSpan.style.cssText = 'position: absolute; top: 10px; left: 50%; transform: translateX(-50%); font-family: monospace;',
maxAreaSpan.style.cssText = 'position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); color: #666; font-family: monospace;',
canvas.width = w, canvas.height …Excerpt — the full answer is on the round page.
▶ R85 · Travelling salesman improved by 2-opt Open round →
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Traveling Salesman Animation</title>
<style>
body {
margin: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f4f4f4;
}
canvas {
border: 2px solid #333;
box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.1);
}
</style>
</head>
<body>
<canvas id="tspCanvas" width="800" height="600"></canvas>
<script>
const canvas = document.getElementById('tspCanvas');
const ctx = canvas.getContext('2d');
const numCities = 60;
let cities = [];
let tour = [];
let improvements = 0;
let totalLength = Infinity;
fun …Excerpt — the full answer is on the round page.
▶ R86 · Scrolling terrain from value noise Open round →
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Endless Noise Landscape</title>
<style>
body {
margin: 0;
overflow: hidden;
}
canvas {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.offset {
font-family: monospace;
color: #fff;
background: rgba(0, 0, 0, 0.7);
padding: 4px;
position: absolute;
top: 10px;
left: 10px;
}
</style>
</head>
<body>
<canvas id="world"></canvas>
<div class="offset">Offset: 0</div>
<script>
const canvas = document.getElementById('world');
const ctx = canvas.getContext('2d');
let offset = 0; // Horizontal scroll offset
let octaves = [ // Nois …Excerpt — the full answer is on the round page.
▶ R87 · Gray-Scott reaction-diffusion Open round →
```html
<canvas id="c"></canvas>
<script>f=()=>{with(c={width:600,height:600,getContext:e=>({fillRect:(i,n,r,l)=>(s=[255*Math.random(),180*Math.random(),70*Math.random()],o=(t,a,u)=>[w=((t/=255)-.3)/F,.6/F*(a/=255-.1),(n=.9+e*.04-e**3)/(b*=.999+.001*e)],function({dx:g,dy:p},m){for(u=t=>o(s[t],l+=g,m+=p);s&&50> ++a;)for(d=[0,h.width];++x<d[1]&&++y<d[0];)e=4*y+3*d[1]+2*(w=x),u(b,o(b,i[w],l)),u(n,o(n,v[w],m));s=[i,v]=
[v,i]})},fillStyle:"#fff"}))t.clearRect(0,0,c.width,c.height),t.fillRect(...s=c.width/2-25,.9*c.height,.5*c.width+50,-1),e.fillImage(i,0,0),requestAnimationFrame(f))}with({buffer:a=[new Uint8ClampedArray(4*h.width*h.height)],dx:[1,0],dy:[0,1],F:.06})for(x=h.width;x--;)for(y=h.height;y--;)a[0][e=4*y+3*h.width+2*x]=o(n=.5,.5,-.06);f();setInterval(()=>{with({buffer:a=[new Uint8ClampedArray(b=a[1]),new Uint8ClampedArray(c=a[0])],dx:[1,0,1,-1],dy:[0,1,-1,0]})for(x=h.width;x--;)for( …Excerpt — the full answer is on the round page.
▶ R88 · L-system tree growing in wind Open round →
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Fractal Tree</title>
<style>
body {
margin: 0;
overflow: hidden;
}
canvas {
display: block;
}
</style>
</head>
<body>
<canvas id="fractal-tree"></canvas>
<script>
const LSystem = {
axiom: 'X',
rules: {
X: 'F+[[X]+]FX--FX',
F: 'FF'
},
angle: Math.PI / 3, // Angle between branches
stepSize: 50, // Length of each branch segment
};
class Node {
constructor(x, y) {
this.x = x;
this.y = y;
this.dx = Math.cos(LSystem.angle);
this.dy = Math.sin(LSystem.angle); …Excerpt — the full answer is on the round page.
▶ R89 · Marching squares on a moving fieldDNF Open round →
▶ R90 · Poisson-disk sampling, Bridson's algorithm Open round →
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Poisson Disk Sampling</title>
<style>
body { margin:0; }
canvas { display:block; image-rendering:optimizeSpeed; }
</style>
</head>
<body>
<canvas></canvas>
<script>
let width, height, gridSize, samples, cells, radius, active;
function Cell(x, y) {
this.x = x;
this.y = y;
};
const makeGrid = (w, h, s) => {
const c = [];
for (let i=0; i<Math.ceil(h/s); ++i) {
let row = [];
for (let j=0; j<Math.ceil(w/s); ++j) {
row.push(new Cell(j*s, i*s));
}
c.push(row);
}
return c;
};
const distanceSq = (x1, y1, x2, y2) => {
let dx = x1 - x2;
let dy = y1 - y2 …Excerpt — the full answer is on the round page.
▶ R91 · Starfield tunnel in perspective Open round →
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="stylesheet" type="text/css" href="#" />
<script type="application/javascript">
const canvas = document.getElementById("game");
const context = canvas.getContext("2d");
let stars = [];
let speed = 0.1;
let starCount = 500;
class Star {
constructor(x, y) {
this.x = x;
this.y = y;
this.z = 300 + Math.random() * 900; // Random z-coordinate for perspective depth
this.vx = -1 + 2 * Math.random();
this.vy = -1 + 2 * Math.random();
}
}
function init() {
context.fillStyle = "rgba(0, 0, 0, 1)";
context.fillRect(
0,
0,
canvas.width,
canvas.height
);
for (let i = 0; i < starCount; i++) {
stars[i] = new Star( …Excerpt — the full answer is on the round page.
▶ R92 · Rotating wireframe solids with depth sorting Open round →
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
canvas { border: 1px solid black; }
</style>
</head>
<body>
<canvas id="myCanvas" width="500" height="500"></canvas>
<script type="application/javascript">
// Cube and another polyhedron vertices & edges
const cubeVerts = [
[ 1, 1, 1 ], [-1, 1, 1 ], [-1,-1, 1 ], [ 1,-1, 1 ],
[ 1, 1,-1 ], [-1, 1,-1 ], [-1,-1,-1 ], [ 1,-1,-1 ]
];
const cubeEdges = [
[0,1], [1,2], [2,3], [3,0], // bottom face
[4,5], [5,6], [6,7], [7,4], // top face
[0,4], [1,5], [2,6], [3,7] // connecting faces
];
const octaVerts = [
[ 1,-1, 0 ], [-1,-1, 0 ], [-1, 1, 0 ], [ 1, 1, 0 ],
[ 0, 0, 1 ], [ 0,-1, 1 ]
];
const octaEdges = [
[0,4],[0,3],[1,4],[1,2],[2,3],[3,5],[2,5] // faces of the octahedron
];
// Per …Excerpt — the full answer is on the round page.
▶ R93 · Rotating wireframe height field Open round →
```html
<!DOCTYPE html>
<html>
<head>
<style>
body {
margin: 0;
}
canvas {
display: block;
}
</style>
</head>
<body>
<canvas id="canvas"></canvas>
<script>
const canvas = document.getElementById("canvas");
const ctx = canvas.getContext("2d");
function smoothStep(edge0, edge1, x) {
let t = Math.max(0, Math.min(1, (x - edge0) / (edge1 - edge0)));
return t * t * (3 - 2 * t);
}
function lerp(a, b, ratio) {
return a + (b - a) * ratio;
}
function drawGrid(gridSize, angle, time) {
const halfWidth = gridSize / 2;
ctx.clearRect(0, 0, canvas.width, canvas.height);
for (let x = -halfWidth; x <= halfWidth; x++) {
for (let y = -halfWidth; y <= halfWidth; y++) {
const height = Math.sin((x * time + angle) / gridSize) * 30; …Excerpt — the full answer is on the round page.
▶ R94 · Raycast maze walkthrough Open round →
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Grid Maze Raycasting</title>
<style>
body { margin: 0; overflow: hidden; }
canvas { display: block; }
</style>
</head>
<body>
<canvas></canvas>
<script>
const canvas = document.querySelector("canvas");
const ctx = canvas.getContext("2d");
const WIDTH = canvas.width = window.innerWidth;
const HEIGHT = canvas.height = window.innerHeight;
let posX, posY, ang, grid, animId, cellSize = 30;
init();
function init() {
posX = -WIDTH/2 + cellSize * 5; // Start position x
posY = HEIGHT/2 - cellSize * 5; // Start position y
ang = Math.PI / 2; // Starting angle (facing right)
grid = generateMaze(); …Excerpt — the full answer is on the round page.
▶ R95 · Shaded sphere by painter's algorithm Open round →
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Rotating Sphere</title>
<style>
body {
margin: 0;
overflow: hidden;
}
canvas {
display: block;
}
</style>
</head>
<body>
<canvas id="sphereCanvas"></canvas>
<script>
const canvas = document.getElementById('sphereCanvas');
const ctx = canvas.getContext('2d');
let width, height;
let centerX, centerY;
const radius = 100;
let theta = 0;
const numPoints = 500; // Number of points on the sphere surface
const pointRadius = 4;
const lightDir = {x: 0.3, y: -0.6};
function randomInRange(min, max) {
return min + Math.random() * (max - min);
}
class Point {
constructor(x, y) {
this.x = x; …Excerpt — the full answer is on the round page.
▶ R96 · Force-directed graph settling Open round →
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Force Simulation Graph</title>
<style>
body {
margin: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f4f4f4;
}
canvas {
border: 2px solid black;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
}
</style>
</head>
<body>
<canvas id="simulationCanvas"></canvas>
<script>
const canvas = document.getElementById('simulationCanvas');
const ctx = canvas.getContext('2d');
let nodes = [];
let edges = [];
let nodeCount;
let energy;
let tickIndex = 0;
function randomInCircle(radius) {
const angle = Math.random() * 2 * Math.PI;
return { …Excerpt — the full answer is on the round page.
▶ R97 · Circle packing without overlap Open round →
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Packing Circles</title>
<script type="text/javascript">
const canvas = document.createElement("canvas");
document.body.appendChild(canvas);
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
let circles = [];
let size = 800;
let context;
function init(size){
canvas.width = canvas.height = size;
context = canvas.getContext("2d");
circles = [];
}
init(size);
function draw() {
requestAnimationFrame(() => {draw();});
if (circles.length === 0) {
init(size);
}
context.fillStyle = "black";
context.fillRect(0, 0, canvas.width, canvas.height);
let circle;
if (circles.length ===0){
circle = { x: getRandomInt(size/4, size*3/4), y: getRandomInt(si …Excerpt — the full answer is on the round page.
▶ R98 · Squarified treemap of changing data Open round →
```html
<!DOCTYPE html>
<html>
<head>
<style>
canvas {
border: 1px solid black;
}
</style>
</head>
<body>
<canvas id="treemap"></canvas>
<script>
const ctx = document.getElementById("treemap").getContext("2d");
class Node {
constructor(val, x, y, w, h) {
this.val = val;
this.x = x;
this.y = y;
this.w = w;
this.h = h;
this.labelVisible = false;
}
draw() {
ctx.fillStyle = "rgb(255, 100, 10)";
ctx.fillRect(this.x - 0.5, this.y - 0.5, this.w + 1, this.h + 1);
}
animate(targetNode) {
const distX = targetNode.x - this.x;
const distY = targetNode.y - this.y;
const distW = targetNode.w - this.w;
const distH = targetNode.h - this.h;
if (Math.abs(distX) < 1 && Math.abs(dist …Excerpt — the full answer is on the round page.
▶ R99 · Three sorting algorithms racing Open round →
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sorting Algorithms Visualization</title>
<style>
body {
margin: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f4f4f4;
}
canvas {
border: 2px solid #333;
box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2);
}
</style>
</head>
<body>
<canvas id="sortCanvas" width="600" height="400"></canvas>
<script>
const canvas = document.getElementById('sortCanvas');
const ctx = canvas.getContext('2d');
function randomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
class SortingAlgorithm …Excerpt — the full answer is on the round page.
▶ R100 · Sankey flow with travelling particles Open round →
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Sankey Diagram</title>
<style>
body {
margin: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
canvas {
background: #2e3440;
border: 5px solid #bccbd6;
box-sizing: border-box;
}
</style>
</head>
<body>
<canvas id="myCanvas"></canvas>
<script>
const ctx = document.getElementById("myCanvas").getContext("2d");
let particleData = [];
function random(min, max) {
return Math.random() * (max - min) + min;
}
class Particle {
constructor(x, y, dx, dy, color) {
this.x = x;
this.y = y;
this.dx = dx ? dx : random(-10, 10);
this.dy = dy ? dy : random(-5, 5);
this.color = color; …Excerpt — the full answer is on the round page.
▶ R101 · Langton's ant building a highway Open round →
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Langton's Ant</title>
<style>
body {
margin: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #222;
}
canvas {
border: 2px solid #333;
image-rendering: optimizeSpeed; /* Older versions of Firefox */
image-rendering: -moz-crisp-edges; /* Firefox */
image-rendering: -webkit-optimize-contrast; /* Safari */
image-rendering: pixelated;
}
</style>
</head>
<body>
<canvas></canvas>
<script>
let canvas = document.querySelector('canvas')
let ctx = canvas.getContext('2d')
const cellSize = 6
const gridWidth = 100
const gridHeight = 90
const antSpeed = 25
class Ant {
constructor() { …Excerpt — the full answer is on the round page.
▶ R102 · Rule 110 growing line by line Open round →
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Rule 110 Cellular Automaton</title>
<style>
body { margin: 0; }
canvas { border: solid black 2px; background: white; display: block; margin: auto; }
</style>
</head>
<body>
<canvas id="ca" width="500" height="500"></canvas>
<script>
const ca = document.getElementById("ca");
const ctx = ca.getContext("2d");
let running = false;
let rowCountdown = 1;
let frameCountdown = 7;
function draw() {
if (!running) return;
requestAnimationFrame(draw);
const w = ca.width / 3, h = ca.height / 500;
ctx.clearRect(0, 0, ca.width, ca.height);
ctx.fillStyle = "black";
for (let x = 1; x < w - 1; ++x) {
if (!frameCountdown--) {
--rowCountdown; frameCountdown = 7; }
const y = Math.floor(ca.height / h * rowCountdown);
ctx.fillRect(x*3 …Excerpt — the full answer is on the round page.
▶ R103 · Wireworld with a clock and a diode Open round →
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Wireworld Circuit</title>
<style>
body { margin:0; }
canvas { border:1px solid black; }
</style>
</head>
<body>
<canvas id="circuit"></canvas>
<script>
const CELL_EMPTY = 0, CELL_CONDUCTOR = 1, CELL_HEAD = 2, CELL_TAIL = 3;
let canvas, ctx, width, height, cellSize, stepCountEl, electronCountEl, stepCount = 0, electronCount = 0, running = false,
circuit = [], diodeStartX = null, diodeStartY = null;
function init() {
canvas = document.getElementById('circuit');
ctx = canvas.getContext('2d');
width = height = 16 * (8 + 3); // 16 cells plus 3 pixel gap each side
cellSize = Math.min(width, height) / width;
canvas.width = width * cellSize;
canvas.height = height * cel …Excerpt — the full answer is on the round page.
▶ R104 · Abelian sandpile toppling Open round →
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Abelian Sandpile</title>
<style>
body { margin: 0; }
canvas { display: block; image-rendering: -moz-crisp-edges; image-rendering: -webkit-crisp-edges; image-rendering: pixelated; image-rendering: crisp-edges; }
</style>
</head>
<body>
<canvas></canvas>
<script>
let drops = 0, topples = 0;
const colors = ["#4158D0", "#A43EEB", "#E22CBF", "#FF6161", "#FFA801"];
function randomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
class Grid {
constructor(size = 400, cellSize = 15) {
this.grid = new Array(size).fill(null).map(() => new Array(size).fill({ grains: 0 }));
this.canvas = document.querySelector("canvas");
this.ctx = this.canvas.get …Excerpt — the full answer is on the round page.
▶ R105 · Brian's Brain Open round →
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Brian's Brain</title>
<style>
body { background: #0A1216; color: whitesmoke; font-family: monospace,monospace; }
canvas { border: 5px solid #97C3E1; display: block; margin: 2vmin auto; }
</style>
</head>
<body>
<h1>Brian's Brain</h1>
<p>A cellular automaton.</p>
<canvas></canvas>
<script type="text/javascript">
const canvas = document.querySelector('canvas')
, context = canvas.getContext('2d')
;
const cw = ( canvas.width = Math.floor( window.innerWidth / 10 ) * 8 ),
ch = ( canvas.height = Math.floor( window.innerHeight / 9 ) * 7 )
, grid = Array(ch).fill().map(() => Array(cw).fill(Math.random() > 0.5))
;
let gen = 1;
function drawGrid(){
const bg = cont …Excerpt — the full answer is on the round page.
▶ R106 · Truchet tiles rearranging Open round →
<!DOCTYPE html>
<html>
<head>
<style>
body { margin: 0; }
canvas { display: block; cursor: crosshair; }
</style>
</head>
<body>
<canvas></canvas>
<script>
const canvas = document.querySelector('canvas')
const ctx = canvas.getContext('2d')
let gridSize = 50
let tilesFlipped = 0
function drawTile(x, y, orientation) {
ctx.save()
// Translate to the tile position and scale for the grid size
ctx.translate(x * gridSize + gridSize / 2, y * gridSize + gridSize / 2)
ctx.scale(gridSize / 100, gridSize / 100)
if (orientation === 'right') {
// Draw a quarter circle for the right tile part
ctx.beginPath()
ctx.arc(50, 0, 50, Math.PI * 3 / 2, -Math.PI / 2, false)
ctx.fillStyle = '#ffffff'
ctx.fill()
} else {
// Draw a quarter ci …Excerpt — the full answer is on the round page.
▶ R107 · Hilbert curve drawing itself Open round →
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Hilbert Curve</title>
<style>
body {
margin: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background: #2d3436;
}
canvas {
border: 3px solid #f3c72a;
}
</style>
</head>
<body>
<canvas id="hilbertCanvas"></canvas>
<script>
const canvas = document.getElementById('hilbertCanvas');
const ctx = canvas.getContext('2d');
let order = 6;
let points = [];
function getHilbertPoints(x, y, level) {
if (level === 0) return [[x, y]];
const A = getHilbertPoints(x, y, level - 1);
const B = getHilbertPoints(x + 1, y, level - 1);
const C = getHilbertPoints(x, y + 1, level …Excerpt — the full answer is on the round page.
▶ R108 · Interlocking star pattern on a grid Open round →
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Islamic Star Pattern</title>
<style>
body {
margin: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #0e0e12;
}
canvas {
border: 3px solid #ff6a00;
}
</style>
</head>
<body>
<canvas id="myCanvas"></canvas>
<script>
const canvas = document.getElementById('myCanvas');
const ctx = canvas.getContext('2d');
let gridSize = 50; // Initial grid size
let rotationSpeed = 0.01; // Speed of rotation (adjust as needed)
function drawGrid() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
const cel …Excerpt — the full answer is on the round page.
▶ R109 · Moire from two rotating rasters Open round →
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Moire Effect Animation</title>
<style>
body {
margin: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: black;
}
canvas {
border: 2px solid #fff;
}
</style>
</head>
<body>
<canvas id="moireCanvas"></canvas>
<script>
const canvas = document.getElementById('moireCanvas');
const ctx = canvas.getContext('2d');
let angle = 0;
let offsetX = 0;
let finished = false;
const ringCount = Math.floor(Math.random() * 15) + 30; // Random number of rings, min: 30, max: 45
const radiusStep = canvas.width / (ringCo …Excerpt — the full answer is on the round page.
▶ R110 · Penrose-style aperiodic tiling growing Open round →
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Aperiodic Rhombus Tiling</title>
<style>
body {
margin: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f4f4f4;
}
canvas {
border: 2px solid black;
background-color: white;
}
</style>
</head>
<body>
<canvas id="aperiodicTiling"></canvas>
<script>
const canvas = document.getElementById('aperiodicTiling');
const ctx = canvas.getContext('2d');
let generation = 0;
let tileCount = 1;
function drawRhombus(x, y, width, color) {
ctx.beginPath();
ctx.moveTo(x + width / 2, y); …Excerpt — the full answer is on the round page.
▶ R111 · Ant colony laying pheromone trails Open round →
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Ant Colony Simulation</title>
<style>
body {
margin: 0;
overflow: hidden;
}
canvas {
width: 100vw;
height: 100vh;
}
</style>
</head>
<body>
<canvas id="simulation"></canvas>
<script>
const canvas = document.getElementById('simulation');
const ctx = canvas.getContext('2d');
let ants = [];
let foodSources = [];
let pheromoneField = [];
let antCount = 50;
let foodFound = 0;
function createAnt() {
return {
x: Math.random() * canvas.width,
y: Math.random() * canvas.height,
angle: Math.random() * 2 * Math.PI, …Excerpt — the full answer is on the round page.
▶ R112 · Physarum slime-mould network Open round →
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Physarum Simulation</title>
<style>
body { margin: 0; }
canvas { display: block; image-rendering: -moz-crisp-edges; image-rendering: -webkit-crisp-edges; image-rendering: pixelated; image-rendering: crisp-edges; }
</style>
</head>
<body>
<canvas></canvas>
<script>
const canvas = document.querySelector('canvas')
const ctx = canvas.getContext('2d')
let width = 0, height = 0
let trailMap, agentCount, step, angle
let startX, startY
function init() {
width = canvas.width = window.innerWidth;
height = canvas.height = window.innerHeight;
ctx.fillStyle = "black";
ctx.fillRect(0, 0, width …Excerpt — the full answer is on the round page.
▶ R113 · Predator and prey on a shared field Open round →
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Predators and Prey Simulation</title>
<style>
body { margin: 0; }
canvas { border: 2px solid black; display: block; }
</style>
</head>
<body>
<canvas id="world"></canvas>
<script>
const WORLD = document.getElementById('world');
const SIM = WORLD.getContext('2d');
let FOOD, PREY, PREDATORS;
let FOOD_GROWTH = 0.5;
let FOOD_SPEED = 1;
let PREY_REPRODUCTION_RATE = 0.3;
let PREDATOR_HUNGER_RATE = 0.8;
let PREDATOR_SPEED = 2;
const WORLD_WIDTH = WORLD.width = window.innerWidth;
const WORLD_HEIGHT = WORLD.height = window.innerHeight;
function init() {
FOOD = [];
PREY = [];
PREDATORS = [];
for (let i=0; i<WORLD_WIDTH*WORLD_HEIGHT/5000; i …Excerpt — the full answer is on the round page.
▶ R114 · Traffic jam from nothing Open round →
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Nagel-Schreckenberg Simulation</title>
<style>
body { margin: 0; }
canvas { border: solid 1px black; background: white; display: block; margin: auto; max-width: 100%; height: auto;}
</style>
</head>
<body>
<canvas id="grid" width="800" height="250"></canvas>
<script>
const canvas = document.getElementById('grid');
const ctx = canvas.getContext('2d');
let cars, maxSpeed, dawdleProb;
function init() {
reset();
animate();
}
function reset() {
const numCars = 80;
maxSpeed = 15;
dawdleProb = 0.3;
const spacing = canvas.width / (numCars + 1);
cars = Array.from({ length: numCars }, () => ({
x: i => i * spacing, …Excerpt — the full answer is on the round page.
▶ R115 · Crowd leaving through a bottleneck Open round →
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Crowd Simulation</title>
<style>
body {
margin: 0;
overflow: hidden;
background-color: #111;
}
canvas {
display: block;
}
</style>
</head>
<body>
<canvas id="simulationCanvas"></canvas>
<script>
const canvas = document.getElementById('simulationCanvas');
const ctx = canvas.getContext('2d');
let people = [];
let MAX_PEOPLE = 300;
let roomWidth = 400;
let roomHeight = 400;
let exitX = roomWidth - 50;
let doorWidth = 100;
function createPeople() {
for (let i = 0; i < MAX_PEOPLE; i++) {
people.push({
x: Math.ran …Excerpt — the full answer is on the round page.
▶ R116 · Bresenham circles and lines, pixel by pixel Open round →
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Bresenham's Algorithm Animation</title>
<style>
body {
margin: 0;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
background-color: #f4f4f4;
}
canvas {
border: 2px solid black;
background: white;
}
</style>
</head>
<body>
<canvas id="bresenhamCanvas"></canvas>
<script>
(function () {
'use strict';
const canvas = document.getElementById('bresenhamCanvas');
const context = canvas.getContext('2d');
function drawLine(x0, y0, x1, y1) {
let dx = Math.abs(x1 - x0);
let dy = Math.abs(y1 - y0);
let sx = x0 < x1 ? 1 : -1;
let sy = y0 < y1 ? 1 : -1;
let err = dx - dy;
while (true) { …Excerpt — the full answer is on the round page.
▶ R117 · De Casteljau construction of a Bezier curve Open round →
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>De Casteljau Construction</title>
<style>
canvas { border: 1px solid black; }
</style>
</head>
<body>
<canvas id="myCanvas" width="600" height="400"></canvas>
<script>
c=document.getElementById("myCanvas");w=c.width;h=c.height;ctx=c.getContext("2d");cls=()=>ctx.clearRect(0,0,w,h);pt=(x,y)=>ctx.fillText(`${Math.round(x)},${Math.round(y)}`,x+10,y-5);draw=t=>{ctx.strokeStyle="#ccc";ctx.lineWidth=.2;cls();ctx.beginPath();[p0,p1,p2,p3]=[[46,280],[587,274],[96,161],[572,153]];[[p0,p1,p2],[p1,p2,p3]].forEach((pts,i)=>{ctx.moveTo(pts[0][0],pts[0][1]);for(j=1;j<3;++j){ctx.lineTo(pts[j][0],pts[j][1]);pt(pts[j][0],pts[j][1])}});ctx.stroke();ctx.beginPath();ctx.moveTo(p0[0],p0[1]);for(i=1;i<4;++i){x=(1-t)**(4-i)*p0[0]+(4-i)*(1-t)**(3-i)*t*p1[0]+(choose(3,i)-choose(2,i-1))*(1-t)**(4-(i+1))*t**2*p2[0]+ …Excerpt — the full answer is on the round page.
▶ R118 · Sutherland-Hodgman polygon clipping Open round →
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Sutherland-Hodgman Clipping</title>
<style>
body {
margin: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
#canvas-wrapper {
background: rgba(255, 255, 255, 0.7);
padding: 3px;
border: 1px solid black;
}
</style>
</head>
<body>
<div id="canvas-wrapper">
<canvas id="myCanvas" width="600" height="400"></canvas>
</div>
<script>
const canvas = document.getElementById("myCanvas");
const ctx = canvas.getContext("2d");
// Clipping window dimensions
let winWidth = 500;
let winHeight = 300;
function randomInt(min, max) {
return Math.floor(Math.random() * (max - min …Excerpt — the full answer is on the round page.
▶ R119 · Floyd-Steinberg dithering a gradient Open round →
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Floyd-Steinberg Dithering</title>
<style>
body {
margin: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
#animation-container {
position: relative;
width: 640px;
height: 360px;
}
</style>
</head>
<body>
<div id="animation-container">
<canvas id="ditheringCanvas" width="640" height="360"></canvas>
<p class="info">Palette Size: <span id="paletteSize">N/A</span></p>
<p class="info">Frame: <span id="frameCount">N/A</span></p>
</div>
<script>
const canvas = document.getElementById('ditheringCanvas');
const ctx = canv …Excerpt — the full answer is on the round page.
▶ R120 · Scanline fill of a self-intersecting polygon Open round →
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Scanline Algorithm</title>
<style>
body { margin: 0; }
canvas { display: block; }
</style>
</head>
<body>
<script>
const canvas = document.createElement('canvas');
document.body.append(canvas);
const ctx = canvas.getContext('2d');
let w = window.innerWidth, h = window.innerHeight;
if (w > 800) {
w = 800;
h = Math.round(800 * (h / w));
}
canvas.width = w;
canvas.height = h;
const a_step = 2 * Math.PI / 36, b_step = 1.5 * Math.PI / 36, c_step = .87 * Math.PI / 36, d_step = 4 * Math.PI / 36;
let a = 0, b = 0, c = 0, d = 0;
function init() {
a = Math.random() * (2 * Math.PI);
b = Math.random() * (2 * Math.PI) - .5;
c = 1 + Math.random() * (1.3);
d = 0;
}
function drawPoint(x, y) {
ctx.fillStyle …Excerpt — the full answer is on the round page.
▶ R121 · A* pathfinding search across an obstacle grid Open round →
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>A* Search Visualization</title>
<style>
body {
margin: 0;
overflow: hidden;
}
button {
position: absolute;
top: 10px;
right: 10px;
z-index: 999;
}
</style>
</head>
<body>
<button id="restartButton">Restart</button>
<canvas id="aStarCanvas"></canvas>
<script>
const canvas = document.getElementById("aStarCanvas");
const ctx = canvas.getContext("2d");
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
let restartButton = document.getElementById("restartButton");
function restart() {
generateMaze();
drawGrid();
}
restartButton.addEventListener('click', restart);
const gridSize = 20;
const cellSize = Math.floor(canvas …Excerpt — the full answer is on the round page.
▶ R122 · Randomized maze generation via recursive backtracking Open round →
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Randomized Maze Generation</title>
<style>
body {
margin: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f4f4f4;
}
canvas {
border: 2px solid black;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
}
</style>
</head>
<body>
<canvas id="mazeCanvas"></canvas>
<script>
const canvas = document.getElementById("mazeCanvas");
const ctx = canvas.getContext("2d");
let width = 50; // Grid width (number of cells)
let height = 50; // Grid height (number of cells)
let cellSize = Math.min(canvas.width / width, canvas.he …Excerpt — the full answer is on the round page.
▶ R123 · Breadth-first flood fill spreading through a region Open round →
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Breadth-First Flood Fill</title>
<style type="text/css">
body {
margin: 0;
overflow: hidden;
}
canvas {
display: block;
}
</style>
</head>
<body>
<canvas></canvas>
<script type="application/javascript">
const colors = ["#6F6", "#AF8", "#ED9"]; // 3 shades of green for distance coloring
function randomInt(n) { return Math.floor(Math.random() * n); } // helper func for random int in [0,n)
function drawGrid(ctx, w, h) {
ctx.fillStyle = "#262"; ctx.fillRect(0, 0, w, h); // dark green background
for (let x=1; x<w; x++) ctx.lineWidth=1, ctx.strokeStyle="#474", ctx.beginPath(),
ctx.moveTo(.5+x,.5), ctx.lineTo(.5+x,h-.5), ctx.stroke(); // verts
for (let y=1; y<h; ++y) ctx.strokeStyle="#363" …Excerpt — the full answer is on the round page.
▶ R124 · Dijkstra's shortest path over weighted terrain Open round →
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Dijkstra's Algorithm Animation</title>
<style>
body {
background: black;
}
canvas{
image-rendering: pixelated;
}
</style>
</head>
<body>
<canvas id="grid" width="600px" height="600px"></canvas>
<script>
const grid = document.getElementById("grid");
// The canvas context with image smoothing disabled
const ctx = grid.getContext("2d", {willReadFrequently: true});
// Size of the canvas and each cell in pixels (must be square)
const cellSizePx = 10;
const widthCells = Math.round(grid.width / cellSizePx);
const heightCells = Math.round(grid.height / cellSizePx);
// The number of cells
const numCells = widthCells * heightCells;
let gridCosts = new …Excerpt — the full answer is on the round page.
▶ R125 · Voronoi diagram growing by multi-source flood fill Open round →
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Voronoi Animation</title>
<style>
body {
background: #2F3640; /* Dark background */
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
canvas {
border: 2px solid #fff; /* White border for the canvas */
}
</style>
</head>
<body>
<canvas id="voronoiCanvas"></canvas>
<script>
const canvas = document.getElementById('voronoiCanvas');
const ctx = canvas.getContext('2d');
let width = window.innerWidth;
let height = window.innerHeight;
canvas.width = width;
canvas.height = height;
class Seed {
cons …Excerpt — the full answer is on the round page.
▶ R126 · Bubble sort sweeping bars into orderDNF Open round →
▶ R127 · Quicksort partitioning around glowing pivotsDNF Open round →
▶ R128 · Merge sort weaving runs togetherDNF Open round →
▶ R129 · Heap sort sifting the maximum to the backDNF Open round →
▶ R130 · Radix sort ordering by one digit at a time Open round →
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Radix Sort Animation</title>
<style>
body {
margin: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f4f4f4;
}
canvas {
border: 2px solid #333;
background-color: white;
}
</style>
</head>
<body>
<canvas id="animationCanvas" width="600" height="400"></canvas>
<script>
const canvas = document.getElementById('animationCanvas');
const ctx = canvas.getContext('2d');
let bars = [];
let pass = 1;
let digitPlace = 0;
function randomInt(min, max) {
return Math.floor(Math.random() * (max - min + …Excerpt — the full answer is on the round page.
▶ R131 · Weekday riddle from two clues Open round →
Today is Tuesday. Given that the day after tomorrow is two days before Thursday, we can infer that we are currently in the middle of this sequence, making today exactly two days prior to 'the day after tomorrow'. Hence, it's Tuesday.
▶ R132 · Fermi estimate: a lifetime of drinking water Open round →
Assumptions: - An average adult consumes 2 liters of water daily. - A year has approximately 365 days. - Average lifespan of an adult is about 70 years. Calculation: Daily intake x Days in a Year x Lifespan = Total Liters 2 L/day * 365 days/year * 70 years = 51,100 Liters An average adult drinks approximately **51,000** liters of water in their lifetime.
▶ R133 · Three friends, three pets Open round →
Ana has the Parrot as she is allergic to fur; Ben owns the Dog since it can't fly, and Cleo must have a Cat due to being the oldest among them. This conclusion was drawn based on given hints that helped us rule out other possibilities for each person's pet ownership.
▶ R134 · Smallest number from three remainders Open round →
The smallest such number is $43$. We can find this through a systematic process of elimination using the Chinese Remainder Theorem: 1. It must be greater than $20$ since it leaves remainder $2$ when divided by $5$, which means it's at least $5 \times 4 + 2 = 22$. 2. It also must be less than or equal to $36$ as it should leave a remainder of $1$ when divided by $3$, and the largest multiple of $3$ in the range we're looking for is $3\times12=36$. 3. So, we've narrowed our search between $20 < N \leq 36$. The number must also have a remainder of $3$ when divided by $7$, so it can't be any multiple of $7$ in that range (like $28$ or $35$) as they leave remainders of $0$ and not $3$. That leaves us with the options: - $21, 24, 26, 30, 33$, which have remainders of $2, 1, 1, 0,$ and $5$ when divided by $7$ respectively. 4. Among these numbers, only one gives the required remainder o …
Excerpt — the full answer is on the round page.
▶ R135 · Conditional dice probability Open round →
The probability of this scenario occurring is 1/3, or 0.33 recurring. There are three possible cases: one die shows a 4 while the other has a value of either 5 or 6; both dice show a value of 4; and finally, again with one die showing a 4 but the other having a value of 3. This gives us two favorable outcomes out of six equally likely possibilities in total. Thus, the probability is 2/6, which reduces to 1/3.
▶ R136 · Double pendulum tracing a chaotic pathDNF Open round →
▶ R137 · Cloth mesh hanging and rippling in the wind Open round →
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Hanging Cloth Animation</title>
<style>
body {
margin: 0;
overflow: hidden;
display: flex;
justify-content: center;
align-items: center;
}
#canvas {
border: 1px solid black;
}
</style>
</head>
<body>
<canvas id="canvas" width="600" height="400"></canvas>
<script>
const canvas = document.getElementById("canvas");
const ctx = canvas.getContext("2d");
let points = [];
let windStrength = 0;
let windDir = -1; // -1 to right, +1 to left
let gravity = 0.05;
let damping = 0.98;
function createPoints() {
const width = canvas.width;
const height = canvas.height;
for (let i = 0; i < 20; i++) {
points[i] = [];
// Top row is …Excerpt — the full answer is on the round page.
▶ R138 · Two-source wave interference patternDNF Open round →
▶ R139 · Small n-body system orbiting a central starDNF Open round →
▶ R140 · Water sloshing in a tilting containerDNF Open round →
▶ R141 · Idiom-dense German into natural English Open round →
It was a shot in the dark, and now we're left high and dry, but giving up is not an option.
▶ R142 · Register shift: casual complaint into formal Open round →
Subject: Urgent Matter Regarding Faulty Blender Dear [Recipient], I am writing to bring to your attention a serious issue with the blender I recently purchased. Within just two days of receiving it, the appliance malfunctioned, emitting sparks. This is an unacceptable and potentially hazardous situation. I kindly request that you provide a prompt resolution by either refunding my purchase or arranging for an immediate replacement. I expect a response detailing the next steps to be taken. Thank you for your attention to this matter. Regards, [Your Name]
▶ R143 · Bureaucratic German into plain English Open round →
You must submit a completed application by the deadline to be eligible for this service; otherwise, your claim will be forfeited.
▶ R144 · English apology into idiomatic Sie-German Open round →
Wir haben hier gepatzt - da gibt es nichts schönzureden. Aber wir werden das wieder gutmachen, und Sie kommen dabei völlig ungeschoren davon.
▶ R145 · False-friend minefield German into English Open round →
We may have to postpone the current appointment; it's a sensitive issue, and I don't want to poison the well.
▶ R146 · Repair broken JSON (4 precise errors) Open round →
{
"name": "Alex Weber",
"age": 34,
"email": "alex@example.com",
"active": true,
"tags": ["admin", "beta"],
"signupYear": 2024,
"address": {
"street": "Hauptstr. 5",
"city": "Berlin",
"zip": "10115",
"country": "Germany"
}
}▶ R147 · CSV with embedded comma to JSON array Open round →
[
{
"id": 1,
"name": "Anna Berg",
"notes": "Prefers email, not phone",
"amount": 120.5
},
{
"id": 2,
"name": "Tom Klein",
"notes": "Standard customer",
"amount": 75
},
{
"id": 3,
"name": "Lena Fuchs",
"notes": "Called twice, resolved",
"amount": 200
},
{
"id": 4,
"name": "Max Otto",
"notes": "VIP customer",
"amount": 50
}
]▶ R148 · Table QA: sum, filter, max over order data Open round →
1. 245.86 2. [1001, 1003, 1006] 3. 268.50
▶ R149 · Extract meeting invite into a fixed JSON schema Open round →
{
"title": "Q3 Roadmap Kickoff",
"date": "2026-08-18",
"time": "10:30",
"location": "Conference Room B, Berlin office (3rd floor)",
"attendees": ["Sarah", "Tom", "Priya"]
}▶ R150 · Diff two near-identical config blocks Open round →
- timeout: A-30 -> B-45 - debug: A-false -> B-true - max_connections: A-100 -> B-150
▶ R151 · Binary search tree growing node by nodeDNF Open round →
▶ R152 · Hash table with visible collision chains Open round →
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Hash Table Animation</title>
<style>
body {
margin: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #222;
font-family: Arial, sans-serif;
color: #fff;
}
canvas { border: 3px solid #4CAF50; }
</style>
</head>
<body>
<canvas id="myCanvas"></canvas>
<script>
const canvas = document.getElementById('myCanvas');
const ctx = canvas.getContext('2d');
let width = window.innerWidth, height = window.innerHeight;
canvas.width = 800; // scale to fit a 16:9 aspect ratio with room for text at the bottom
canvas.height = (canvas.width * 9) / 16;
function drawSlot(x, y, fillLevel) { …Excerpt — the full answer is on the round page.
▶ R153 · Binary min-heap with bubble-up and sink-downDNF Open round →
▶ R154 · Ring buffer with producer and consumer at different ratesDNF Open round →
▶ R155 · Linked list with animated pointer relinkingDNF Open round →
▶ R156 · Invent 3 product names + taglines for a fictional object (no superlatives) Open round →
1. Bag Buddy — Keeps your snacks super fresh 2. Snack Saver — Stand-up storage for all! 3. Clamp Clip — Fold, seal, enjoy later!
▶ R157 · Rewrite the same product text for two different audiences, facts unchanged Open round →
(a) Teenagers: The AquaGlow bottle is the perfect hydration companion, holding an impressive 750 ml to keep your drinks icy cold for up to 12 hours straight! Crafted from safe BPA-free plastic with a convenient built-in straw, this dishwasher-safe bottle comes in 4 fresh colors. (b) Seniors: Stay refreshed and hydrated with the AquaGlow bottle—it holds a generous 750 ml of your favorite beverage and keeps it chilled for an incredible 12 hours! Made from durable BPA-free plastic with a handy built-in straw, this dishwasher-safe bottle is available in 4 elegant colors.
▶ R158 · 5 email subject lines under 50 chars, no clickbait, no ALL-CAPS Open round →
1. End of Season Sale: 20% off Winter Warmers 2. Your Opinion Matters: Mobile App Survey 3. Extended Returns Policy: Shop with Confidence! 4. November Offers: Stay Cozy, Save Money 5. Latest Store Updates: Free Returns & More
▶ R159 · Micro-story: exactly 50 words (±5) with 3 mandatory elements Open round →
She arrived at the station just as the train pulled away without her; its whistle echoed like a lighthouse beacon in the rain. The red umbrella she carried offered little protection from the downpour and the missed connection.
▶ R160 · Critique a generic slogan in 2 sentences + give 2 better alternatives Open round →
The slogan is too broad and could apply to any product, lacking specificity to the unique features of these solar-powered chargers. It fails to emphasize the innovative nature of the product or its benefit to outdoor enthusiasts. 1. "Powering Your Adventures: Solar-Charged and Ready" 2. "Hike, Camp, Charge: Off-Grid Phone Power"
▶ R161 · Selection sort vs shell sort racing side by side Open round →
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sorting Visualization</title>
<style>
canvas {
border: 2px solid black;
margin: 20px auto;
display: block;
}
</style>
</head>
<body>
<canvas id="visualization" width="800" height="400"></canvas>
<script>
const canvas = document.getElementById('visualization');
const ctx = canvas.getContext('2d');
let bars, selectionCounter=0, shellCounter=0;
function init() {
bars = Array.from({length: 30}, () => Math.random() * 150 + 15); // random heights
drawBars();
}
function drawBar(x, y, width, height) {
ctx.fillRect(x, canvas.height - height, width, height);
} …Excerpt — the full answer is on the round page.
▶ R162 · Breadth-first search flooding a random grid maze Open round →
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Breadth First Search</title>
<style>
body { margin: 0; }
canvas { display: block; background: #242134; border: 5px solid #FABA9D; border-radius: 6px; image-rendering: crisp-edges; }
</style>
</head>
<body>
<canvas></canvas>
<script>
// global variables
let maze = [];
const canvasEl = document.querySelector("canvas");
const ctx = canvasEl.getContext("2d");
// constant colors
const cBackground = "#242134";
const cWall = "#FABA9D";
const cGoal = "#A6C5EB";
const cStart = "#F78BAA";
const cVisited = ["#FFFAEF", "#FFF0DB", "#FFE0BD"];
// canvas size and grid layout
const cellSize = 24;
const padding = 3.5;
const width = (Math.floor(canvasEl.width …Excerpt — the full answer is on the round page.
▶ R163 · Prim's algorithm growing a minimum spanning treeDNF Open round →
▶ R164 · Boids flocking with separation, alignment, cohesion and a predatorDNF Open round →
▶ R165 · Recursive backtracker carving a maze, then solving itDNF Open round →
▶ R166 · Faithful 3-sentence summary of a chaotic meeting transcript Open round →
The team agrees to move weekly status updates to Monday mornings and adopts Priya's simplified ticket labeling system, with Priya updating the guide by Wednesday. Tom will send an updated calendar invite reflecting this change by Friday, and the plant budget discussion is deferred to the next meeting. These decisions streamline processes and improve communication within the team.
▶ R167 · One-sentence TL;DR under 25 words Open round →
The legacy /v1/reports API is shutting down by September 30, 2026; migrate to /v3/reports for better performance.
▶ R168 · Extract action items as a checklist Open round →
1. Chen -- fix the broken contact form -- by Monday 2. Maria -- chase the client for confirmation on new logo colors -- by today 3. Ben -- get updated privacy policy text to legal -- by next Wednesday
▶ R169 · Neutral summary of a biased product rant Open round →
The blender's base seal allows liquid to leak when filled past the halfway point, the speed dial has multiple settings with identical functions, and its motor overheats after 90 seconds of continuous use, rendering it ineffective for thicker liquids.
▶ R170 · Compress a how-to into exactly 5 numbered steps Open round →
1. Mix 100g wheat flour and 100g room temp water. 2. Stir into paste, loosely cover jar; leave for 24 hours. 3. Discard half, feed with 100g each flour/water; repeat daily x5 days. 4. Look for bubbles and pleasant tangy smell by day 7. 5. Bake when dough doubles in size within 4-6 hours post feeding.
▶ R171 · Fireworks bursting into fading sparks Open round →
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Fireworks Display</title>
<style>
body {
margin: 0;
background-color: #0d0d16;
}
canvas {
display: block;
}
</style>
</head>
<body>
<canvas id="fireworks"></canvas>
<script>
const canvas = document.getElementById('fireworks');
const ctx = canvas.getContext('2d');
let activeParticles = [];
class Particle {
constructor(x, y, radius, color) {
this.x = x;
this.y = y;
this.radius = radius;
this.color = color;
this.velocityX = Math.random() * 2 - 1;
this.velocityY = Math.random() + 0.5;
this.gravity = 0.25 + Math.random() * 0.3;
}
draw() { …Excerpt — the full answer is on the round page.
▶ R172 · Raindrops sliding down a window pane Open round →
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Rainy Window</title>
<style>
body {
margin: 0;
background: #02131d;
}
canvas {
display: block;
}
</style>
</head>
<body>
<canvas id="windowCanvas"></canvas>
<script>
const canvas = document.getElementById('windowCanvas');
const ctx = canvas.getContext('2d');
let dropletCount = 0;
let maxDroplets = 50; // maximum number of droplets on screen at once
let dropletRadius = 10; // initial radius for new droplets
let minSpeed = 1;
let maxSpeed = 3;
const acceleration = 0.2;
const growthRate = 0.1;
const mergeRadius = 5;
class Droplet {
constructor(x, y) { …Excerpt — the full answer is on the round page.
▶ R173 · Metaball lava lamp with heating and cooling blobs Open round →
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Metaball Lava Lamp</title>
<style>
body {
margin: 0;
background: #111;
overflow: hidden;
}
canvas {
display: block;
}
</style>
</head>
<body>
<canvas id="lavaLamp"></canvas>
<script>
const canvas = document.getElementById('lavaLamp');
const ctx = canvas.getContext('2d');
class Blob {
constructor(x, y) {
this.pos = [x, y];
this.vel = [0, 0];
this.radius = Math.random() * 3 + 1;
this.temp = Math.random() * 40 + 20; // Initial temperature
}
update(dt) {
this.pos[0] += this.vel[0] * dt;
this.pos[1] += this.vel[1] * dt;
if (this.pos[1] < this.radius …Excerpt — the full answer is on the round page.
▶ R174 · Recursive fractal tree growing branch by branchDNF Open round →
▶ R175 · Noise flowfield painting additive particle trails Open round →
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Perlin Noise Flowfield</title>
<style>
body {
margin: 0;
background: #000;
overflow: hidden;
}
canvas {
display: block;
}
</style>
</head>
<body>
<canvas id="flowfield"></canvas>
<script>
const canvas = document.getElementById('flowfield');
const ctx = canvas.getContext('2d');
const width = canvas.width = window.innerWidth;
const height = canvas.height = window.innerHeight;
let particles = [];
let particleCount = 300;
let fieldSize = 16;
let hueOffset = Math.random() * 100;
let fadeFactor = 0.98;
let resetTimer = 0;
const resetDuration = 2500; …Excerpt — the full answer is on the round page.
▶ R176 · Fix exactly the errors, change nothing else Open round →
On Monday morning, the small archive opened its new reading room to local students. The room has six desks, two lamps, and a shelf for returned notebooks. Before the first group arrived, Mara checked the sign-in sheet and placed pencils beside each chair. She noticed that one window was stuck, but the hallway was quiet, and the heater worked well. At nine o'clock, twelve students entered the archive, greeted the staff, and began comparing old town maps. Their teacher asked them to write short notes about every map they handled. One student found a drawing of the river bridge, and another matched it to a photograph from 1912. By noon, the class had labeled the boxes, cleaned the tables, and thanked Mara for her help. The visit ended on time, and the archive stayed open for regular visitors after lunch.
▶ R177 · Make the numbers consistent Open round →
Workshop attendance report: The registration desk recorded 18 participants: 7 from North Hall, 6 from East Studio, and 5 from River Annex. The header now accurately reflects this count as 18 participants attended. The event took place on Wednesday, March 4, 2026. All references to Tuesday have been corrected in the report. Regarding the feedback survey, an impressive 15 out of the 18 attendees submitted forms. The draft summary has been updated to accurately reflect this as a participation rate of 83%.
▶ R178 · Remove redundancy without losing facts Open round →
The mobile clinic opens on April 8 at the Maple Community Center, offering free blood pressure checks, vaccinations, and medical consultations every Wednesday from 10 a.m. to 4 p.m. Appointments are available by phone or in person, with Spanish and Vietnamese interpretation services provided during clinic hours. The center is located on Maple Street, and residents should note that this date marks the launch of services rather than a planning meeting.
▶ R179 · Unify tense and perspective Open round →
At dawn, I stepped onto the station platform and checked the timetable. I noticed the last train number blinking on the board before the screen went dark. I waited beside the vending machine, but my eyes kept wandering toward the empty tracks. The loudspeaker crackled, and I heard a short apology for the delay. Then I walked to the ticket office, where the clerk handed me a paper voucher. I folded the voucher into my notebook and thought about the missed connection. I finally boarded the replacement bus and sat near the back window. As the bus left town, I watched the station lights disappear behind the rain.
▶ R180 · Fix the broken references Open round →
Maintenance note for the demo room: The tablet is stored in the blue cabinet, and it must be charged before each session. The projector was tested after lunch; the former should remain unplugged overnight. See below for the cleaning checklist. Setup steps: 1. Unlock the cabinet. 2. Place the tablet on the stand. 3. Start the room timer.