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<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;
	}
}

C++: #include<iostream>
int main(){int h,b,i,j;std::string r,a;while(std::cin>>r>>a,r!="0"&&a!="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<iostream>
using namespace std;

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

 int hit,blow,count;

     count = 0;
 
 while(1){
    cin >> qwe >> ans;
    if(qwe[0]='0'&&ans[0]=='0'&&qwe[1]=='\0'&&ans[1]=='\0') break;
    hit = 0 ;
    blow = 0;


   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;
   count++;
  }

  hit = 0 ;
  blow = 0;

/*  while(hit != 4){
    if(count == 0){
      break;
    } 
    cin >> qwe >> ans;
    hit = 0 ;
    blow = 0;

   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;
   
   count--;
 }*/

 return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

int main (int argc, char *argv[]) {
    string str1, str2;
    while (cin>>str1>>str2, str1.length() != 1) {
        int hit = 0;
        int blow = 0;
        for (int i = 0; i < 4; ++i) {
            if (str1[i] == str2[i]) hit++;
            for (int j = 0; j < 4; ++j) {
                if (i == j) continue;
                if (str1[i] == str2[j]) blow++;
            }
        }
        cout<<hit<<" "<<blow<<endl;
    }
    return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>

using namespace std;

int main(int argc, char *argv[]) {
  string s, t;
  int hit, blow;

  while (true) {
    cin >> s >> t;
    if (s == "0")
      break;
    hit = blow = 0;
    for (int i = 0; i < 4; i++)
      for (int j = 0; j < 4; j++)
        if (i == j && s[i] == t[j])
          hit++;
        else if (s[i] == t[j])
          blow++;
    cout << hit << ' ' << blow << endl;
  }
  return 0;
}

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

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

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

int main()
{
  string r, a;
  int c1, c2;

  while (cin >> r >> a && r != "0"){
    c1 = c2 = 0;
    for (int i = 0; i < 4; i++){
      if (r[i] == a[i]){
        c1++;
      }
    }
    for (int i = 0; i < 4; i++){
      for (int j = 0; j < 4; j++){
        if (r[i] == a[j] && i != j){
          c2++;
        }
      }
    }

    cout << c1 << " " << c2 << endl;
  }
}

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

int main(){
	int x,y,n[4],m[4];
	int h,b,i,j;
	
	while(1){
		cin >> x >> y;
		if(x+y==0) break;
		
		h=0; b=0;
		
		for(i=3; i>0; i--){
			n[i]=x/pow(10,i);
			x-=n[i]*pow(10,i);
			m[i]=y/pow(10,i);
			y-=m[i]*pow(10,i);
		}
		n[0]=x; m[0]=y;
		
		for(i=0;i<4;i++){
			if(n[i]==m[i]) h++;
			else for(j=0;j<4;j++){
				if(n[i]==m[j]) b++;
			}
		}
		
		cout << h << " " << b << endl;
	}
	
	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<string>
using namespace std;
string S1,S2;
int A1,A2;
int main()
{
	while(true){
	cin >> S1 >> S2;
	A1=0;A2=0;
	if(S1.length()==1)break;
	for(int i=0;i<4;i++){
		if(S1[i]==S2[i])A1++;
	}
	for(int i=0;i<4;i++){
		for(int j=0;j<4;j++){
			if(i==j)continue;
			if(S1[i]==S2[j])goto a;
		}
		continue;
		a:;
		A2++;
	}
	printf("%d %d\n",A1,A2);
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int n,n2,in[4],in2[4],hit,blow,d;
  while(cin>>n>>n2){
    if(n==0&&n2==0) break;
    d = 1000;
    //cout << n << " " << n2 << endl;
     for(int i=0;i<4;i++){
      in[i] = n / d;
      in2[i] = n2 / d;
      n -= in[i] * d;
      n2 -= in2[i] * d;
      d /= 10;
      //cout << in[i] << endl << in2[i] << endl;  
    } 
    hit = 0;
    blow = 0;    
    for(int i=0;i<4;i++){
      for(int j=0;j<4;j++){
      if(in[i]==in2[j]&&i==j) hit++;
      else if(in[i]==in2[j]) blow++;
      }
    }
    cout << hit << ' ' << blow << endl;
  }
  return 0;
}

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

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

int main(){
	string s,t;
	while(1){
		int cnt[2][10] = {},hit = 0,blow = 0;
		cin >> s >> t;
		if(s == "0") break;
		for(int i = 0;i < 4;i++){
			if(s[i] == t[i]) hit++;
			else{
				cnt[0][s[i] - '0']++;
				cnt[1][t[i] - '0']++;
			}
		}
		for(int i = 0;i < 10;i++){
			blow += min(cnt[0][i],cnt[1][i]);
		}
		cout << hit << " " << blow << endl;
	}
	return 0;
}