Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		buf := strings.Split(scanner.Text(), " ")
		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 <iostream>
#include <string>
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

int p[50];
void init(){rep(i,26) p[i]=i;}
int find(int x){return x==p[x]?x:p[x]=find(p[x]);}
void unite(int a,int b){a=find(a),b=find(b),p[a]=b;}
bool same(int a,int b){return find(a)==find(b);}

int main(){
	string r,a;
	while(cin >> r >> a){
		if(r=="0") break;
		int hit=0,blow=0;
		rep(i,4)rep(j,4) if(r[i]==a[j]) blow++;
		rep(i,4) if(r[i]==a[i]) hit++;
		cout << hit << " " << blow-hit << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>
#include <fstream>
#include <cassert>
using namespace std;


//common
typedef int  i32;
typedef long long i64,ll;
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef long long ll; typedef vector<long long> vl; typedef pair<long long,long long> pll; typedef vector<pair<long long,long long> > vpll;
typedef vector<string> vs; typedef long double ld;

#define BR "\n"
#define ALL(c) (c).begin(),(c).end()
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define EACH(it,o) for(auto it = (o).begin(); it != (o).end(); ++it)
#define IN(l,v,r) ((l)<=(v) && (v)<(r))

//config
//#undef NDEBUG
//#define INF 1<<30
//#define EPS 1e-8
//const ll MOD =100000007;

//debug
#ifdef NDEBUG
#define DUMP(x)
#define DUMPLN(x)
#define DEBUG(x)
#define DEBUGLN(x)
#define LINE()
#define LINELN()
#define CHECK(exp,act)
#define STOP(e)
#else
#define DUMP(x)  cerr << #x << " = " << (x)
#define DUMPLN(x)  DUMP(x) <<endl
#define DEBUG(x) DUMP(x) << LINE() << " " << __FILE__
#define DEBUGLN(x) DEBUG(x)<<endl
#define LINE()    cerr<< " (L" << __LINE__ << ")"
#define LINELN()    LINE()<<endl
#define CHECK(exp,act)  if(exp!=act){DUMPLN(exp);DEBUGLN(act);}
#define STOP(e)  CHECK(e,true);if(!(e)) exit(1);
#endif

template<class T> inline string toString(const vector<T>& x) {
	stringstream ss;
	REP(i,x.size()){
		if(i!=0)ss<<" ";
		ss<< x[i];
	}
	return ss.str();
}

template<class T> inline string toString(const vector<vector<T> >& map) {
	stringstream ss;
	REP(i,map.size()){
		if(i!=0)ss<<BR;
		ss<< toString(map[i]);
	}
	return ss.str();
}
template<class K,class V>  string toString(map<K,V>& x) {
	string res;stringstream ss;
	for(auto& p:x)ss<< p.first<<":" << p.second<<" ";
	return ss.str();
}

string BITtoString(int bit){
    stringstream ss;
    while(bit!=0){ss<<(bit%2);bit/=2;}
    string res=ss.str();reverse(ALL(res));
    return res;
}

template<typename T,typename V> inline T mod(T v,V MOD){
	return (v%MOD+MOD)%MOD;
}

class Main{
public:
	void run(){
	//	ifstream cin("in");
	//	ofstream cout( "out" );

		while(true){
			string r,a;cin >> r >>a;
			if(r=="0")break;
			int Sz=4;

			int h=0,b=0;
			REP(i,4){
				REP(j,4){
					if(a[i]==r[j]){
						if(i==j)h++;
						else b++;
					}
				}
			}
			cout << h<<" "<<b<<endl;
		}
	}
};
 int main(){
	ios::sync_with_stdio(false);
 	Main().run();
 	return 0;
 }

C++: #include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    string s, t;
    while(cin >> s >> t, s.size() == 4){
        int a = 0, b = 0;
        for (int i = 0; i < 4; ++i) {
            if(s[i] == t[i]) a++, b--;
            for (int j = 0; j < 4; ++j) {
                if(s[i] == t[j]) b++;
            }
        }
        printf("%d %d\n", a, b);
    }
    return 0;
}

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

using namespace std;

int main() {

	int  h, b;
	char r[5], a[5];

	while(cin >> r >> a) {
		if(!strcmp(r, "0")&&!strcmp(a, "0"))
			break;
		h=0;
		b=0;
		for(int i=0; i<4; i++) {
			for(int j=0; j<4; j++) {
				if(r[i]==a[j])
					i==j ? h++ : b++;
			}
		}
		cout << h << " " << b << endl;
	}

	return 0;

}

C++: #include <cmath>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <cstdio>
#include <cctype>
#include <queue>
#include <complex>
#include <climits>

typedef long long ll;

using namespace std;

int main(){
	string s1, s2;

	while(cin >> s1 >> s2){
		int H=0, B=0;
		if(s1 == "0" && s2 == "0") break;
		for(int i=0; i<4; ++i){
			if(s1[i] == s2[i]) H++;
			for(int j=0; j<4; ++j){
				if(s1[i] == s2[j] && i != j) B++;
			}
		}

		cout << H << " " << B << endl;
	}

    return 0;
}

C++: #include<iostream>
int main(){int f[2],i,j;std::string r,a;while(std::cin>>r>>a,r!="0"&&a!="0"){for(f[0]=f[1]=i=0;i<4;i++)for(j=4;j-->0;)if(a[i]==r[j])f[i!=j]++;printf("%d %d\n",f[0],f[1]);}}

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<<'\n';
return 0;
}

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

using namespace std;

int Judge[10];

int main() {
	int h, b;
	string r, a;

	while (cin >> r >> a, r.size() != 1) {
		//cout << r << " " << a << endl;
		memset(Judge, 0, sizeof(Judge));
		h = b = 0;
		for (int i = 0; i < 4; ++i) {
			if (r[i] == a[i]) {
				++h;
			}
			else {
				++Judge[r[i] - '0'];
			}
		}
		for (int i = 0; i < 4; ++i) {
			if (Judge[a[i] - '0'] != 0) {
				++b;
			}
		}
		cout << h << " " << b << endl;
	}

	return 0;
}

C++: #include <iostream>

using namespace std;
 
int main(){
    int Q,A,qq[4],aa[4],Hit,Blow,num;
 
    while(1){ 
	num = 1000;
	Hit = Blow = 0;
 
	cin >> Q >> A;
	if( Q == 0 && A == 0 ) break;
 
	for( int i = 0 ; i < 4 ; i++ ){
 
	    qq[i] = Q / num % 10;
	    aa[i] = A / num % 10;
	    num/=10;
 
	}
 
	for( int i = 0 ; i < 4 ; i++ ){
	    for( int j = 0 ; j < 4 ; j++ ){
 
		if( qq[i] == aa[j] && i == j ) Hit++;
		else if( qq[i] == aa[j] && i != j ) Blow++;
 
	    }
	}
	cout << Hit << " " << Blow << endl;
    }
    return 0;
}

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

int main()
{
    string r, a;
    while(cin >> r >> a && r != "0" && a != "0") {
        int hist1[10], hist2[10];
        memset(hist1, 0, sizeof(hist1));
        memset(hist2, 0, sizeof(hist2));
        
        int hit = 0;
        for(int i = 0; i < 4; i++) {
            hist1[r[i] - '0']++;
            hist2[a[i] - '0']++;
            if(r[i] == a[i]) {
                hit++;
            }
        }
        
        int blow = 0;
        for(int i = 0; i < 10; i++) 
            if(hist2[i] > 0 && hist1[i])
                blow += (hist2[i] > hist1[i]) ? hist1[i] : hist2[i];
        blow -= hit;
        
        cout << hit << " " << blow << endl;
    }   
}