push_swap

The numbers are sorted by the program from the repository, compiled to WebAssembly. What it prints is a list of operations, replayed below on the two stacks. The verdict comes from the checker, the project’s second program, fed that same list.

Compiled from github.com/abrisse16/42-push_swap

Both stacks at every operation of a hundred-number sort: stack A on top empties then refills into a gradient, stack B below does the reverse

The demo needs JavaScript. Here is what it shows.

One sort of a hundred numbers, operation by operation. Stack A on top, stack B below, colour gives the value.

How many numbers

Up to 500, separated by spaces or commas.

Operations
—
Bar
—
Checker
—
0 / 0

How it works

What runs here

The push_swap program written in C, compiled to WebAssembly with Emscripten, and its checker, compiled separately. The numbers are passed as arguments, and it runs the same sort in the browser as in a terminal.

What had to be adapted

Nothing in the algorithm. The program draws nothing, it prints a list of operations on its standard output: the page captures it, replays it on the two stacks, then hands it to the checker, which gives the verdict.

What differs from the original

The page stops at 500 numbers: beyond that, sorting takes more than a second and the tab would freeze during the computation.