Yes, at least that. Let's say we only use 10 APL functions and operators, plus the ten digits. That's 20 possibilities for each character. Total number of programs is 20⁷=1280000000
I'm afraid evaluating 1 billion programs might take a while.
How about this: ⋄ {2::'n/a'⋄4::'n/a'⋄11::'n/a'⋄⍎⎕←⍵[5?≢⍵]}'⍳⌽≡~⌿0123456789' I am sure @Adám can make it prettier. I have no time now, but you can iterate it till it provides N good answers.
@Adám Yes, much more can be done (with time), but it's tough to work around the problem that there are useless functions here and there. Often a sequence of 6 can be done with 3 by just dropping some of the functions.
@AlexB Ooh, I just got an idea. One could attach an operator to each function, checking it that function has an effect: {⍺←⊢ ⋄ r←⍺ ⍺⍺ ⍵ ⋄ ⍺ ⍵∊⍨⊂r:$ ⋄ r}
To do something better, we should make it much more "clever", i.e. comprising at least some heuristics of what makes sense and what doesn't. At some point I added the ∪ function and I got a lot of ∪⍳ sequences, where the ∪ did nothing.
challenge←{
0::∇⍵
d←' ',⎕D
k←d,4/'+-×⍳=¯≠'
r←⍎e←k[⍵?≢k]
(1≥≢∪r)∨(r≡⍳⊃⌽r)∨(r≡⌽⍳⊃r)∨(20<×/⍴r)∨(1∊2=/e)∨(⍵=+/e∊d)∨((5>≢r)∧(1≥⍴⍴r)):∇⍵
r
⎕←⎕UCS e ⍝ remove "e" to hide the solution!
}
@Fmbalbuena What? the challenge? As @Adám and I already said, it's really tough to generate clever challenges. That's why @Adám is a real person and not a bot... (ha ha)
So, the last thing we touched upon was the slash. We used +/ for summation and ×/ to find the product.
I didn't explain the actual concept behind this.
So we have APL functions that take one or two arguments, like - etc.
We also have an entirely different class of built-ins, that we call "operators", and / is an example of that.
You can think of an operator as a tiny factory that produces functions on demand.
You feed the operator one or two parameters (we call those operands) and it goes and creates a new function based on your parameters, and according to a specific recipe, unique to that operator.
So the recipe of / is that it takes a 2-argument function, and creates a 1-argument function which conceptually inserts the 2-argument function between elements.
Lots of words. Let's take an easy-to-understand example.
+ takes two arguments and adds them.
⍨ is an operator just like /. It takes a function, e.g. + on its left and creates a function that takes a single argument, but conceptually uses that single argument on both sides of +.
@Elise I'd like you to find a neat way using ⍨ to square a number, but if the above was too confusing, do let me know, and I'll try to explain it in a different way.
@FawnLocke Have a look at ⎕DT'J' with an appropriate high-res tick.
And again, you're using ⍨ to flip the arguments of < (which is a functionality I've not even told you about! How are you learning so quick?). I'm looking for things like <⍨ 3 1 4 1 5 which uses only one argument.
Is there a reason why it isn't possible to execute some System commands on TryAPL? If so, and if it's so expensive to load by default some functions, isn't it a good idea to put a link to a prebuilt TryAPL, with functions like cmpx (this is what I'm wishing to have in this moment, but there can be some other useful functions to have)
]runtime -c "(×⍨⍣¯1)⍳1e6" "(*∘0.5)⍳1e6"
(×⍨⍣¯1)⍳1e6 → 3.2E¯3 | 0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
(*∘0.5)⍳1e6 → 3.7E¯3 | +17% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
Although it seems to be slower if that's a concern