Hi Duc Haba,
I think what you are describing is a time series. There is a whole topic, with many participants, devoted to classifying and predicting time series:
You will find many tested, refined techniques and ideas there – RNNs, Transformers, auto-regressive, Rocket, etc.
But if you are thinking of these sequences not as time series, but rather as the kind of problem found on an aptitude test for humans… that’s a very interesting question! As Conwyn points out, there is a grammar to these types of sequences. Something like a language model might discover and extend the patterns. I also have some ideas in this direction. So would you please clarify what kind of problem you are trying to solve?
HTH,
Malcolm