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>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  string s,s2;
  while(cin>>s>>s2,s!="0"){
    int blow[10]={};
    int hitc=0,blowc=0;
    for(int i=0;i<4;i++){
      if(s[i]==s2[i])hitc++;
      else {blow[s[i]-'0']++;blow[s2[i]-'0']++;}
    }
    for(int i=0;i<=10;i++)
      if(blow[i]==2)blowc++;
    cout<<hitc<<" "<<blowc<<endl;
  }
  return 0;
}

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

int main(){
  char r[10],a[5];
  while(1){
  int hit=0,blow=0;
  cin>>r>>a;
  if(r[0]=='0'&&a[0]=='0'){
     break;
   }
  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<<"\n";
}
  return 0;
}

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

using namespace std;
string r, a;

const int INF = 1 << 29;

int main(void)
{
	while(cin >> r >> a && r != "0" && a != "0")
	{
		int blow = 0, hit = 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;
	}
	return 0;
}

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

int main(){

  string a, r;
  int h_cnt = 0, b_cnt = 0;

  while(1){
    cin >> a >> r;
    if(a == "0" && r == "0") return 0;

    for(int i = 0; i < 4; i++){
      for(int j = 0; j < 4; j++){
          if(a[i] == r[j] && i == j){
            h_cnt++;
          }else if(a[i] == r[j]){
            b_cnt++;
          }
      }
    }

    cout << h_cnt << " " << b_cnt << endl;
    h_cnt = 0;
    b_cnt = 0;
  }
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#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 <numeric>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

const double EPS = 1e-8;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
	int r, a;
	while (scanf("%d%d", &r, &a), r|a)
	{
		set<int> s;
		int d[] = { 1, 10, 100, 1000 };
		for (int i = 0; i < 4; ++i)
			s.insert((r / d[i]) % 10);

		int hit = 0, blow = 0;
		for (int i = 0; i < 4; ++i, r /= 10, a /= 10)
			if (r % 10 == a % 10)
				++hit;
			else if (s.count(a % 10))
				++blow;
		printf("%d %d\n", hit, blow);
	}

	return 0;
}

C++: #include <iostream>
using namespace std;
int main(void){
	int a,b;
	while(cin>>a>>b,a||b){
		int hit=0,blow=0;
		for(int i=0,c=1;i<4;++i){
			for(int j=0,d=1;j<4;++j){
				if(i==j) hit+=(a/c%10==b/d%10)?1:0;
				else blow+=(a/c%10==b/d%10)?1:0;
				d*=10;
			}
			c*=10;
		}
		cout<<hit<<" "<<blow<<endl;
	}
}

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

int main(){
	string r, a;
	while( cin >> r >> a , r != "0" || a != "0" ){
		int hit = 0, blow = 0;
		for(int i=0 ; i<4 ; ++i){
			if( a[i] == r[i] ) 
				++hit;
			for(int j=0 ; j<4 ; ++j ){
				if( a[i] == r[j] && i != j )
					++blow;
			}
		}
		cout << hit << " " << blow << endl;
	}
}

C++: #include <iostream>

using namespace std;

int main()
{
	int r;	// 正解
	int a;	// 回答
	int array_r[4];
	int array_a[4];
	int hit;
	int blow;

	while(1)
	{
		cin >> r;
		cin >> a;
		hit = 0;
		blow = 0;

		if(r == 0 && a == 0)
		{
			break;
		}
		
		for(int i = 0; i < 4; ++i)
		{
			array_r[i] = r % 10;
			array_a[i] = a % 10;
			r /= 10;
			a /= 10;
		}

		for(int index_r = 0; index_r < 4; ++index_r)
		{
			for(int index_a = 0; index_a < 4; ++index_a)
			{
				if(array_r[index_r] == array_a[index_a])
				{
					if(index_r == index_a)
					{
						hit++;
					}
					else
					{
						blow++;
					}
				}
			}
		}
		
		cout << hit << " " << blow << endl;
	}
	
	return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	//char a[10],b[10];
	string a,b;
	while(true){
	cin>>a>>b;
	if(/*strcmp(a,"0")==0&&strcmp(b,"0")==0*/a==0&&b==0)break;
	int x=0,y=0;
	for(int i=0;i<4;i++){
		for(int j=0;j<4;j++){
			if(i<j)continue;
			if(a[i]==b[j]){
			if(i==j)x++;
			else y++;
			}			

		}
	}
	cout<<x<<" "<<y<<endl;
	}
	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<sstream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<climits>
#include<map>
#include<set>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<30
#define F first
#define S second
using namespace std;
typedef pair<int,bool> P;

int main(){
  string a,b;
  while(true){
    cin >> a >> b;
    if(a == "0" && b == "0")break;
    map<char,P> r;
    for(int i=0;i<4;i++){
      r.insert(map<char,P>::value_type(b[i],P(i,true)));
    }
    int hit,blow;
    hit = blow = 0;
    for(int i=0;i<4;i++){
      if(r[a[i]].S && i == r[a[i]].F){
	hit++;
      }
      else if(r[a[i]].S){
	blow++;
      }
    }
    cout << hit <<" " << blow << endl;
  }
return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;

int main()
{
  string r, a;
  while(cin >> r >> a, r != "0") {
    vector< int > Counter(10, 0);
    for(int i = 0; i < r.size(); i++) {
      Counter[r[i] - '0']++;
    }
    for(int i = 0; i < a.size(); i++) {
      Counter[a[i] - '0'] = max(0, Counter[a[i] - '0'] - 1);
    }
    int hit = 0;
    for(int i = 0; i < r.size(); i++) {
      hit += r[i] == a[i];
    }
    cout << hit << " " << 4 - accumulate(Counter.begin(), Counter.end(), 0) - hit << endl;
  }
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define ALL(c)   (c).begin(),(c).end()

main(){
  string a,b;
  while(cin>>a>>b && a != "0"){
    int hit=0,blow=0;
    rep(i,b.size()){
      if (a[i] == b[i])hit++;
    }
    rep(i,b.size()){
      blow+=count(ALL(a),b[i]);
    }
    cout << hit <<" " << blow-hit << endl;
  }
  return false;
}