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<cstring>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
using namespace std;
int main(){
char a[5],b[5];
while(cin>>a>>b,a[0]-'0'||b[0]-'0'){
int h=0,v=0;
//cout<<a[0]<<endl;
rep(i,4){
rep(j,4){
if(i==j&&a[i]==b[j])h++;
else if(a[i]==b[j])v++;
}
}
cout<<h<<" "<<v<<endl;
}
}

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

int main(){
    while(1){
    int h,b;
    h=0; b=0;
    char r[10];
    char a[10];
    char x[5]="0";
    cin>>r>>a;
    if((strcmp(r,x)==0)&&(strcmp(a,x)==0)){
        break;
    }
    for(int i=0;i<4;i++){
        if(r[i]==a[i]){
            h++;
        }
        for(int j=0;j<4;j++){
            if(r[i]==a[j]){
                b++;
            }
        }
    }
    b=b-h;
    cout<<h<<' '<<b<<endl;
    }
    return 0;

}

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

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

 int hit,blow;

 cin >> qwe >> ans;
 
 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;

 return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;

string r,a;

bool input(){
  cin>>r>>a;
  if(r=="0")return false;
  return true;
}
int solve(){
  int x=0,y=0;
  for(int i=0;i<r.size();i++){
    for(int j=0;j<a.size();j++){
      if(r[i] == a[j]){
        if(i==j){
          y++;
        }else{
          x++;
        }
      }
    }
  }
  cout<<y<<" "<<x<<endl;
}


int main(){
  while(input()){
    solve();
  }

}

C++: // #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;

#define MP make_pair
#define fastIO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
int INPUT_INT() { int d; cin >> d; return d; } // 入力をpush_back(d)やarray[d]に使う時に無駄な変数を使わない

// ------------------- include, typedef, define END. -------------------

void solve(string ans, string kore_de_douda){
	int hit = 0, blow = 0;
	FOR(i, 0, 4){
		if (ans[i] == kore_de_douda[i])
			hit++;
		else{
			if (kore_de_douda.find(ans[i])!=string::npos)
				blow++;
		}
	}
	cout << hit << " " << blow << endl;
}

int main(){
	fastIO;
	string ans, kore_de_douda;
	while (cin >> ans >> kore_de_douda, ans!="0"||kore_de_douda!="0"){
		solve(ans, kore_de_douda);
	}
	return 0;
}

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

C++: #include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
	int i, j, h, b;
	while (1)
	{
		char r[5] = "", a[5] = "";
		cin >> r >> a;
		if (atoi(r) == 0 && atoi(a) == 0) break;
		h = b = 0;
		for (i = 0; i < 4; i++)
		{
			for (j = 0; j < 4; j++)
			{
				if (r[i] == a[j])
				{
					if (i == j)
						h++;
					else
						b++;
				}
			}
		}
		cout << h << " " << b << endl;
	}
}

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

using namespace std;

int main(void){
	int a,b;
	string str1;
	string str2;
	while(1){
		cin >> str1 >> str2;
		if(str1=="0" && str2=="0")break;
		int h=0,bl=0;
		for(a=0;a<4;a++){
			for(b=0;b<4;b++){
				if(str1[a]==str2[b]){
					if(a==b)h++;
					else bl++;
				}
			}
		}
		cout << h << " " << bl << endl;
	}
	return 0;
}

C++: char a[17]="0 0";main(i,j){for(;a[2]=*a=48,scanf("%[^\n]\n",a+5),a[8];puts(a)){for(i=4;++i<9;)for(j=4;++j<9;)a[j+5]-a[i]||a[(i!=j)*2]++;}i=0;}

C++: #include<iostream>
#include<string>
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++ ){
			for( int j=0; j<4; j++ ){
				if( r[i] == a[j] ){
					if( i==j )	hit++;
					else		blow++;
					a[j] = '*';
				}
			}
		}
		cout << hit << " " << blow << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  string a,b;
  while(cin>>a>>b){
    int c=0,d=0;
    if(a.size()==1&&a[0]=='0')break;
    r(i,4){
      if(a[i]==b[i])c++;
      else r(j,4)if(a[i]==b[j])d++;
    }
    cout<<c<<' '<<d<<endl;
  }
}

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

int main()
{
while{
 char stra[10], strb[10];
 int hit,bro;
 cin>>stra>>strb;

 for(int i=0;i<4;i++){
  if(stra[i]==strb[i]){
	hit++;}
  for(int j=0;j<4;j++){
	if(stra[i]==strb[j])
	 bro++;}
 }
if(stra==0&&strb==0){break;}
bro=bro-hit;
cout<<hit<<' '<<bro<<'\n';

}
return 0;}

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

int main() {
  char r[4], a[4];
  int h, b;

  while(1) {
    cin >> r >> a;
    if(r[0] == '0' && a[0] == '0') break;

    h = 0;
    b = 0;

    for(int i = 0 ; i < 4; i++){
      if(r[i] == a[i])
        h++;
    }

    for(int i = 0 ; i < 4; i++) {
      for(int j = 0; j < 4; j++) {
        if(r[i] == a[j])
          b++;
      }
    }

  cout << h << ' ' << (b-h) << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <cstdio>
using namespace std;
int main(){
    char p1[5],p2[5],b,h;
    while(1){
        b=0;
        h=0;
        scanf("%s %s",p1,p2);;
        if(p1[0] - '0' == 0 && p2[0] - '0' == 0){
            break;
        }
        for(int i=0;i<4;i++){
            for(int j=0;j<4;j++){
                if(p1[i] - '0' ==  p2[j] - '0' && i == j){
                    h++;
                }
                else if(p1[i] - '0' == p2[j] - '0'){
                    b++;
                }
            }
        }
        printf("%d %d\n",h,b);
    }
}

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

using namespace std;

int main(){
	string a,b;
	while(cin >> a >> b){
		if(a == "0" && b == "0") break;
		int hit=0,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;
	}
}