Created
December 15, 2025 13:33
-
-
Save goofballLogic/a0a05c56e417e75af0d341c6341fc9cc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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