Skip to content

Instantly share code, notes, and snippets.

@goofballLogic
Created December 15, 2025 13:33
Show Gist options
  • Select an option

  • Save goofballLogic/a0a05c56e417e75af0d341c6341fc9cc to your computer and use it in GitHub Desktop.

Select an option

Save goofballLogic/a0a05c56e417e75af0d341c6341fc9cc to your computer and use it in GitHub Desktop.
const rotate = ([ head, ...tail]) => [...tail, head];
const explode = (num, acc = []) =>
num === 0 ? acc
: explode(num - 1, [num, ...acc])
;
const build = (num, input, lines = []) =>
num === 0 ? lines
: build(num - 1, rotate(input), [...lines, input])
;
const latinSquare = n => build(n, explode(n));
latinSquare(1);
latinSquare(2);
latinSquare(4);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment