Maybe the internal broadcasting mecanism in numpy don't allow this nativelly ?
Example 1: Find the missing number
xor =: (16 + 2b0110) b.
iota1000 =: (i. 1000)
missingNumber =: (xor/ iota1000) xor (xor/ iota1000 -. 129)
echo 'The missing number is ' , ": missingNumber
This print 'The missing number is 129'Example 2: Using a random permutation, find the missing number.
permuted =: (1000 ? 1000)
missingNumber = (xor/ permuted) xor (xor/ permuted -. ? 1000)
Example 3: find the missing number in this matrix. _ (< 2 2) } 5 5 $ (25 ? 25)
12 9 1 20 19
6 18 3 4 8
24 7 _ 15 23
11 21 10 2 5
0 16 17 22 14
Final test: repeat 10 times the example 3 (random matrices) and collect the time it takes you to solve it in a list of times, then compute the linear regression best fit by times %. (1 ,. i. 10)
Did you get better at solving it by playing more times?I am not affiliated with J, but in case you want to try some J code there is a playground: https://jsoftware.github.io/j-playground/bin/html2/
Edited: It seems I am procrastinating a lot about something I have to do but don't want to.
f =: ]`1:`>:`0:@.(4&|)"0
Then: (,. ; #: ; [: #: f) i.16
0 0 0 0 0 0 0 0 0
1 0 0 0 1 0 0 0 1
2 0 0 1 0 0 0 1 1
3 0 0 1 1 0 0 0 0
4 0 1 0 0 0 1 0 0
5 0 1 0 1 0 0 0 1
6 0 1 1 0 0 1 1 1
7 0 1 1 1 0 0 0 0
8 1 0 0 0 1 0 0 0
9 1 0 0 1 0 0 0 1
....b. Why J, as opposed to another APL implementation? In particular, the different syntax, I suppose I mean.
Thanks!
r/apljk on reddit is also active.