Expected amount of increments of a base-4 number until it has 5 digits, when each digit has a 1/6 chance of being reset to 0 Let's say I have a base-4 number $N$, with the initial value of $N = 00000$. The following function is applied to $N$ iteratively:

*

*$N$ is incremented by 1 (i.e. if $N = 02033$, on the next iteration it will be $02100$)

*Then, each digit has a 1/6 chance of being reset back to 0 ($03210$ might become $00210$, $03010$, $03000$, etc.)

*Repeat.

On average, how many iterations will it take until $N$ becomes $10000$ (1024) after the first step of the function?
In case it helps at all with clarity, here is a JavaScript equivalent to this scenario:
const array = [0, 0, 0, 0];
function findRight(arr) {
    let index = -1;
    for (let i = 0; i < arr.length; i++) {
    if (arr[i] !== 3) {
        index = i;
        break;
    }
    }
    return index;
}
function next() {
    const val = findRight(array);
    if (val !== -1) {
        array[val] += 1;
        if (val !== 0) array[val - 1] = 0;
    } else {
        return true; // all digits are 3; N = 1024
    }
    array.forEach((val, index) => {
        if (Math.floor(Math.random() * 6) == 5) {
            array[index] = 0;
        }
    })
}

(Apologies if the formatting/writing of this question is strange; I just have no idea how to explain this in proper math format, so a bit of code-like syntax is mixed in. Any edits to make this question more clear or more "mathy" would be greatly appreciated!)

Calculate the expected number of moves for the lowest digit, starting at 0, to change from 3 to 0.
Calculate the expected number of moves until the second digit changes from 3 to 0. That will be a large number, because the first number has to change from 3 to 0 four times without the 2nd digit changing to 0. That might be a three digit number.
Then the third digit - that will take ages to change from 3 to 0 because it must survive a few hundred moves without being changed back to 0.
The fourth digit will take a massive time. If you simulate it, it’s unlikely to succeed in your lifetime.
