alias fcalc { if ($chr(58) !isin $1-) { return } var %num $1- var %math $2 var %pos $pos(%num,$(%math,2)) var %side.1 = $remove($left(%num,%pos),$(%math,2)) var %side.2 = $right(%num,$+(-,%pos)) var %x 2 while (%x) { set $+(%,len.,%x) $calc($count($($+(%,side.,%x),2),$chr(58)) + 1) dec %x } if (%len.1 == %len.2) { var %y 1 var %x %len.1 while (%y <= 2) { while (%x) { set $+(%,cs,%y,.,%x) $gettok($($+(%,side.,%y),2),$(%x,2),58) dec %x 1 } inc %y 1 var %x %len.1 } var %x %len.1 while (%x) { var %c = $calc($($+(%,cs1.,%x),2) %math $($+(%,cs2.,%x),2)) set %ans $+($chr(58),%c,%ans) dec %x 1 } } echo -a Num: %num Ans: $right(%ans,-1) unset %len.* unset %calc.* unset %cs* unset %ans }