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 <bits/stdc++.h>
using namespace std;
int main(void) {
    int r,a,r1,r2,r3,r4,a1,a2,a3,a4,hit=0,blow=0;
    while (cin>>r>>a) {
        if (r==0&&a==0) {
            break;
        } else {
            r1=r/1000;
            r2=(r-r1*1000)/100;
            r3=(r-r1*1000-r2*100)/10;
            r4=r-r1*1000-r2*100-r3*10;
            a1=a/1000;
            a2=(a-a1*1000)/100;
            a3=(a-a1*1000-a2*100)/10;
            a4=a-a1*1000-a2*100-a3*10;
            if (r1==a1) {
                hit++;
            } else if (r1==a2||r1==a3||r1==a4) {
                blow++;
            }
            if (r2==a2) {
                hit++;
            } else if (r2==a1||r2==a3||r2==a4) {
                blow++;
            }
            if (r3==a3) {
                hit++;
            } else if (r3==a1||r3==a2||r3==a4) {
                blow++;
            }
            if (r4==a4) {
                hit++;
            } else if (r4==a1||r4==a2||r4==a3) {
                blow++;
            }
        }
        cout<<hit<<" "<<blow<<endl;
        hit=0;
        blow=0;
    }
}

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

using namespace std;
main(){
  string in[2];
  while(1){
    cin >> in[0] >> in[1];
    if(in[0]=="0" && in[1]=="0") break;

    int hit=0, bro=0;

    for(int i=0;i<4;i++){
      if(in[0][i]==in[1][i]) hit++;
      for(int j=0;j<4;j++){
	if(in[0][i]==in[1][j]) bro++;
      }
    }
    bro-=hit;

    cout << hit << ' '<< bro << endl;
      }
  return 0;
}

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

int main(void){
  string a, b;
  while(cin >> a >> b && a != "0" && b != "0"){
    int 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(i != j && a[i] == b[j]) blow++;
      }
    }
    cout << hit << " " << blow << endl;
  }
  return 0;
}

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

using namespace std;

void solve()
{
	string a, b;
	while(cin >> a >> b)
	{
		if((a == "0") && (b == "0"))
		{
			break;
		}
		int count1 = 0;
		for(int i = 0; i < 4; ++i)
		{
			if(a[i] == b[i])
			{
				count1++;
			}
		}
		int count2 = 0;
		for(int i = 0; i < 4; ++i)
		{
			for(int j = 0; j < 4; ++j)
			{
				if(a[i] == b[j])
				{
					count2++;
				}
			}
		}
		cout << count1 << " " << count2 - count1 << endl;
		
	}
}

int main()
{
	solve();
	return(0);
}

C++: #include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <vector>

using namespace std;





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

using namespace std;

int main()
{
  string s1, s2;

  while(1){
    cin >> s1 >> s2;
    if(s1 == "0" && s2 == "0"){
      break;
    }
    int h=0, b=0;

    for(int i = 0; i < 4; i++){
      for(int j = 0; j < 4; j++){
	if(s1[i] == s2[j]){
	  if(i == j){
	    h++;
	  } else {
	    b++;
	  }
	}
      }
    }

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

  return 0;
}

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

int main() {
	// your code goes here
	string m,n;
	while(cin >> m >> n && m!="0"){
		int h=0,b=0;
		int nums[10][2]={};
		for(int i=0;i<4;i++)
			if(m[i]==n[i])
				h++;
			else{
				nums[m[i]-'0'][0]++;
				nums[n[i]-'0'][1]++;
			}
		for(int i=0;i<9;i++){
			if(min(nums[i][0],nums[i][1])>0)
			b+=min(nums[i][0],nums[i][1]);
		}
		cout << h << " " << b << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cstring>
using namespace std;
int main()
{
	int i, j, h, b;
	while (1)
	{
		char r[5] = "", a[5] = "";
		cin >> r >> a;
		if (r[0] == '0' && r[1] == '\0' && a[0] == '0' && a[1] == '\0') break;
		h = b = 0;
		for (i = 0; i < 4; i++)
		{
			for (j = 0; j < 4; j++)
			{
				if (r[i] == a[j])
				{
					if (i == j)
						h++;
					else
						b++;
				}
			}
		}
		cout << h << " " << b << endl;
	}
}

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

int main( void )
{
    string a, b;
    while ( cin >> a >> b && a != "0" && b != "0" ) {
        int n = a.size();
        int H = 0, B = 0;
        bool used1[n], used2[n];
        fill( used1, used1+sizeof(used1), false );
        fill( used2, used2+sizeof(used2), false );

        for ( int i = 0; i < n; i++ ) {
            if ( a[i] == b[i] ) {
                H++;
                used1[i] = used2[i] = true;
            }
        }

        for ( int i = 0; i < n; i++ ) {
            if ( used1[i] ) continue;
            for ( int j = 0; j < n; j++ ) {
                if ( used2[j] ) continue;
                if ( a[i] == b[j] ) {
                    B++;
                    used1[i] = used2[j] = true;
                }
            }
        }

        cout << H << " " << B << endl;
    }
    return 0;
}

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


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

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

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

 int hit,blow;

 cin >> qwe >> ans;
 
 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;

 return 0;
}

C++: // 2015/05/30 Tazoe

#include <iostream>
#include <cstring>
using namespace std;

int main()
{
	while(true){
		char r[10], a[10];
		cin >> r >> a;

		if(strcmp(r, "0")==0 && strcmp(a, "0")==0)
			break;

		int h = 0, b = 0;

		for(int i=0; i<4; i++){
			for(int j=0; j<4; j++){
				if(r[i]==a[j]){
					if(i==j){	// ヒット
						h++;
					}
					else{		// ブロー
						b++;
					}
				}
			}
		}

		cout << h << ' ' << b << '\n';
	}

	return 0;
}

C++: #include <stdio.h>
int main(){
  char ans[5], sei[5];
  int i,j,hit=0,brow=0;

  while(1){
    hit=0;
    brow=0;
    scanf("%s %s",ans,sei);
    if(ans[0]=='0'&&sei[0]=='0')break;
    for(i=0;i<4;i++){
      if(ans[i]==sei[i])hit++;
    }
    for(i=0;i<4;i++){
      for(j=0;j<4;j++){
	if(ans[i]==sei[j]&&i!=j)brow++;
      }
    }
    printf("%d %d\n",hit,brow);
  }
  return 0;
}