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++: // 2014/05/20 Tazoe

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

int main()
{
	while(true){
		char r[5], a[5];
		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<cstdio>
main(){int h,b,i,j;char r[5],a[5];while(scanf("%s%s",r,a),r[1]!='\0'&a[1]!='\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(){
int i,j,h,b;
string s,t;
while(cin>>s>>t){
if(s=="0")break;
h=b=0;
for(i=0;i<4;i++){
if(s[i]==t[i])h++;
for(j=0;j<4;j++)if(i!=j&&s[i]==t[j])b++;
}
cout<<h<<" "<<b<<endl;
}
return 0;
}

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

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

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

		map<char,int> m;
		bool flag[4];
		int hit = 0,b = 0;
		rep(i,4)
		{
			if(s[i] == s2[i]) 
			{
				hit++;
				flag[i] = true;
			}
			else 
			{
				m[s[i]]++;
				flag[i] = false;
			}
		}

		rep(i,4)
		{
			if(!flag[i] && m[s2[i]] > 0)
			{
				b++;
			}
		}

		cout <<  hit << " " << b << endl;

	}
}

C++: #include <iostream>
#include <string>
using namespace std;
 
int main (void) {
  string strH, strB;
  int hNum, bNum;
   
  while(1) { 
    cin >> strH >> strB;
    if(strH == "0" && strB == "0") break;
     
    hNum = bNum = 0;
     
     
    for(int i = 0; i < 4; i++) {
      for(int j = 0; j < 4; j++) {
    if(strH[i] == strB[j]) {
      if(i == j) hNum++;
      else bNum++;
    }
      }
    }
     
    cout << hNum << " " << bNum << endl;
  }
 
  return 0;
}

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

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

C++: #include<stdio.h>
int main()
{
	int a,r,x[4],y[4],i,j,c,d;
	while(scanf("%d%d",&a,&r),a)
	{
		for(i=0;i<4;++i)x[i]=a%10,y[i]=r%10,a/=10,r/=10;
		for(c=d=i=0;i<4;++i)
		{
			if(x[i]==y[i])++c;
			else for(j=1;j<4;++j)if(x[i]==y[(i+j)%4])++d;
		}
		printf("%d %d\n",c,d);
	}
	return 0;
}

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

int main(){
	while(1){
		std::string str;
		std::string Astr;
		int h=0,b=0;
		std::cin>>str>>Astr;
		if(str=="0"&&Astr=="0")break;
		for(int i=0;i<str.size();i++){
			for(int j=0;j<Astr.size();j++){
				if(str[i]==Astr[j]){
					if(i==j)h++;
					else b++;
				}
			}
		}
		std::cout<<h<<" "<<b<<std::endl;
	}
	return 0;
}

C++: #ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

#include <array>

using namespace std;

int main ()
{
	string s1 , s2;
	while( cin >> s1 >> s2 )
	{
		if( s1 == "0"&&s2 == "0" )return 0;
		int a = 0;
		for( size_t i = 0; i < 4; i++ )
		{
			a += s1[i] == s2[i];
		}
		cout << a << " ";
		vector<int>d(10,0);
		for( size_t i = 0; i < 4; i++ )
		{ 
			d[s1[i] - '0']++;
		}
		int b = 0;
		for( size_t i = 0; i < 4; i++ )
		{
			if( d[s2[i] - '0'] > 0 )
			{
				b++;
				d[s2[i] - '0']--;
			}
		}
		cout << b - a << endl;
	}
}

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

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	for (string r, a; scan(r, a), r != "0";) {
		int h = 0, b = 0;
		for (int i = 0; i < 4; i++)
			if (r[i] == a[i])
				h++;
			else
				for (int j = 0; j < 4; j++)
					if (i != j && r[i] == a[j]) {
						b++;
						break;
					}
		outl(h, ' ', b);
	}
}

C++: #include<iostream>
using namespace std;
string s,t;
main()
{
	while(cin>>s>>t,s!="0")
	{
		int a=0,b=0;
		for(int i=0;i<4;i++)
		{
			if(s[i]==t[i])
			{
				a++;s[i]='a';
			}
		}
		for(int i=0;i<4;i++)
		{
			bool f=0;
			for(int j=0;j<4;j++)if(s[i]==t[j]){f=1;break;}
			if(f)b++;
		}
		cout<<a<<" "<<b<<endl;
	}
}