Create a list of snaking numbers under 50,000
K (ngn/k), 60 57 bytes

(x;#x:{*/1=3!5&amp;+/x*x:+1_-':(+0 1,'2*!3 3)@10\x}#1+!50000)


Try it online!

!50000 list of 0 .. 49999

1+ add 1 to all

{ }# filter with the function in { }

10\x decimal digits of the argument

( )@ use as indices in ...


!3 3 a pair of lists: (0 0 0 1 1 1 2 2 2;0 1 2 0 1 2 0 1 2)
2* multiply all by 2
0 1,' prepend 0 to the first list and 1 to the second
+ transpose (pair of lists -> list of pairs). this gives us the approx button coords.


-': subtract from each pair the previous pair. use 0 0 as an imaginary element before the first.

1_ drop the first

+ transpose

x*x: square (assign to x and multiply by x). here x is a pair of lists - ∆x-s and ∆y-s

+/ sum the two lists (element by element)

5&amp; min with 5

3! mod 3

1= boolean list of where it's equal to 1

*/ product (boolean "and")

(x;#x: ) make a pair of the result and the length (#) of the result