The score-calculating code isn't quite correct. One error is the fact that %g*num vars are set to "x" before they are used in $remtok, whereas this should happen afterwards. But that's not the only problem (eg it fails with number = 8888, guess = 1118).

Here's an alternative that works with numbers of any length (not just 4).
Code:
; $mmscore(actual, guess)
; eg $mmscore(2778,7777)
; returns <correct> <close>
; ("2 0" for the above example)
alias mmscore {
  var %i = 1, %correct = 0, %close = 0
  while $mid($2,%i,1) != $null {
    if $v1 == $mid($1,%i,1) {
      inc %correct
      tokenize 32 $left($1,$calc(%i - 1)) $+ $right($1,- $+ %i) $&
        $left($2,$calc(%i - 1)) $+ $right($2,- $+ %i)
    }
    else inc %i
  }
  %i = 1
  while $mid($2,%i,1) != $null {
    if $pos($1,$v1) {
      inc %close
      tokenize 32 $left($1,$calc($v1 - 1)) $+ $right($1,- $+ $v1) $2
    }
    inc %i
  }
  return %correct %close
}


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com