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>
int main(){int h,b,i,j;std::string r,a;while(std::cin>>r>>a,r!="0"&&a!="0"){for(h=b=i=0;i<4;i++)for(j=4;j-->0;)if(a[i]==r[j])i==j?h++:b++;printf("%d %d\n",h,b);}}

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

int main(){
 
 char qwe[6],ans[6];

 int hit,blow,count;

     count = 0;
 
 while(1){
    cin >> qwe >> ans;
    if(qwe[0]='0'&&ans[0]=='0'&&qwe[1]=='\0'&&ans[1]=='\0') break;
    hit = 0 ;
    blow = 0;


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

           if(qwe[i] == ans[g]){
               
                if(i == g)
                      hit++;
                else
                      blow++;
            }
       }
    }
   
   cout << hit << " " << blow << endl;
   count++;
  }

  hit = 0 ;
  blow = 0;

/*  while(hit != 4){
    if(count == 0){
      break;
    } 
    cin >> qwe >> ans;
    hit = 0 ;
    blow = 0;

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

           if(qwe[i] == ans[g]){
               
                if(i == g)
                      hit++;
                else
                      blow++;
            }
       }
    }
   
   cout << hit << " " << blow << endl;
   
   count--;
 }*/

 return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

int main (int argc, char *argv[]) {
    string str1, str2;
    while (cin>>str1>>str2, str1.length() != 1) {
        int hit = 0;
        int blow = 0;
        for (int i = 0; i < 4; ++i) {
            if (str1[i] == str2[i]) hit++;
            for (int j = 0; j < 4; ++j) {
                if (i == j) continue;
                if (str1[i] == str2[j]) blow++;
            }
        }
        cout<<hit<<" "<<blow<<endl;
    }
    return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>

using namespace std;

int main(int argc, char *argv[]) {
  string s, t;
  int hit, blow;

  while (true) {
    cin >> s >> t;
    if (s == "0")
      break;
    hit = blow = 0;
    for (int i = 0; i < 4; i++)
      for (int j = 0; j < 4; j++)
        if (i == j && s[i] == t[j])
          hit++;
        else if (s[i] == t[j])
          blow++;
    cout << hit << ' ' << blow << endl;
  }
  return 0;
}

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

int main(){
  while(1){
    int h=0,b=0;
    string r,a;
    cin >> r >> a;
    if(r=="0"&&a=="0")
      break;
    for(int i=0;i<r.size();i++){
      for(int j=0;j<r.size();j++){
        if(r[i]==a[j])
          (i==j)?h++:b++;
      }
    }
    cout << h << " " << b << endl;
  }
  return 0;
}

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

int main()
{
  string r, a;
  int c1, c2;

  while (cin >> r >> a && r != "0"){
    c1 = c2 = 0;
    for (int i = 0; i < 4; i++){
      if (r[i] == a[i]){
        c1++;
      }
    }
    for (int i = 0; i < 4; i++){
      for (int j = 0; j < 4; j++){
        if (r[i] == a[j] && i != j){
          c2++;
        }
      }
    }

    cout << c1 << " " << c2 << endl;
  }
}

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

int main(){
	int x,y,n[4],m[4];
	int h,b,i,j;
	
	while(1){
		cin >> x >> y;
		if(x+y==0) break;
		
		h=0; b=0;
		
		for(i=3; i>0; i--){
			n[i]=x/pow(10,i);
			x-=n[i]*pow(10,i);
			m[i]=y/pow(10,i);
			y-=m[i]*pow(10,i);
		}
		n[0]=x; m[0]=y;
		
		for(i=0;i<4;i++){
			if(n[i]==m[i]) h++;
			else for(j=0;j<4;j++){
				if(n[i]==m[j]) b++;
			}
		}
		
		cout << h << " " << b << endl;
	}
	
	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<string>
using namespace std;
string S1,S2;
int A1,A2;
int main()
{
	while(true){
	cin >> S1 >> S2;
	A1=0;A2=0;
	if(S1.length()==1)break;
	for(int i=0;i<4;i++){
		if(S1[i]==S2[i])A1++;
	}
	for(int i=0;i<4;i++){
		for(int j=0;j<4;j++){
			if(i==j)continue;
			if(S1[i]==S2[j])goto a;
		}
		continue;
		a:;
		A2++;
	}
	printf("%d %d\n",A1,A2);
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int n,n2,in[4],in2[4],hit,blow,d;
  while(cin>>n>>n2){
    if(n==0&&n2==0) break;
    d = 1000;
    //cout << n << " " << n2 << endl;
     for(int i=0;i<4;i++){
      in[i] = n / d;
      in2[i] = n2 / d;
      n -= in[i] * d;
      n2 -= in2[i] * d;
      d /= 10;
      //cout << in[i] << endl << in2[i] << endl;  
    } 
    hit = 0;
    blow = 0;    
    for(int i=0;i<4;i++){
      for(int j=0;j<4;j++){
      if(in[i]==in2[j]&&i==j) hit++;
      else if(in[i]==in2[j]) blow++;
      }
    }
    cout << hit << ' ' << blow << endl;
  }
  return 0;
}

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

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

int main(){
	string s,t;
	while(1){
		int cnt[2][10] = {},hit = 0,blow = 0;
		cin >> s >> t;
		if(s == "0") break;
		for(int i = 0;i < 4;i++){
			if(s[i] == t[i]) hit++;
			else{
				cnt[0][s[i] - '0']++;
				cnt[1][t[i] - '0']++;
			}
		}
		for(int i = 0;i < 10;i++){
			blow += min(cnt[0][i],cnt[1][i]);
		}
		cout << hit << " " << blow << endl;
	}
	return 0;
}

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

using namespace std;

int main(void){

  string taro,hanako;
  while( cin >> taro >> hanako ){
    if( taro == hanako && taro == "0" )break;

    int hit = 0;
    int blow = 0;
    for( int i = 0 ; i < 4 ; i++ ){
      for( int j = 0 ; j < 4 ; j++ ){
	if( i != j && taro[i] == hanako[j] ){
	  hit++;
	}
	if( i == j && taro[i] == hanako[j] ){
	  blow++;
	}
      }
    }
    cout << blow << " " << hit << endl;

  }
  return 0;
}

C++: #include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


int main() {
	int r, a;
	while (cin >> r >> a && r > 0 && a > 0) {
		vi d(4, 0), e(4, 0), n(10, 0);
		rep(i, 4) {
			d[i] = r % 10;
			e[i] = a % 10;
			n[r % 10]++;
			r /= 10;
			a /= 10;
		}
		int b = 0, h = 0;
		rep(i, 4) {
			if (d[i] == e[i])b++;
			else if (n[e[i]] > 0)h++;
		}
		cout << b << " " << e << endl;
	}
}