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 <vector>
#include <algorithm>
#include <cstdio>
#include <map>

using namespace std;

int main() {
	string ans, res;

	while (cin >> ans >> res, ans != "0" || res != "0") {
		int hit = 0;
		for (int i = 0; i < 4; ++i)
			if (ans[i] == res[i])
				++hit;

		cout << hit << " ";

		int blow = 0;
		map<int, bool> m;
		for (int i = 0; i < 4; ++i)
			m[ans[i]] = true;

		for (int i = 0; i < 4; ++i)
			if (m[res[i]])
				++blow;

		cout << (blow - hit) << endl;
	}
/*
	vector<int> nums;
	for (int i = 0; i < 10000; ++i) {
		char str[5];
		sscanf(str, "%04d", i);

		bool is_ng = true;
		for (int j = 0; j < 4; ++j)
			for (int k = 0; k < 4; ++k)
				if (str[j] == str[k])
					is_ng = false;

		if (is_ng) continue;

		nums.push_back(i);
	}

	int ans, res;

	while (cin >> ans >> res, ans || res) {
		int 
		cout << (int)( lower_bound( nums.begin(), nums.end(), res ) - lower_bound() ) << endl;
	}
*/
}

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


int main(){
  int i,j,hit,blow;
  string qs,as;
  while(1){
    hit = 0;
    blow = 0;
    cin >> qs >> as;
    if(qs[0] == '0' && as[0] == '0')
      break;
    for(i=0;i<4;i++){
      if(qs[i] == as[i]){
	hit++;
      }
      for(j=0;j<4;j++){
	if(qs[i] == as[j])
	  blow++;
      }
    }
    cout << hit << ' ' << blow - hit << endl;
  }
}

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

int main(){
    int x, y;
    while(1){
        cin >> x >> y;
        if(x+y == 0)    break;
        
        int r[4], a[4];
        for(int i = 0; i < 4; i++){
            r[3-i] = x%10;  x /= 10;
            a[3-i] = y%10;  y /= 10;
        }
        
        int hit = 0, blow = 0;
        for(int i = 0; i < 4; i++){
            if(r[i] == a[i]){
                hit++;
                r[i] = a[i] = -1;
            }
        }
        
        for(int i = 0; i < 4; i++){
            if(r[i] == -1)  continue;
            for(int j = 0; j < 4; j++){
                if(i == j)  continue;
                if(r[i] == a[j]){
                    blow++;
                    break;
                }
            }
        }
        
        cout << hit << " " << blow << endl;
    }
    return 0;
}

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

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

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

 int hit,blow,count;

     count = 0;
 
 while(hit != 4){
    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++;
  }

  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<string>

using namespace std;

int hit(string r,string a){
  int cnt=0;
  for(int i=0;i<r.size();i++)
    if(r[i]==a[i])cnt++;

  return cnt;
}

int blow(string r,string a){
  int cnt=0;
  for(int i=0;i<a.size();i++)
    for(int j=0;j<r.size();j++)
      if(i!=j && a[i]==r[j])cnt++;

  return cnt;
}

int main(void){
  string r,a;

  while(cin >> r >> a){
    if(r=="0" && a=="0")break;
    
    cout << hit(r,a) <<" "<< blow(r,a) << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
  int hit,brow;
  string s1,s2;
  while(1){
    int math[4]={0};
    cin >> s1 >> s2;
    if(s1=="0" && s2=="0"){
      break;
    }
    hit=0;
    brow=0;
    for(int i=0;i<4;i++){
      if(s1[i]==s2[i]){
	math[i]++;
	hit++;
      }
    }
    for(int i=0;i<4;i++){
      if(math[i]==0){
	for(int j=0;j<4;j++){
	  //if(math[j]==0){
	    if(s1[i]==s2[j]){
	      math[i]++;
	      brow++;
	    }
	    //}
	}
      }
    }
    cout << hit << " " << brow << endl;
  }
}

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

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

int main(){
	string taroNomber;
	string hanakoNomber;
	int hitCount = 0;
	int blowCount = 0;
	while(true){
		cin >> taroNomber >> hanakoNomber;
		if(taroNomber=="0" && hanakoNomber=="0"){
			break;
		}
		hitCount = 0;
		blowCount = 0;
		int taroSize = taroNomber.size();
		int hanakoSize = hanakoNomber.size();
		for(int i=0;i<taroSize;i++){
			for(int j=0;j<hanakoSize;j++){
				if(taroNomber[i] == hanakoNomber[j]){
					if(i == j){
						hitCount++;
					}else{
						blowCount++;
					}
				}
			}
		}
		cout << hitCount << ' ' << blowCount << '\n';
	}

	return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	for (string r, a; cin >> r >> a&&r != "0";) {
		int hit = 0, blow = 0;
		rep(i, 0, 4) {
			if (r[i] == a[i])hit++;
			else {
				if (r.find(a[i]) != string::npos)blow++;
			}
		}
		cout << hit << " " << blow << endl;
	}
	return 0;
}

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

main(){
    string r, a;
    while(1){
	cin >> r >> a;
	if ( a == "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] ) continue;
		if ( i == j ) hit++;
		else blow++;
	    }
	}
	cout << hit << " " << blow << endl;
    }
}