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<vector>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
int main(){
    string s,t;
    while(cin >> s >> t, s != "0"){
        int x = 0, y = 0;
        int a[10] = {}, b[10] = {};
        rep(i,4){
            if(s[i] == t[i])x++;
            else{
                a[s[i]-'0']++;
                b[t[i]-'0']++;
            }
        }
        rep(i,10)y += min(a[i],b[i]);
        cout << x << " " << y << endl;
    }
}

C++: // 2011/07/27 Tazoe

#include <iostream>
#include <string>
using namespace std;

int main()
{
	while(true){
		string r, a;
		cin >> r >> a;
		if(r=="0"&&a=="0")	// ツ閉カツ篠堋療ア
			break;

		int hit = 0;
		int blw = 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
						blw++;

		cout << hit << ' ' << blw << endl;
	}

	return 0;
}

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

int main() {
	string s, t;
	while(cin >> s >> t, s != "0" && t != "0") {
		int a[10] = {0}, b[10] = {0};
		int hit = 0, blow = 0;
		for(int i = 0; i < s.size(); i++) {
			if(s[i] == t[i])
				hit++;
			else {
				a[s[i]-'0']++;
				b[t[i]-'0']++;
			}
		}
		for(int i = 0; i < 10; i++) {
			blow += min(a[i], b[i]);
		}
		cout << hit << " " << blow << endl;
	}
}

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 <string>
using namespace std;

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

C++: #include <iostream>
#include <cstdio>
using namespace std;
int main(){
  int i ,j ,n ,m ,hit=0 ,blow=0;
  char a[5] ,r[5];
  while( 1 ){
    cin >> a;
    cin >> r;

    if( a[0] == '0' && r[0] == '0' ){
      break;
    }

    for( i=0 ; i<4 ; i++ ){
      for( j=0 ; j<4 ; j++ ){
	if( a[i] == r[j] ){
	  
	  if( i == j ){
	    hit++;
	  }
	  else{
	    blow++;
	  }
	}
      }
     
    }
      
    printf( "%d %d\n" ,hit ,blow );
    hit = 0;
    blow = 0;
  }
  
  return 0;
}

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int main() {
	string a, b;
	
	while (cin >> a >> b) {
		if (a == "0") break;
		
		int hit = 0, blow = 0;
		
		for_(i,0,4) if (a.find(b[i]) != a.npos) ++blow;
		for_(i,0,4) if (a[i] == b[i]) { ++hit; --blow; }
		
		cout << hit << " " << blow << endl;
	}
}

C++: #include<iostream>
#include<cstring>
using namespace std;
int main(){
int h;
int b;
char r[10],a[10];
cin>>r>>a;
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++: // 2011/02/17 Tazoe

#include <iostream>
#include <string>		// string^ðg¤½ßÉ
using namespace std;

int main()
{
	while(true){
		string r, a;		// stringi¶ñj^
		cin >> r >> a;
		if(r=="0"&&a=="0")
			break;

		int hit = 0;
		int blw = 0;
		for(int i=0; i<4; i++)
			for(int j=0; j<4; j++)		// ½è
				if(r[i]==a[j])		// ª¯¶ÈçÎ
					if(i==j)		// Êuà¯¶ÈçÎ
						hit++;
					else
						blw++;

		cout << hit << ' ' << blw << endl;
	}

	return 0;
}

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  string l, r;
  while (cin >> l >> r, l != "0") {
    int a = 0;
    vc p, q;
    rep(i, 4) {
      if (l[i] == r[i]) {
        a++;
      } else {
        p.pb(l[i]), q.pb(r[i]);
      }
    }
    sort(all(p)), sort(all(q));
    vc r;
    set_intersection(all(p), all(q), back_inserter(r));
    cout << a << ' ' << r.size() << endl;
  }
}

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

int main(){
    string S,T;
    while(cin >> S >> T, S != "0" && T != "0"){
        set<char> st;
        for(char& c : S) st.insert(c);

        int hit = 0;
        int blow = 0;
        for(int i = 0; i < T.size(); i++){
            if(S[i] == T[i]) hit++;
            else blow += st.count(T[i]);
        }

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

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

int main(void) 
{
	char a[4], b[4];
	int c, d, e, f, g, i, j;

	while (cin >> c >> d)
	{
		if (c == 0 && d == 0)break;
		f = 0, g = 0;
		e = 1000;
		for (i = 0; i < 4; i++)
		{
			a[i] = c / e;
			b[i] = d / e;
			c -= a[i] * e;
			d -= b[i] * e;
			e /= 10;
		}

		for (i = 0; i < 4; i++)
		{
			for (j = 0; j < 4; j++)
			{
				if (a[i] == b[j])
				{
					if (i == j)
					{
						f++;
					}
					else
					{
						g++;
					}
				}
			}
		}
		cout << f << " " << g << endl;
	}
}

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

int main() {
	while (1) {
		string a, b;
		cin >> a >> b;
		if (a == "0"&&b=="0")break;
		vector<int>c(4);
		vector<int>d(4);
		for (int e = 0; e < 4; e++) {
			c[e] = a[e] - 48;
		}
		for (int e = 0; e < 4; e++) {
			d[e] = b[e] - 48;
		}
		int f = 10;
		int s = 0;
		for (int g = 0; g < 4; g++) {
			if (c[g] == d[g]) { s++; c[g] = f++; d[g] = f++; }
		}
		cout << s << " ";
		s = 0;
		for (int h = 0; h < 4; h++) {
			for (int i = 0; i < 4; i++) {
				if (c[h] ==d[i]) { s++; c[h] = f++; d[i] = f++; }
			}
		}
		cout << s << endl;
	}
}

C++: #include <iostream>
using namespace std;
int a,b,n[4],m[4];
int main(){
	int i,j,h,l;
	while(cin >> a >> b && (a != 0 && b != 0)){
		h = 0;
		l = 0;
		for(i=0;i<4;i++){
			n[i] = a % 10;
			m[i] = b % 10;
			a /= 10;
			b /= 10;
		}
		for(i=0;i<4;i++){
			for(j=0;j<4;j++){
				if(n[i] == m[j]){
					if(i==j) h++;
					else l++;
				}
			}
		}
		cout << h << " " << l << endl;
	}
}