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 <stdio.h>


int main(){
    int set,call;
    int setAry[4], callAry[4];
    int setCnt[10], callCnt[10];
    int hit, used, blow;

    while (scanf("%d %d",&set, &call), set!=0){
        for (int i=0; i<10; i++){
            setCnt[i] = callCnt[i] = 0;
        }
        for (int i=0; i<4; i++){
            setAry[i] = set%10;
            set /= 10;
            setCnt[setAry[i]]++;
            callAry[i] = call%10;
            call /= 10;
            callCnt[callAry[i]]++;
        }
        used=0;
        for (int i=0; i<10; i++){
            if (setCnt[i] && callCnt[i] ) used++;
        }
        hit=0;
        for (int i=0; i<4; i++){
            if (setAry[i] == callAry[i]) hit++;
        }
        blow = used-hit;
        printf("%d %d\n", hit, blow);
    }    
    return 0;
}

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

int main(){
	string taro, hanako;
	while(cin >> taro >> hanako, taro != "0" && hanako != "0"){
		int hit = 0, blow = 0;
		for(int i=0; i < 4; i++){
			if(taro[i] == hanako[i]) hit++;
			else {
				for(int j=0; j < 4; j++){
					if(i == j) continue;
					if(taro[i] == hanako[j]) blow++;
				}
			}
		}
		cout << hit << ' ' << blow << endl;

	}
}

C++: #include<iostream>
#include<string>
using namespace std;
int main() {
	string a, b,keta[5];
	int ans[4],kt[5];
	while (1) {
		for (int i = 0; i <= 5; i++) {
			kt[i] = 1;
		}
		cin >> a >> b;
		if (a == "0"&&b == "0") {
			goto a;
		}
		for(int i=0;i<=3;i++){
			keta[i] = a[i];
		}
		ans[1] = 0;
		ans[2] = 0;
		for (int i = 0; i <= 3; i++) {
			if (a[i] == b[i]) {
				ans[1] = ans[1] + 1;
				kt[i] = 0;
			}
		}
		for (int i = 0; i <= 3; i++) {
			for (int z = 0; z <= 3; z++) {
				if (a[i] == b[z]) {
					if (kt[z]) {
						ans[2] = ans[2] + 1;
					}
				}
			}
		}
		cout << ans[1] << " " << ans[2] << endl;
	}
a:;
}

C++: #include<iostream>
using namespace std;
int main() {
	char a[5];
	char b[5];
	int x;
	int hit[12001];
	int blow[12001];
	for (int i = 0;; i++){
		cin >> a >> b;
		hit[i] = 0;
		blow[i] = 0;
		if (a[0] == '0' && b[0] == '0'){
			x = i;
			break;
		}
		for (int j = 0; j < 4; j++){
			for (int k = 0; k < 4; k++){
				if (a[j] == b[k]){
					if (j == k){
						hit[i] += 1;
					}
					else blow[i] += 1;
				}
			}
		}
	}
	for (int i = 0; i < x; i++){
		cout << hit[i] << " " << blow[i] << endl;
	}
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
#include <iomanip>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
	string a, b;
	while(cin >> a >> b && a != "0")
	{
		int blow = 0, hit = 0;
		rep(i, 4)
		{
			if(a[i] == b[i])
				hit++;
			else
				blow += (0 < count(ALL(b), a[i]));
		}

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

C++: #include <iostream>
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
using namespace std;
int main(){
	int a, b;
	while(cin >> a >> b, (a || b)) {
		int hit=0, blow=0;
		int ma[4],mb[4];
		rep(i,4) {
			ma[i] = a%10, mb[i] = b%10;
			a/=10, b/=10;
		}
		rep(i,4) {
			if(ma[i]==mb[i]) {
				hit++;
				mb[i] = -1;
			}
		}
		rep(i,4) {
			if(ma[i]!=mb[i]) {
				rep(j,4) {
					if(ma[i] == mb[j]) {
						blow++;
						mb[j] = -1;
					}
				}
			}
		}
		cout << hit << " " << blow << endl;
	}
}

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

int main(){
    while(true){
        string a, b;
        cin >> a;
        cin >> b;
        if(a == "0")
            break;
        
        int hit = 0;
        int blow = 0;
        for(int i=0;i<4;++i){
            if(a[i] == b[i]) hit++;
        }
        for(int i=0;i<4;++i){
            for(int j=0;j<4;++j){
                if(i == j) continue;
                if(a[i] == b[j]) blow++;
            }
        }
        cout << hit << " " << blow;
    }
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>

using namespace std;

int main(){

	string str1,str2;
	while(cin>>str1>>str2&&!(str1=="0"&&str2=="0")){
		int hit=0;
		int blow=0;

		set<char> s1,s2;
		for(int i = 0; i < 4; i++){
			if(str1[i]==str2[i]){
				hit++;
			}
			else{
				s1.insert(str1[i]);
				s2.insert(str2[i]);
			}
		}
		for(set<char>::iterator it = s1.begin(); it!=s1.end(); it++){
			if(s2.find(*it)!=s2.end()){
				blow++;
			}
		}
		cout<<hit<<" "<<blow<<endl;
	}


	return 0;
}

C++: #include <iostream>

using namespace std;

int main() {

  string str;

  int hit,blow;


  while(1) {

    getline(cin,str);

    if(str=="0 0") break;

    hit=blow=0;

    for(int i=0;i<4;i++) {

      for(int j=0;j<4;j++) {

	if(str[i]==str[j+5]) {

	  if(i==j) hit++;

	  else blow++;

	}

      }

    }

    cout << hit << " " << blow << endl;

  }

  return 0;

}

C++: #include <stdio.h>
#include <iostream>

using namespace std;

int main () {
	int number1,number2;
	int a[4],b[4];

	while (1) {
		int B = 0;
		int H = 0;
		cin >> number1 >> number2;
		if (number1 == 0 && number2 == 0) {
			break;
		} else {
			for (int i = 0; i < 4; i++) {
				a[i] = number1 % 10;
				b[i] = number2 % 10;
				number1 = number1 / 10;
				number2 = number2 / 10;
			}
			for (int i = 0; i < 4; i++) {
				if (a[0] == b[i] || a[1] == b[i] || a[2] == b[i] || a[3] == b[i]) {
					B++;
				}
				if (a[i] == b[i]) {
					if (B > 0) {
						B--;
					}
					H++;
				}
			}
			cout << H << " " << B << endl;
		}
	}

	return 0;
}

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

int hit(char* s1,char* s2){
	int n=0;
	for(int i=0;i<4;i++){
		if(s1[i]==s2[i]){
			n++;
		}
	}
	return n;
}

int blow(char* s1,char* s2){
	int n=0;
	for(int i=0;i<4;i++){
	if(s1[i]==s2[0]){
		n++;
		}
	if(s1[i]==s2[1]){
		n++;
		}
	if(s1[i]==s2[2]){
		n++;
		}
	if(s1[i]==s2[3]){
		n++;
		}
	}
	return n;
}

int main(){
	char r[5],a[5];
	for(int i=0;i<100;i++){
		cin>>r;cin>>a;
		if(r[0]==0&&a[0]==0){
		break;
		}
		else{
		cout<<hit(r,a)<<' '<<blow(r,a)-hit(r,a)<<endl;
		}
	}
return 0;
}

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

using namespace std;

int main() {
  string r, a;
  while (true) {
    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;
  }
}