« first day (738 days earlier)      last day (1923 days later) » 

1:27 AM
⎕← {n←1↑⍴⍵ ⋄ (∊⍵)[+\∊{i x←⍵ ⋄ x/(1 n ¯1(-n))[1+4|i-1]}¨↓⍉↑(⊂⍳⍴a),⊂a←1↓⌽2/⍳n]}4 4⍴'abcd'
⎕← {n←1↑⍴⍵ ⋄ (∊⍵)[+\∊{i x←⍵ ⋄ x/(1 n ¯1(-n))[1+4|i-1]}¨↓⍉↑(⊂⍳⍴a),⊂a←1↓⌽2/⍳n]}4 4⍴'abcd'
 
@nathanrogers
abcddddcbaaabccb
 
⎕← {n←1↑⍴⍵ ⋄ (∊⍵)[+\∊{i x←⍵ ⋄ x/(1 n ¯1(-n))[1+4|i-1]}¨↓⍉↑(⊂⍳⍴a),⊂a←1↓⌽2/⍳n]}5 5⍴⍳25
 
@nathanrogers
1 2 3 4 5 10 15 20 25 24 23 22 21 16 11 6 7 8 9 14 19 18 17 12 13
 
This was a pretty neat exercise
create a list of indices, and a list of n, where n is the root of a square matrix. next, generate a list of appropriate maneuvers, in the case of 4: 4 3 3 2 2 1 1, because you take the first row, then the back column, then the bottom row, then the first column. The first row missing means all columns are now n-1, and after the bottom, n-2, thus, 4, 3, 3, 2, 2... Pair each number generated with an index, to expand each manuever based on the index of the number to take from a given row.

4/1
3/4
3/¯1
and the plus expand... I'm really proud of that one :P
 
 
7 hours later…
9:04 AM
⎕←{n←1↑⍴⍵ ⋄ (∊⍵)[+\∊a/(⍴a←1↓⌽2/⍳n)⍴1 n ¯1(-n)]}3 3⍴'abc'
 
@nathanrogers
abcccbaab
 
same solution no "each" or dfn
 
 
3 hours later…
12:21 PM
@nathanrogers looks like you've made it unnecessarily complicated, there's a much simpler way if you use recursion
 
1:17 PM
Does anybody have unit tests based on the FinnAPL idiom list?
 
 
2 hours later…
3:43 PM
@H.PWiz thank you... Possible one equivalent definition of Rocco number is n is a Rocco number <=> exist r max prime divisor of n such that 14=|r-n div r| where |x| is abs(x)...
This is the link where they speak of Rocco numbers: codegolf.stackexchange.com/questions/179239/find-a-rocco-number
 
4:04 PM
Right, I wonder if this method will shorten any other answers. One thing I failed to mention earlier is that this also relies on the fact that, p is small either p+14 is prime, or it happens to not have a prime factor bigger than p. For large p this will always hold, for small p, we get lucky
 
 
2 hours later…
5:59 PM
@EriktheOutgolfer yes I know that
@EriktheOutgolfer That was my first soltion, but I was challenged to solve it without recursion or looping
⎕←{0<+/⍴⍵:⍵[1;],∇⊖⍉⍵[1↓⍳1↑⍴⍵;]⋄⍬} 4 4⍴⍳16
 
@nathanrogers
1 2 3 4 8 12 16 15 14 13 9 5 6 7 11 10
 
@EriktheOutgolfer in a sense the recursive solution is more complicated, but the solution I posted above is more idiomatic and could be argued to be simpler than the recursive solution
 
@nathanrogers shortened to {0<+/⍴⍵:(1⌷⍵),∇⊖⍉1↓⍵ ⋄ ⍬} - no need to use brackets there
(the 1⌷⍵ is just my preference though)
 
@EriktheOutgolfer One solution is algorithmic and uses recursion, one creates an index map. Either way it was a cool problem :) And I learned a bunch
@dzaima and yours reads better than mine too. 1 take with recurse on 1 drop
that's a nice expression
which makes clear that is all I'm doing in the above... still trying to think in the context of other languages
⎕←{n←1↑ ⍴⍵ ⋄ a←1↓ ⌽ 2/ ⍳n ⋄ (∊⍵)[ +\∊ a/ (⍴a) ⍴ 1 n ¯1 (-n) ]} 4 4⍴'abcd'
 
@nathanrogers
abcddddcbaaabccb
 
6:10 PM
in this one I thought the a expression was an interesting discovery
it gives you the list of how many to take after each pivot. For 4 4⍴⍳16→1 2 3 4, 8 12 16, 15 14 13, 9 5, 6 7, 11, 10. because a← 4 3 3 2 2 1 1. And it works for all sizes. Then the +\... If I were to go back through my repl there were a few random insights I had by just having the ability to tinker with the numbers with all the APL operations. It's a simple problem, but this I think has done more to help me see idiomatic APL than any other problem
Map a to CardinalDirections←1 n, -1 n and you have the series of movements, like a cellular automaton, then simply +\ to get the indices :D
 
this from what i understand is about the same algorithm
 
6:30 PM
⎕←3 3⍴{ a←1↓⌽2/⍳n ←1↑⍴⍵ ⋄ (∊⍵)[+\∊ a/ (⍴a) ⍴1 n,- 1 n]}⊖⌽3 3⍴⍳9
 
@nathanrogers
9 8 7
4 1 2
3 6 5
 
that doesn't seem to work :/
 
4 4⍴⍋{a←1↓⌽2/⍳n←≢⍵ ⋄ (∊⍵)[+\ a/ (⍴a)⍴ 1 n,-1 n]}4 4⍴⍳16 you wanted this?
1 n,-1 n(⊢,-)1 n with trains because why not
 
that works for involute, I don't understand the use of ⍋ here, also it doesn't seem to work for exvolutes? though it seems it should
 
6:52 PM
@nathanrogers I don't understand its use there either, i just remember the article spamming it here and there :p
it you want evolute, just prepend 17- :p
 
7:19 PM
17- ?
oh
hrm
lol
As to Eugene's question of how do you come up with it, it's just a matter of asking yourself what are the relationships between the things. At first I was trying to calculate the values themselves, I tried all manner of rotations, I also tried to see if there was some formula based on n that would make things work
⎕←4 4⍴⌽((2↓¯1↓,1↑1↓c),(2↓¯1↓,1↑1↓b),(⌽1↓¯1↓,1↑1↓a),(⌽¯1↓1↓,1↑⌽⍉a),(⌽1↓,1↑c←⊖⍉b),(⌽1↓‌​,1↑b←⊖⍉a),(⌽,1↑a←4 4⍴⍳16))
 
@nathanrogers
 1  2  3  4
 8 12 16 15
14 13  9  5
 6  7 11 10
 
Tried to see if there was some pattern of things that would lead to the right answer directly
0 0 0 0 3 6 9 7 5 3 ¯2 ¯7 ¯7 ¯7 ¯4 ¯6+⍳16
⎕←0 0 0 0 3 6 9 7 5 3 ¯2 ¯7 ¯7 ¯7 ¯4 ¯6+⍳16
 
@nathanrogers
1 2 3 4 8 12 16 15 14 13 9 5 6 7 11 10
 
what were the relationships between the values, and maybe I could derive them by some kind of formula
result←∪/ <??> 1 2 1 2 1 2 1{⍵⌷[⍺] 4 4⍴⍳16}¨1 4 4 1 2 3 3
then I wound up at this sort of a solution, thinking well I take row 1, column 4, row 1, column 4 row 2 column 3, etc, and then I just need to reverse every other pair and take the unique and voila
but then I recognized that since 4 4⍴⍳16, if I sort correctly the values correspond to the indices and not the values necessarily... well I was stuck
but by looking at the above version, I recognized that I take 4 from the first row, then 3 from the back column, then 3 from the bottom row, then 2... so that lead me to the 4 3 3 2 2 1 1 pattern
recognizing this it was just a matter of asking "how does this pattern relate to the matrix itself". There is a relationship, but how do I map it to the values that I want?
Counting up one or back one in rows, and up n and down n just took a bit of floundering and playing with random things in the repl
Like all good ideas, it came to me on the john. :P
 
7:45 PM
⎕←0{a←1↓⌽2/⍳n←1↑⍴⍵ ⋄ (⍴⍵)⍴(∊⍵)[⎕←|((1+n*2)×⍺)-⍋+\∊a/(⍴a)⍴1 n,-1 n]}5 5⍴⍳25
 
@nathanrogers
1 2 3 4 5 16 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9
 1  2  3  4 5
16 17 18 19 6
15 24 25 20 7
14 23 22 21 8
13 12 11 10 9
 
⎕←1{a←1↓⌽2/⍳n←1↑⍴⍵ ⋄ (⍴⍵)⍴(∊⍵)[⎕←|((1+n*2)×⍺)-⍋+\∊a/(⍴a)⍴1 n,-1 n]}5 5⍴⎕A
 
@nathanrogers
25 24 23 22 21 10 9 8 7 20 11 2 1 6 19 12 3 4 5 18 13 14 15 16 17
YXWVU
JIHGT
KBAFS
LCDER
MNOPQ
 
Thanks @dzaima for that article
 
8:17 PM
From what I can undersand the ⍋ maps the location indices to the value indices. Since we have the index map, grade up says let's get the index of the value that belongs in that new index. Since, at index 5 of an alphabet involute, ABCDE, we have E, F, needs to go below it. We already know that in an index map, the value below index 5 is index 10. Indexes sorted go 1 2 3 4 5 10 15 20 25 24...
But what comes after E in the list pre reshape? i.e. index 6. Index 6 is 16th in the index map, so by grade up, we get the 16th value which is P. Which means that since index 10 is the 6th value, by grade up, F will be mapped to the 10th value in the new list.
so from ⎕A, using 1 2 3 4 5 10...24 maps to 1 2 3 4 5 16...6, we get ABCDEP...F. I can follow it, but I'd have never found that on my own
 
@ktye Not that I know of. Be aware that that won't test any nested array stuff.
 
@Adám That's ok for me, as iv does not do nested arrays anyway. I added github.com/ktye/iv/blob/master/cmd/apl/testdata/finn.apl that has the idioms as dfns. I can at least parse most of them!
 
8:38 PM
@nathanrogers I was referring to something similar to dzaima's version (but a bit simpler): {⍵≢0 0⍴⍬:⍵[1;],∇⍉⌽1↓⍵ ⋄ ⍬}
 
8:48 PM
@EriktheOutgolfer ⍵≢0 0⍴⍬ makes it not work for character matrices though
 
I think it's only integers in there...
otherwise, 0 0≢⍴⍵ works
 
@ktye Why doens't the meaning of life work? Edit: Oh, because nested arrays.
But if you remove ⊃⊂ it should work.
 
But this works at least: A←5 5⍴(23⍴2)⊤1215488⋄l←{3=S-⍵∧4=S←({+/,⍵}⌺3 3)⍵}⋄(l⍣8)A
Although I had to insert braces.
 
@ktye Which braces are you talking about?
 
S←({+/,⍵}⌺3 3)
Dyalog works without
 
9:03 PM
@ktye No, you have to separate 3 3 from with something. Either parens, or .
 
Yes, that's true, the one with ⊢ didn't work for me
 
@ktye Do you have tacit?
 
I hope that's compatible. Except for / \ etc.. which is treated as an operator in iv.
 
@ktye Ah nice. Then you can write GoL tacitly instead.
 
@Adám which one?
 
9:10 PM
@ktye Yeah, those a problematic. In original APL, it didn't make a difference what exactly they were, but when operators were generalised, it became an issue. Some dialects went for all-operator, but that has downsides, e.g. they can't be operands of operators. Others went with a hybrid approach, which is harder to get right and makes it awkward to use them in trains.
 
@Adám does not work :( I have to figure out why
 
@Adám out-of-context quote of the day...
 
I personally think less is more:
⍞←⍎⌽⍕⌈*○≡⍬
 
@Adám 42
 
9:26 PM
@Adám ⍎⌽⍕? :P
 
@EriktheOutgolfer Reverse order of digits.
 
@Adám more like cheating when it comes to "less is more", but... anyway ;P
 
@EriktheOutgolfer What? Why? It is in the original.
 
@Adám I just commented on why that doesn't prove the meaning of life so much ;)
 
@EriktheOutgolfer I knew that, but still one is more idiomatic, if not golfed
 
9:32 PM
@EriktheOutgolfer I like it better than
⍞←≢⍕!⍋⎕D
 
@Adám 42
 
Even though it is a bit longer.
 
@nathanrogers generally, I don't think with idioms, just the basics
@Adám huh that second version doesn't even contain the... inverses that often come with life
 
I solved it initially in JavaScript with recursion. So that was obvious, but from what I understand of APL, iteration is slower and less desirable than array operations, so when I was told a non iterative approach was possible, I gave it a whack
And found it to be much more elegant
 
iteration is slower indeed...
ah, the many times we've tried to eliminate darned ¨s here... :P
 

« first day (738 days earlier)      last day (1923 days later) »