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 <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
#include <map>
using namespace std;
int main(){

	string a,b;
	
	while(cin>>a>>b,a!="0"||b!="0"){
		int h=0,l=0;
	for(int i=0;i<4;i++){
		for(int j=0;j<4;j++){
			if(a[i]==b[j]){
				if(i==j)
					h++;
				else
					l++;
			}
		}
	}
		cout<<h<<" "<<l<<endl;
	}
}

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

using namespace std;

int main(){
	char r[5];
	char a[5];
	cin>>r>>a;
	int h=0,b=0;
	for(int i=0;i<=3;i++){
			for(int j=0;j<=3;j++){
				if(r[i]==a[j]){
					b++;
					if(i==j){
						h++;
					}
				}
			}
	}
	b=b-h;
	cout<<h<<' '<<b<<endl;
	
	return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;
int main()
{
    while(1)
    {
        string r,a;
        int hit=0;
        int blow=0;
        cin>>r>>a;if(r=="0")return 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++;
                    }
                }
            }
        }
        cout<<hit<<" "<<blow<<endl;
    }
    return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main()
{
while(;;){
int a,b;
cin >> a >> b;
if(a==0&&b==0)return 0;
int x[4],y[4];
for(int i=0;i<4;i++){
x[i]=a%10;
a/=10;
y[i]=b%10;
b/=10;
}

int hit=0,blow=0;
for(int i=0;i<4;i++)if(x[i]==y[i])hit++;
}
for(int i=0;i<4;i++){
for(int j=0;j<4;j++)if(x[i]==y[j])blow++;
}
blow-=hit;

printf("%d %d\n",hit,blow);
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    int hit,brow;
    char a[5],b[5];
    for(;;){
        hit=0,brow=0;
        cin>>a>>b;
        if(a[0]=='0'&&b[0]=='0')break;
        for(int i=0;i<3;i++){
            for(int j=i+1;j<4;j++){
                if(a[i]==b[j]||b[i]==a[j])brow++;
            }
        }
        for(int i=0;i<4;i++){
            if(a[i]==b[i])hit++;
        }
        cout<<hit<<" "<<brow<<endl;
    }

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

int a[4],b[4];
void search()
{
	int hit=0,blow=0;
	for(int i=0;i<4;i++){
		for(int j=0;j<4;j++){
			if(a[i] == b[j] && i==j)
				hit++;
			else if(a[i]==b[j])
				blow++;
		}
	}
	cout << hit << ' ' << blow << endl;
}

int main()
{
	int m,n;
	while(cin >> m && cin >> n){
		if(m==0&&n==0)
			break;
		int j=10;
		for(int i=3;i>=0;i--){
			a[i] = m%j;
			b[i] = n%j;
			m/=j;
			n/=j;
		}
		search();
	}
	return 0;
}

C++: #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<cstdio>
int main(){int h,b,i,j;char r[5],a[5];while(scanf("%s%s",r,a),r[1]!='\0'&&a[1]!='\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;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

string s, t;

int main()
{
	while (cin >> s >> t, s != "0"){
		int a = 0, b = 0;
		rep(i, 4){
			if (s[i] == t[i]){
				a++;
				s[i] = t[i] = '*';
			}
		}
		rep(i, 4){
			if (s[i] == '*') continue;
			int p = t.find(s[i]);
			if (p != -1){
				b++;
				t[p] = '*';
			}
		}
		cout << a << " " << b << endl;
	}
}

C++: #include <iostream>
#include <cstdio>
using namespace std;
int main()
{
  for(;;){
    int r,a;
    cin >> r >> a;
    if(r == 0 && a == 0) break;
    char sr[5],sa[5];
    sprintf(sr,"%04d",r);
    sprintf(sa,"%04d",a);
    int hit = 0,blow = 0;
    for(int i=0; i<4; i++){
      for(int j=0; j<4; j++){
        if(sr[i] == sa[j]){
          if(i==j) hit++;
          else blow++;
          continue;
        }
      }
    }
    cout << hit << " " << blow << endl;
  }
  return 0;
}

C++: // 2014/06/20 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 h = 0, b = 0;

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

		cout << h << ' ' << b << '\n';
	}

	return 0;
}

C++: #include <iostream>
#include <vector>
int usage(int a, int digit = 0) {
	if (digit == 4) return 0;
	return (1 << (a % 10)) + usage(a / 10, digit + 1);
}
int hit(int a, int b) {
	int res = 0;
	for (auto i = 0; i < 4; ++i) {
		res += (a % 10 == b % 10) ? 1 : 0;
		a /= 10; b /= 10;
	}
	return res;
}
int brow(int a, int b) {
	int ua = usage(a); int ub = usage(b);
	int res = -hit(a, b);
	for (auto i = 0; i < 10; ++i) {
		res += (ua & ub & 1);
		ua >>= 1; ub >>= 1;
	}
	return res;
}
int main() {
	int a, b;
	std::cin >> a >> b;
	while (a != 0 && b != 0) {
		std::cout << hit(a, b) << ' ' << brow(a, b) << std::endl;
		std::cin >> a >> b;
	}
}

C++: // 2011/01/08 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 h = 0;
		int b = 0;
		for(int i=0; i<4; i++)
			for(int j=0; j<4; j++)
				if(r[i]==a[j])
					if(i==j)
						h++;
					else
						b++;

		cout << h << ' ' << b << endl;
	}

	return 0;
}

C++: #define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <P,P> PP;
typedef pair <int,PP> PPP;

static const double eps = 1e-8;

int main(){
	char a[32],b[32];
	while(~scanf("%s %s",a,b)){
		if(a[0]==b[0] && b[0] == '0') break;
		int hit=0;
		int brow=0;

		for(int i=0;i<4;i++){
			if(a[i]==b[i]){
				hit++;
				continue;
			}
			for(int j=0;j<4;j++){
				if(i==j) continue;
				if(b[i] == a[j]){
					brow++;
					break;
				}
			}

		}

		printf("%d %d\n",hit,brow);
	}
}