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<cstdio>
using namespace std;
int main( ){
  while(1){
    int a,b,c[4],d[4],x=0,y=0;
    cin>>a>>b;
    if(a==0&&b==0)break;
    c[0]=a/1000;
    c[1]=(a%1000)/100;
    c[2]=(a%100)/10;
    c[3]=(a%10);
    d[0]=b/1000;
    d[1]=(b%1000)/100;
    d[2]=(b%100)/10;
    d[3]=(b%10);
    for(int i=0;i<4;i++){
      for(int j=0;j<4;j++){
        if(c[i]==d[j]){
          if(i==j)x++;
          else y++;
        }
      }
    }
    printf("%d %d\n",x,y);
  }
  return 0;
}

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

using namespace std;

int main() {
  string s1, s2;
  int hit, blow;

  while(1) {
    cin >> s1 >> s2;
    if(s1 == "0" && s2 == "0") break;
    hit = blow = 0;
    for(int i = 0; i < 4; i++) {
      if(s1[i] == s2[i]) hit++;
      for(int j = 0; j < 4; j++) {
	if(s1[i] == s2[j]) blow++;
      }
    }
    blow -= hit;
    cout << hit << ' ' << blow << endl;
  }
  return 0;
}

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

int main(){
	int length = 4
	char[length+1] taroNomber;
	char[length+1] hanakoNomber;
	int hitCount = 0;
	int blowCount = 0;
	while(true){
		cin >> taroNomber;
		cin >> hanakoNomber;
		hitCount = 0;
		blowCount = 0;
		if(strlen(taroNomber)==1){
			break;
		}
		for(int i=0;i<length;i++){
			for(int j=0;j<length;j++){
				if(taroNomber[i]==hanakoNomber[j]){
					if(i==j){
						hitCount++;
						break;
					}else{
						blowCount++;
						break;
					}
				}
			}
		}
		cout << hitCount << ' ' << blowCount << '\n';
	}
	return 0;
}

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

int main()
{
 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++;}
 }

bro=bro-hit;

cout<<hit<<' '<<bro<<'\n';

return 0;
}

C++: #include <iostream>

int main(){
	std::string a, b;
	while(std::cin >> a >> b, a != "0"){
		int hit = 0, brow = 0, as[10] = {0}, bs[10] = {0};
		//hitの判定, browの準備
		for(int i=0;i<4;i++){
			if(a[i] == b[i])hit++;
			as[a[i]-'0']++, bs[b[i]-'0']++;
		}
		//仮のbrowを求める
		for(int i=0;i<10;i++){
			if(as[i] > 0 && bs[i] > 0)
				brow++;
		}
		//仮のbrowにはhitも含まれているので引く
		brow -= hit;
		std::cout << hit << " " << brow << std::endl;
	}
}

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

int main()
{
  int r, a;

  while (cin >> r >> a, r || a){
    int hit = 0, blow = 0;
    int n1[4], n2[4];
    for (int i = 0; i < 4; i++){
      n1[i] = r % 10;
      n2[i] = a % 10;
      r /= 10;
      a /= 10;
    }
    for (int i = 0; i < 4; i++){
      for (int j = 0; j < 4; j++){
        if (n1[i] == n2[j]){
          if (i == j) hit++;
          else  blow++;
        }
      }
    }
    cout << hit << ' ' << blow << endl;
  }
  return (0);
}

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

int main() {
    int i,j,x,y,h,b,c[4],d[4];
    while(cin >> x >> y && x!=0) {
		for (i=1000,h=0;i>=1;i/=10,h++) {c[h]=x/i; x-=c[h]*i; d[h]=y/i; y-=d[h]*i;}
		h=b=0;
		for (i=0;i<4;i++) for (j=0;j<4;j++) {	if (c[i]==d[j]) { b++; if (i==j) h++;}}
		cout << h << ' ' << b-h << endl;
	} 
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <array>
#include <vector>

using namespace std;

int main() {
  while( true ) {
    int n, m;
    cin >> n >> m;
    if ( n == 0 and m == 0 ) break;
    vector<int> ns, ms;
    for ( int i = 0; i < 4; i++ ) {
      ns.push_back( n % 10 );
      n /= 10;
      ms.push_back( m % 10 );
      m /= 10;
    }
    int hit = 0;
    const int NONE = -1;
    for ( int i = 0; i < 4; i++ ) {
      if ( ns[ i ] == ms[ i ] ) {
	hit++;
	ns[ i ] = ms[ i ] = NONE;
      }
    }
    int brow = 0;
    for ( int val : ns ) {
      if ( val != NONE and find( ms.begin(), ms.end(), val ) != ms.end() ) {
	brow++;
      }
    }
    cout << hit << " " << brow << endl;
  }
}

C++: #include<string.h>
#include<stdio.h>
int main()
{
	int h,b,i,j;
	char r[5],a[5];
	while(1){
		scanf("%s %s",r,a);
		if(strcmp(r,"0")==0&&strcmp(a,"0")==0){
			break;
		}
		h=0;
		b=0;
		for(i=0;i<4;i++){
			if(r[i]==a[i]){
				h++;
				r[i]='r';
				a[i]='a';
			}
		}
		for(i=0;i<4;i++){
			for(j=0;j<4;j++){
				if(r[i]==a[j]){
					b++;
					r[i]='r';
					a[j]='a';
				}
			}
		}
		printf("%d %d\n",h,b);
	}
	return 0;
}

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

using namespace std;

int main()
{
  while(true){
    char r1[5];
    char r2[5];
    scanf("%s%s", r1, r2);
    if(strcmp(r1,"0")==0&&strcmp(r2,"0")==0)break;
    
    int hit=0;
    int blow=0;
    for(int i = 0; i < 4; ++i){
      if(r1[i] == r2[i])++hit;
      for(int j = 0; j < 4; ++j){
	if(r1[i] == r2[j])++blow;
      }
    }
    blow -= hit;
    cout << hit << ' ' << blow << endl;
  }
  return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)



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

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define pp pair<int,int>
#define ll long long
#define ld long double
int inf=100000000;
ll INF=5000000000000000000;
ll MOD=1000000007;


int main() {
    while (true){
    string a,b;
    cin >> a >> b;
    if (a=="0") break;
    int h=0,k=0;
    rep(i,4){
        rep(j,4){
            if (a.at(i)==b.at(j) && i==j) h++;
            else if (a.at(i)==b.at(j)) k++;
        }
    }
    cout << h << " " << k << endl;
    }
}

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

typedef vector<int> VI;
typedef pair<int, int> PII;

#define REP(i, n) for(int i=0; i<n; i++)

PII solve(string ans, string call)
{
	int nHit = 0;
	int nBlow = 0;

	//count up hit
	REP(i, ans.size())
	{
		if(ans[i] == call[i])
		{
			nHit++;
		}
	}

	REP(i, ans.size())
	{
		REP(j, call.size())
		{
			if(i != j && ans[i]==call[j])
			{
				nBlow++;
			}
		}
	}

	return PII(nHit, nBlow);
}

int main()
{
	string ans, call;
	while( 1 )
	{
		cin >> ans;
		cin >> call;
		if(ans == "0" && call == "0")
			break;

		PII out = solve(ans, call);
		printf("%d %d\n", out.first, out.second);
	}
}

C++: #include<iostream>
int main(){
	while(1){
		int a,b;
		std::cin>>a>>b;
		if(a==0&&b==0)break;
		std::vector<int> vec(4);
		std::vector<int> vec2(4);
		int n=1000;
		for(int i=0;i<4;i++){
			int x=a/n;
			int y=b/n;
			vec[i]=x;
			vec2[i]=y;
			x*=n;
			y*=n;
			a-=x;
			b-=y;
			n/=10;
		}
			int c=0,d=0;
		for(int i=0;i<4;i++){
			for(int j=0;j<4;j++){
				if(vec[i]==vec2[j]){
					if(i==j)c++;
					else d++;
				}
			}
		}

		std::cout<<c<<" "<<d<<std::endl;
	}
	return 0;
}