Go: package main

import (
	"bufio"
	"os"
	"strings"
	"fmt"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		buf := strings.Split(scanner.Text(), " ")
		_a, _ := strconv.Atoi(buf[0])
		_b, _ := strconv.Atoi(buf[1])
		a := strings.Split(buf[0], "")
		b := strings.Split(buf[1], "")
		if _a == 0 && _b == 0 {
			break
		}
		hit := 0
		blow := 0
		for i, av := range a {
			for j, bv := range b {
				if i == j && av == bv {
					hit++
				}
				if i != j && av == bv {
					blow++
				}
			}
		}
		fmt.Println(hit, blow)
	}
}

C++: //include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main() {
  string r, a;

  while(1) {
    cin >> r >> a;
    if(r[0] == '0' && a[0] == '0') break;
    int hit = 0, blow = 0;
    
    REP(i, 4) {
      if(r[i] == a[i]) {
	hit++;
	continue;
      }
      REP(j, 4) {
	if(r[i] == a[j]) blow++;
      }
    }
    cout << hit << ' ' << blow << endl;
  }  
}

C++: #include<bits/stdc++.h>

using namespace std;

int main(){

  string s,k;

  while(1){

	cin>>s>>k;

	if(s == "0" && k == "0")
	  break;

	int hit=0;
	int blow=0;
	
	for(int i=0;i<4;++i){

	  if(s[i] == k[i])
		hit++;

	  else{
		for(int j=0;j<4;++j){

		  if(s[i]==k[j]){
			blow++;
			break;
		  }
		}
		
	  }
	
	}

	cout<<hit<<" "<<blow<<endl;
	
  }
}

C++: #include <iostream>
#include <string>
#include<algorithm>
using namespace std;
 
int main() {
    string a,b;
    int c=0,d=0;
 
    while(cin>>a>>b){
        if(a=="0"&&b=="0"){
        	break;
        }	
        for(int i=0;i<4;i++){
            if(a[i]==b[i]){
            	c++;
            }	
        }
         
        for(int j=0;j<4;j++){
            for(int k=0;k<4;k++){
                if(j!=k&&a[j]==b[k]){
                	d++;
                }	
            }
        }
        
        cout<<c<<" "<<d<<endl;
        c=0;
        d=0;
        }
     
     
    return 0;
}

C++: #include<iostream>
#include<cstring>
using namespace std;
int main(){
int h;
int b;
int n=1;
while(n<0){
char r[10],a[10];
cin>>r>>a;
if((r[0]=='0')&&(a[0]=='0')){
break;
}
for(int i=0;i<4;i++){
for(int j=0;j<4;j++){
if(r[i]==a[j]){
b++;
if(i==j){
h++;
}
}
}
}
}
b=b-h;
cout<<h<<' '<<b<<endl;
return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;++i)
int main(){
  string r, a;
  while(cin>>r>>a, r!="0"){
    int h = 0, b = 0;
    REP(i, 4) REP(j, 4){
      if(r[i] == a[j]){
        if(i == j) h++;
        else b++;
      }
    }
    cout<<h<<" "<<b<<endl;
  }
  return 0;
}

C++: #include <stdio.h>

int main(void) {
  int n, i, j, k;
  char a[10], b[10];
  while(1) {
    scanf("%s", a);
    scanf("%s", b);
    if(!a[1]) break;
    int h = 0, bl = 0, flag[10];
    for(i = 0; i < 10; ++i) flag[i] = 0;
    for(i = 0; i < 4; ++i) {
    if(a[i] == b[i]) h++;
    else flag[a[i] - '0'] = 1;
    }
    for(i = 0; i < 4; ++i) if(flag[b[i] - '0']) ++bl;
    printf("%d %d\n", h, bl);
  }
  return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    int hit,brow;
    char a[5],b[5];
    for(;;){
        hit=0,brow=0;
        cin>>a>>b;
        if(a[0]=='0'&&a[1]=='\0'){
            break;
        }
        for(int i=0;i<3;i++){
            for(int j=i+1;j<4;j++){
                if(a[i]==b[j]||b[i]==a[j]){
                    brow++;
                }
            }
        }
        for(int i=0;i<4;i++){
            if(a[i]==b[i]){
                hit++;
            }
        }
        cout<<hit<<" "<<brow<<endl;
    }
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main(){
  int hit,blow;
  vector<int> a,b;
  string ina,inb;
  while(1){
    cin >> ina >> inb;
    if(ina=="0"&&inb=="0") break;
    for(int i=0;i<4;i++){
      a.push_back(ina[i]-'0');
      b.push_back(inb[i]-'0');
    }
    hit=blow=0;
    for(int i=0;i<4;i++){
      for(int j=0;j<4;j++){
	if(a[i]==b[j]){
	  if(i==j) hit++;
	  else blow++;
	}
      }
    }
    cout << hit << ' ' << blow << endl;
    a.clear();
    b.clear();
  }
  return 0;
}

C++: #include<stdio.h>
int main(){
  int a,b,i,j;
  char s[10],t[10];
  while(scanf("%s %s",s,t),s[1]){
    a=b=0;
    for(i=0;i<4;i++){
      if(s[i]==t[i])a++;
      for(j=0;j<4;j++){
	if(s[i]==t[j])b++;
      }
    }
    printf("%d %d\n",a,b-a);
  }
  return 0;
}

C++: #include<iostream>
#include<cstring>
using namespace std;
int main(){
for(int x=0;x>=0;x++){
int h;
int b;
char r[10],a[10];
char z[2]="0";
cin>>r>>a;
if((strcmp(r,z)==0)&&(strcmp(a,z)==0)){
break;
}
for(int i=0;i<4;i++){
for(int j=0;j<4;j++){
if(r[i]==a[j]){
b++;
if(i==j){
h++;
}
}
}
}
b=b-h;
cout<<h<<' '<<b<<'\n';
}
return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
	bool f[10];
	string a,b;
	while(1){
		int hit=0,blow=0;
		cin>>a>>b;
		if(a=="0"&&b=="0")break;
		memset(f,false,sizeof(f));
		for(int i=0;i<4;i++){
			f[a[i]-'0']=true;
		}
		for(int i=0;i<4;i++){
			if(b[i]==a[i])hit++;
			else if(f[b[i]-'0'])blow++;
		}
		cout<<hit<<" "<<blow<<endl;
	}
}

C++: #include<iostream>
#include<cstring>
using namespace std;

int hit(char* s1,char* s2){
	int n=0;
	for(int i=0;i<4;i++){
		if(s1[i]==s2[i]){
			n++;
		}
	}
	return n;
}

int blow(char* s1,char* s2){
	int n=0;
	for(int i=0;i<4;i++){
	if(s1[i]==s2[0]){
		n++;
		}
	if(s1[i]==s2[1]){
		n++;
		}
	if(s1[i]==s2[2]){
		n++;
		}
	if(s1[i]==s2[3]){
		n++;
		}
	}
	return n;
}

int main(){
	char r[5],a[5];
	for(int i=0;i<100;i++){
		cin>>r;cin>>a;
		if(r==0&&a==0){
		i=101;
		}
		else{
		cout<<hit(r,a)<<' '<<blow(r,a)-hit(r,a)<<endl;
		}
	}
return 0;
}

C++: #include<iostream>
#include<string>
#include<cstring>

int main()
{
	std::string r, a;
	while( std::cin >> r >> a, r != "0" || a != "0" )
	{
		bool fr[10], fa[10];
		int hit = 0, blow = 0;
		memset( fr, false, sizeof( fr ) );
		memset( fa, false, sizeof( fa ) );

		for( int i = 0; i != r.size(); ++i )
		{
			if( r[i] == a[i] )
				++hit;
			else
			{
				fr[r[i]-'0'] = true;
				fa[a[i]-'0'] = true;
			}
		}

		for( int i = 0; i != 10; ++i )
			if( fr[i] & fa[i] )
				++blow;

		std::cout << hit << ' ' << blow << std::endl;
	}

	return 0;
}