Number sequence puzzle

Thought of this puzzle the other day, though I’m probably not the first.

To save you all some trouble. The solution is algorithmic, not algebraic.

What’s the next number in the sequence? Post just your answer and other’s can keep trying even after I confirm or reject a solution.

2211
335
223
47
22223
77
255
51

Dang it! I just noticed the 51 should actually be 317 … How’s that for a hint?
And following that is
2213

I’m not really sure what that is supposed to mean. These seem like different categories of thing, not mutually exclusive alternatives. Many algorithms would be expressed algebraically.

The algorithm involves an operation that I’m relatively certain falls outside most people’s definition of algebra.

317
2213
53
2333
511
2227