Skip to content

Instantly share code, notes, and snippets.

@eamonnbell
Last active January 22, 2017 23:26
Show Gist options
  • Select an option

  • Save eamonnbell/de5f3db753fcec958345da2b9ad3d612 to your computer and use it in GitHub Desktop.

Select an option

Save eamonnbell/de5f3db753fcec958345da2b9ad3d612 to your computer and use it in GitHub Desktop.
Serial matrix in J
mod12 =: 12 & |
matrix =. monad : 0
m =. mod12 y -/ (y - (0 { y))
)
pcs =: i. 12
shuf =: {~ ?~@#
newrow =: shuf pcs
matrix newrow
5 8 7 3 2 11 1 6 9 4 10 0
2 5 4 0 11 8 10 3 6 1 7 9
3 6 5 1 0 9 11 4 7 2 8 10
7 10 9 5 4 1 3 8 11 6 0 2
8 11 10 6 5 2 4 9 0 7 1 3
11 2 1 9 8 5 7 0 3 10 4 6
9 0 11 7 6 3 5 10 1 8 2 4
4 7 6 2 1 10 0 5 8 3 9 11
1 4 3 11 10 7 9 2 5 0 6 8
6 9 8 4 3 0 2 7 10 5 11 1
0 3 2 10 9 6 8 1 4 11 5 7
10 1 0 8 7 4 6 11 2 9 3 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment