SOLUTION. Consider a four digit number ABCD. Suppose the free variable is var(0).

First we obtain the first digit, the one to the far left. If we divide ABCD by 1000, then we obtain a number of the form A.BCD. Observe that floor(A.BCD) = A. We obtained our first digit, we can then display it on screen!

Now that we have the first digit, we need to get the second one, B, next. We already know A, so we can perform the operation ABCD - A*1000. Which yields BCD. We then perform

* the previous procedure* to BCD!

BCD / 100 = B.CD. Thus floor(B.CD) = B and we obtain the second digit! We then perform the operation BCD - B*100 = CD and

*repeat the procedure* until we hit D.

Here there's a very clear procedure that we keep performing

*in steps*, this is recursion! How would we code this solution in MUGEN? It would go something like this:

[State x, null]

type = null

trigger1 = var(0) := ABCD ;We assign the value of ABCD to var(0).

[State x, Display A]

type = Explod

trigger1 = !time ;Trigger on the first tick

...

value = floor(var(0)/1000),0 ;Display A. (Asuming the digits are in the groups X,0). Here we are displaying explod "A,0".

...

[State x, Display B]

type = Explod

trigger1 = !time ;Trigger on the first tick

trigger1 = var(0):= var(0) - floor(var(0)/1000)*1000 ;This operation trims the leftmost digit.

...

value = floor(var(0)/100),0 ;Display B. (Asuming the digits are in the groups X,0). Here we are displaying explod "B,0".

...

[State x, Display C]

type = Explod

trigger1 = !time ;Trigger on the first tick

trigger1 = var(0):= var(0) - floor(var(0)/100)*100 ;This operation trims the leftmost digit.

...

value = floor(var(0)/10),0 ;Display C. (Asuming the digits are in the groups X,0). Here we are displaying explod "C,0".

...

[State x, Display D]

type = Explod

trigger1 = !time ;Trigger on the first tick

trigger1 = var(0):= var(0) - floor(var(0)/10)*10 ;This operation trims the leftmost digit.

...

value = var(0),0 ;Display D. (Asuming the digits are in the groups X,0). Here we are displaying explod "D,0".

...

[State x, null]

type = null

trigger1 = var(0) := 0 || e ;We nullify var(0) since our operations are complete.