Last active
August 13, 2025 08:52
-
-
Save emirikol/ab4230d0c0f2b119f62135093ea2b52d to your computer and use it in GitHub Desktop.
J palindromes
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
range =: 100 }. i. 1000 | |
uniq_prods =: ~. @: , @: (*/~) | |
palindrome =: (-: |."1) @ (":"0) | |
>./ (#~ palindrome) uniq_prods range | |
>./ ( palindrome # ] ) ~. , */~ range | |
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
t =: ... | |
table =: 20 20 $ t | |
transposed =: > table ; (|: table) ; ([ /. table) ; ([ /. |. table) | |
cycles =: 0 ,"1 (0 ,"0 i. 20) | |
foursomes =: 4 {."1 cycles |. transposed | |
>./ , */"1 foursomes | |
Or better | |
table =: 20 20 $ ... | |
transposed =: (] ` |: ` ([ /.) ` ([ /.@|.)) `:0 table | |
>./ , 4 */\"1 transposed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment