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<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[6][1010];//動的計画法
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
   int n,m;
   while(cin>>n>>m){
       if(n==0&&m==0) break;
       int hit=0,blow=0,pl[4],ans[4];
       for(int i=0;i<4;i++){
           pl[i]=ans[i]=0;
       }
       for(int i=3;i>=0;i--){
           pl[i]=n%10;
           ans[i]=m%10;
           n/=10;
           m/=10;
       }
       for(int i=0;i<4;i++){
           if(pl[i]==ans[i]) hit++;
       }
       for(int i=0;i<4;i++){
           for(int j=0;j<4;j++){
               if(pl[i]==ans[j]){
                   blow++;
                   break;
               }
           }
       }
       cout<<hit<<' '<<blow-hit<<endl;
   }
    return 0;
}

C++: #include<iostream>

int hit=0,blow=0;
char r[5],a[5];

bool exist(char c, char *s){
	for(int i=0; i<4; i++)
		if(c == s[i])
			return true;
	return false;
}

void check(){
	for(int i=0; i<4; i++){
		if(r[i] == a[i])
			hit++;
		else if(exist(r[i],a))
			blow++;
	}
}

int main(){
	while(true){
		std::cin >> r >> a;
		if(r[0] == '0' && a[0] == '0')
			return 0;
		check();
		std::cout << hit << ' ' << blow << std::endl;
		hit = 0;
		blow = 0;
	}
}

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

int main(){
 while(1){
	string stra,strb;
	cin>>stra>>strb;
	int h=0,b=0;

	if((stra=="0")&&(strb=="0")){
	 break;}

	for(int i=0;i<4;i++){
	 if(stra[i]==strb[i]){
		h++;
	 }
	 for(int j=0;j<4;j++){
		if(stra[i]==strb[j]){
			b++;
		}
	 }
	}

  b=b-h;
  cout<<h<<' '<<b<<'\n';
 }
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>
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>
using namespace std;


int main(){
	int a,b;
	while(cin>>a>>b,a|b){
		int c[10]={},hit=0,blow=0;
		for(int i=0;i<4;i++){
			if(a%10==b%10)hit++;
			c[a%10] |= 1;
			c[b%10] |= 2;
			a/=10;
			b/=10;
		}
		for(int i=0;i<10;i++){
			if(c[i]==3)blow++;
		}
		blow -= hit;
		cout<<hit<<' '<<blow<<endl;
	}
	return 0;
}

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

int main(){
 while(1){
	string stra,strb;
	cin>>stra>>strb;
	int h=0,b=0;

	if((stra=="0")&&(strb=="0")){
	 break;}

	for(int i=0;i<4;i++){
	 if(stra[i]==strb[i]){
		h++;
	 }
	 for(int j=0;j<4;j++){
		if(stra[i]==strb[j]){
			b++;
		}
	 }
	}

  b=b-h;
  cout<<h<<' '<<b<<'\n';
 }
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<<'\n';
return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#define INF 999999
using namespace std;
int main(){
    string A,B;
    while(cin>>A>>B){
        int hit=0,blow=0;
        if(A=="0")break;
        for(int i=0;i<4;i++){
            if(A[i]==B[i]){
                hit++;
                A[i]='A';B[i]='B';
            }
        }
        for(int i=0;i<4;i++){
            for(int j=0;j<4;j++){
                if(A[i]==B[j]){
                    blow++;
                    B[j]='B';
                    break;
                }
            }
        }
        cout<<hit<<" "<<blow<<endl;
    }

    return 0;
}

C++: #include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

const int INF = 10000000;
using namespace std;
typedef long long  ll;

int main()
{
	int hit, blow;
	string num, tmp;
	
	while (1) {
		hit = 0; blow = 0;
		
		cin >> num;
		cin >> tmp;
		if (num=="0" && tmp=="0") break;
		
		for (int i=0; i<4; i++)
			for (int j=0; j<4; j++)
				if (num[i] == tmp[j]) {
					if (i == j) hit++;
					else		blow++;
				}
		cout << hit << " " << blow << endl;
		
	}
	return 0;
}

C++: #include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j;
  int h,b;
  string r,a;
  while(cin>>r>>a&&r!="0"&&a!="0"){
    h=b=0;
    for(i=0;i<4;i++){
      for(j=0;j<4;j++){
	if(r[i]==a[j])
	  b++;
      }
    }	  
    for(i=0;i<4;i++){
      if(r[i]==a[i]){
	h++;
	b--;
      }
    }
    cout<<h<<" "<<b<<endl;
  }
  return 0;
}

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<bits/stdc++.h>
using namespace std;

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

    return 0;
}

C++: #include <cstdio>
#include <vector>
#include <set>

using namespace std;



int main(){
	int self;
	char a[5];
	char b[5];
	int h;
	int br;
	while(1){
		scanf("%s %s",a,b);
		if(a[1] == '\0' && b[1] == '\0'){
			break;		
		}
		set<int> s;
		h = 0;
		br = 0;
		for(int i=0;i<4;i++){
			if(a[i] == b[i]){
				h+=1;
			}
			s.insert(b[i]);
		}
		set< int >::iterator it;
		for(it = s.begin();	it != s.end();it++){
			for(int i=0;i<4;i++){
				if(a[i]==*it){
					br+=1;
				}
			}
		}
		br-=h;
		printf("%d %d\n",h,br);
	}
	return 0;
}

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

int main(){
	while(1){
		int hit = 0, blow = 0;
		string num[2];

		cin>>num[0]>>num[1];
		if((num[0] == "0") && (num[1] == "0"))
			break;
		
		for(int i=0;i<4;i++)
			for(int j=0;j<4;j++)
				if(num[0][i] == num[1][j])
					if(i == j)
						hit++;
					else
						blow++;
		
		cout<<hit<<" "<<blow<<endl;
	}
	return 0;
}