"I just implemented Conway's Game of Life in two lines of code. #fml"
pad = x flip[stitch] 0, stitch 0, flip[cat] 0, cat 0
life = pad, neighborhoods[3 3], [ravel, [sum in?: [x @ 4, + 3; 3]]]/2
/* | |
* To try it: | |
* c = $c.sRGB8(23,58,32); | |
* c.Lab(); | |
* c.Lab().sRGB8(); | |
*/ | |
var $c = {}; | |
( | |
function () { |
It's time to drag the Island of Knights and Knaves kicking and screaming into the 19th century! We're going to run a train. For these puzzles, you'll have a set of stations with possible connections, and you need to find a route that starts at one station, goes through every other station exactly once, and ends in a station. IE if our map was
A -- B -- C
| | |
D -- E -- F
Valid routes might be A B C F E D
, or A D E B C F
, but A B E D C F
is invalid. The ordering matters: A B C
is a different route from C B A
.
import os | |
import sys | |
""" | |
This (pure!) python script streams a gzip-compressed YUV4MPEG video to stdout. | |
It easily runs at 1080p60fps on my machine. | |
Pipe it into a media player like this: | |
python3 gzip_swar_life.py | mbuffer | gunzip - | mpv - |
Here we see the same UUIDv4 generation function written in three different APL(-like) languages: APL, J, and K.
The algorithm is very simple, but one that lends itself well to implementation in an array language:
from typing import TypeVar, Union | |
T = TypeVar("T") | |
Thing = Union[str, int] | |
MaybeTuple = Union[T, tuple[T]] | |
def untuple(item: MaybeTuple[T]) -> T: | |
if isinstance(item, tuple): |