R
R
russeljo2021-12-12 19:40:54
PHP
russeljo, 2021-12-12 19:40:54

How to iterate over all values ​​of a string of a certain length consisting of numbers and letters?

Given: a string of a certain length, e.g. '03jd34' - can only consist of numbers 0..9 and Latin a..z
How to enumerate all possible values?
If there were only numbers, then the task is primitive, know yourself to increment from 0..999999, and add zeros for 0..99999 - i.e. here the alphabet is the numbers 0..9.
And when letters are added, the alphabet increases by a multiple of 0..9a..z and I don’t know how to do such an increment using the PL. And I want it that way, because there will be a sequential search from 0 to zzzzzz. Type to create some kind of data type numstring))

I wonder if it is possible, and how? Or, if not, what are the ways?

Nested loops and recursions come to mind.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
R
Rsa97, 2021-12-12
@Rsa97

Just convert numbers from 0 to 36 6 to base 36.
0 10 = 0 36
...
9 10 = 9 36
10 10 = a 36
...
35 10 = z 36
36 10 = 10 36
...
2176782335 10 = zzzzzz 36

R
russeljo, 2021-12-12
@russeljo

Like something found https://stackoverflow.com/questions/12504042/what-...

W
Wataru, 2021-12-12
@wataru

Well this is how you add 1 to a number from 0..9 add 1 to a number where the digits could be 0..9 and a..z. Replace all z at the end with 0, increase the next character by 1 (if it became '9'+1, then Replace with 'a').

R
Rostik Kalchenko, 2021-12-12
@noder_ss

Element.includes('text')
Check with if(your variable.includes('characters, in the presence of which the following will be executed'){command if if will be executed}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question