@Bubbler That's nice, though I have 1 additional requirement I didn't specify clearly enough. I need to be able to "tick up". That is, I either need to be able to give a number and get the odometer equivalent of that number, or else be able to continuously increment the odometer to its next highest value, as with my original example.
@Adám I've edited it in! I should probably rearrange the post so that the Extended solution is the more prominent one but I don't get why =≢⍵ is equal to 0=≢⍵ here
@Sherlock9 Because in Extended, all monadic scalar comparisons imply the prototypical element as left argument, so numbers are compared to 0 and characters to space.
@dzaima {⍺⍺ ⍵} is ignore-left-and apply-monadically? I've thought about that. Yes, I agree that a single-char {⍺⍵} would be very valuable. ⍮ seems like a nice symbol…
I'm a little distressed as a) I should have seen this earlier, and b) while I have written a correct answer in Ruby before, I'm not sure how to translate it into APL
The idea is that I can't just chop off everything before the point of mismatch. It's not efficient enough. I need to find a way to keep the two paths and the common ancestor and also search the first path and the common ancestor for the shortest backtracking step
And it's all so jargon-y in my head, I'm not sure where to start
I have an idea for a fix but I'm not sure how to implement it. In a case like 66 to 1, where the paths are P←1 3 3 3 and Q←1, the point of mismatch is index 2. ⍸P∘=¨∪P gets us (1)(2 3 4) and then ⊃⌽⍸P∘=¨∪P gets us 1 4. Now I need to get, not the minimum, but whichever index in that last list is closest to the point of mismatch, 2. Now how do I do that?
Okay I'm not sure how this solves my problem of needing to find from a list of ancestors, the one closest to the point of mismatch. So of ancestors 3 7 14 and point of mismatch 9, the answer should be 7
Basically once I've found the indices of the ancestors, say, indices 3 7 14. I need to find the index that's closest or equal to that point of mismatch
@Sherlock9 ok, let me try to re-state it in my own words: so you've got a list of numbers a and a number b and you want to find the element of a that is closest to b?
for my bounty, @H.PWiz gets 350 rep for his 28-byte answer and @dzaima gets an honourable mention for (probably) having come up with a shorter answer but never publishing it.