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

int main(){
 
 string qwe,ans;

 int hit,blow,count;

     count = 0;
 
 while(1){
    cin >> qwe >> ans;
    if(qwe[0]=='0'&&ans[0]=='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>
using namespace std;

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

 int hit,blow,count;

 cin >> qwe >> ans;
 
 while(hit != 4){
    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++;
 }

  while(hit != 4 || count != 0){
    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 <cstdio>
#include <iostream>
#include <string>
using namespace std;

int main(){
  int i,j,n,m,a[4][2],h,b;
  while(1){
    cin >> n >> m;
    if(n == 0 && m == 0) break;
    j = 1000;
    for(i=0;i<4;i++){
      a[i][0] = n / j;
      n -= a[i][0] * j;
      a[i][1] = m / j;
      m -= a[i][1] * j;
      j /= 10;
    }
    h = b = 0;
    for(i=0;i<4;i++){
      if(a[i][0] == a[i][1]) h++;
      for(j=0;j<4;j++){
	if(i == j) continue;
	if(a[i][0] == a[j][1]) b++;
      }
    }

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

  }
  return 0;
}

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

int main(){
  string r, a;
  while(1){
    cin >> r >> a;
    if(r[0] - '0' == 0 && a[0] - '0' == 0) break;
    int hit = 0, blow = 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;
  }
}

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

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

    int hit = 0;
    for (int i = 0; i < 4; ++i) {
      if (r[i] == a[i])
	++hit;
    }

    int blow = 0;
    for (int i = 0; i < 4; ++i) {
      for (int j = 0; j < 4; ++j) {
	if (i == j)
	  continue;
	if (r[i] == a[j])
	  ++blow;
      }
    }

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

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

int main()
{
  string r, a;
  int hit, brow;
  while(1)
  {
    hit = brow = 0;

    cin >> r >> a;
    if(r.length() == 1)
      break;

    for(int i = 0; i < 4; i++)
    {
      if(r[i] == a[i])
      {
        hit++;
        r[i] = a[i] = 'a';
      }
    }

    for(int i = 0; i < 4; i++)
    {
      for(int j = 0; j < 4; j++)
      {
        if(r[i] != 'a' && a[j] != 'a' && r[i] == a[j])
        {
          brow++;
          r[i] = a[j] = 'a';
        }
      }
    }

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

C++: #include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

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

C++: #include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

int main() {
  string A, B;
  while(cin >>A >>B && A != "0"){
    int hit = 0, blow = 0;
    REP(i, A.length()){
      REP(j, B.length()){
        if(A[i] == B[j] && i == j) ++hit;
        if(A[i] == B[j] && i != j) ++blow;
      }
    }
    cout <<hit <<" " <<blow <<endl;
  }
  return 0;
}

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

using namespace std;

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

struct edge {
    int to, cost;
};

struct state {
    int v, d, rest;
    bool operator<(const state& s)const{
        return d>s.d;
    }
};

int main(){
    string a, b;
    while (cin >> a >> b, a != "0"){
        int aaa = 0;
        int bbb = 0;
        rep(i,4){
            char guess = b[i];
            if (a[i] == b[i])aaa++;
            if (a.find(guess) != string::npos)bbb++;
        }
        cout << aaa << " "<<bbb - aaa << endl;
    }
}

C++: #include<stdio.h>
int main()
{
        int a[5],b[5],hit=0,brow=0;
        int i,j,k;
        while(scanf("%d %d %d %d",&a[0],&a[1],&a[2],&a[3])!=EOF)
        {
                scanf("%d %d %d %d",&b[0],&b[1],&b[2],&b[3]);
                if(a[0]==0&&a[1]==0)break;
                for(i=0;i<4;i++)
                {
                        if(a[i]==b[i])
                        {
                                hit+=1;
                                a[i]=1000;
                                b[i]=1500;
                        }
                }
                for(i=0;i<4;i++)
                {
                        for(j=0;j<4;j++)
                        {
                                if(a[i]==b[j])
                                {
                                        brow+=1;
                                        a[i]=1000;
                                        b[j]=1500;
                                }
                        }
                }
                printf("%d %d\n",hit,brow);
                for(i=0;i<5;i++)
                {
                        a[i]=0;b[i]=0;
                }
                hit=0;brow=0;
        }
        return 0;
}