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



int main()
{
while(1){
	char r[10]; char a[10];
	int h=0,v=0,i,j;

	cin >> r;
	cin >> a;
if(r[0]=='0'&&r[1]=='\0')break;
	for(i=0;i<4;i++){
		if(r[i]==a[i])h=h+1;
	for(j=0;j<4;j++){
		if(r[i]==a[j])v=v+1;
		if(r[j]==a[i])v=v-1;
		
		}
	}
cout<<h<<" "<<v<<endl;

}
return 0;

}

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

using namespace std;

int main()
{
  string s1, s2;

  while(1){
    cin >> s1 >> s2;
    if(s1 == "0" && s2 == "0"){
      break;
    }
    int h=0, b=0;

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

    cout << h << " " << b << endl;
  }

  return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
#include <complex>
using namespace std;

const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef pair<int,int> P;
struct edge{int to,cost;};

int main(){
    while(1){
        string r,a;
        cin >> r >> a;
        if(r=="0")break;

        int hit = 0, blow = 0;
        for(int i=0;i<4;i++){
            if(r[i]==a[i]){
                r[i] = '-';
                a[i] = '-';
                hit += 1;
            }
        }
        for(int i=0;i<4;i++){
            if(r[i]=='-')continue;
            for(int j=0;j<4;j++){
                if(r[i]==a[j]){
                    blow += 1;
                    break;
                }
            }
        }
        cout << hit << " " << blow << endl;
    }

    return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

char buf[10];
int main() {
	int a[4], b[4];
	while (gets(buf), strcmp(buf, "0 0")) {
		char*s = buf;
		rep(i, 4) { sscanf(s, "%1d", &a[i]); s += 1; }s += 1;
		rep(i, 4) { sscanf(s, "%1d", &b[i]); s += 1; }
		int hit = 0, blow = 0;
		rep(i, 4)if (a[i] == b[i])hit++;
		rep(i, 4) if (find(a, a + 4, b[i]) != a + 4)blow++;
		cout << hit << ' ' << blow - hit << endl;
	}
	return 0;
}

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

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

C++: #include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int x,y,h,b,r[4],a[4],i,j,cnt1,cnt2;
	while(1){
		cin>>x>>y;
		if(x==0 && y==0) break;
		for(i=3;i>=0;i--){
			r[i]=x%10;
			x=x/10;
			a[i]=y%10;
			y=y/10;
		}
		cnt1=0;
		cnt2=0;
		for(i=0;i<4;i++){
			if(r[i]==a[i]) cnt1=cnt1+1;
			for(j=0;j<4;j++){
				if(r[i]==a[j]) cnt2=cnt2+1;
			}
		}
		h=cnt1;
		b=cnt2-cnt1;
		cout<<h<<' '<<b<<endl;
	}
	return 0;
}

C++: #include <stdio.h>
#include <string.h>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
int a, b, hit, blow; const int power[4] = { 1, 10, 100, 1000 };
int main() {
	while (true) {
		scanf("%d %d", &a, &b);
		if (a == 0 && b == 0) break;
		hit = 0; blow = 0;
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 4; j++) {
				if ((a / power[i]) % 10 == (b / power[j]) % 10) {
					if (i == j) {
						hit++;
					}
					else {
						blow++;
					}
				}
			}
		}
		printf("%d %d\n", hit, blow);
	}
	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	while(1){
        int a[10] = {0},b[10] = {0};
        int c,d;
        cin >> c >> d;
        if(c == 0 && d == 0) break;
        a[0] = c / 1000;
        a[1] = c / 100 - a[0]*10;
        a[2] = c / 10 - a[0]*100-a[1]*10;
        a[3] = c -a[0]*1000 - a[1]*100 - a[2]*10;
        b[0] = d / 1000;
        b[1] = d / 100 - b[0]*10;
        b[2] = d / 10 - b[0]*100-b[1]*10;
        b[3] = d -b[0]*1000 - b[1]*100 - b[2]*10;
        int hit = 0;
        int 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;
	}
	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;
}

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

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int main(){
	string str1,str2;
	while(cin>>str1>>str2){
		if(str1==str2&&str1=="0")break;
		int hit = 0;
		map<char,int> data;
		for(int i=0;i < 4;i++){
			if(str1[i]==str2[i]){
				hit++;
			}else{
				data[str1[i]]++;
				data[str2[i]]++;
			}
		}
		int blow = 0;
		map<char,int>:: iterator it =data.begin();
		while(it !=data.end()){
			if(it->second>=2){
				blow++;
			}
			it++;
		}
		cout <<hit<<" "<<blow<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <sstream>
//#include <fstream>

using namespace std;

int stoi (string str )
{
	stringstream ss (str );
	int n;
	ss >> n;
	
	return n;
}

int main()
{
//	cut here before submit 
//	freopen("testcase.hit6blow", "r", stdin);
	string A = "", B = "";
	
	while (cin >> A >> B ) {
		if ( stoi(A) == 0 && stoi(B) == 0 ){
			break;
		} // end if

		int hit = 0;
		int blow = 0;
		int i,j;

		for (i = 0; i < 4; ++i){
			if (A[i] == B[i]){
				++hit;
				A[i] = B[i] = 'e';
			} // end if
		} // end for
		
		for (i = 0; i < 4; ++i){
			for (j = 0; j < 4; ++j){
				if (A[i] != 'e' && B[j] != 'e' && A[i] == B[j]){
					++blow;
					A[i] = B[j] = 'e';
				} // end if
			} // end for
		} // end for
		cout << hit << ' ' << blow << endl;
	} // end while

	return 0;
}

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

string r, a;

int main () {
	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[j] == a[i]) {
					if (i == j) hit++;
					else blow++;
					break;
				}
			}
		}
		cout << hit << ' ' << blow << endl;
	}
	return 0;
}