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


int main() {

    string a, b;
    int hit, blow;
    for (;;) {
        set<char> s;
        cin >> a >> b;
        if (a.size() == 1 && b.size() == 1) break;
        hit = blow = 0;
        for (int i = 0; i < 4; i++) s.insert(b[i]);
        for (int i = 0; i < 4; i++) {
            if (a[i] == b[i]) hit++;
            else if (s.find(a[i]) != s.end()) blow++;
        }
        cout << hit << " " << blow << endl;

    }

    return 0;
}

C++: #include<iostream>

int main(){
int a[4],b[4],i,j,H,B;
	while(std::cin>>a[0]){
		for(i=0;i<4;i++){
			std::cin>>a[i];
		}
		for(j=0;j<4;j++){
			std::cin>>b[j];
		}
		H=0;
		B=0;
		for(i=0;i<4;i++){
			for(j=0;j<4;j++){
				if(a[i]==b[j]){
					if(i==j){
						H++;
					}
					else(){
						B++;
					}
				}
			}
		}
		std::cout<< H << " " << B <<std::endl;
	}
return 0;
}

C++: //include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstring;
typedef pair<int, int> pint;
typedef pair<pint, int> ppint;
typedef pair<int, pint> pintp;
typedef unsigned int uint;
typedef long long llint;
typedef unsigned long long int ullint;

//container util
//------------------------------------------
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define EXIST(v,i) (find((v).begin(), (v).end(), i) != (v).end())
#define ERASE(v,i) (v).erase(remove((v).begin(), (v).end(),i) ,(v).end())
#define me (*this)
#define INDEX(v,i) (find((v).begin(), (v).end(), i) - (v).begin())

//repetition
//------------------------------------------
#define rep(i,s) for(int i=0; i<(int)(s); i++)

//constant
//--------------------------------------------
const int INF = 100000000;
const double PI = 3.14159265358979323;
const double EPS = 1e-10;

//clear memory
#define CLEAR(a) memset((a), 0 ,sizeof(a))

//debug
#define debug(x)  cerr << #x << " = " << (x) << endl

//function
int gcd(int x, int y) {
	if(y > x)
		swap(x, y);
	while(y != 0) {
		x %= y;
		swap(x, y);
	}
	return x;
}

int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

//structure
struct POS {
	int x, y;
};

POS vec[4] = {
	{1, 0}, // right
	{0, -1}, // up
	{-1, 0}, // left
	{0, 1} // down
};

int main() {
	while(1) {
		string p, q;
		cin >> p >> q;
		if(p == "0" && q == "0")
			break;
		int hit = 0, blow = 0;
		rep(i, 4) {
			if(q[i] == p[i]) {
				hit++;
			} else if(EXIST(p, q[i])) {
				blow++;
			}
		}
		printf("%d %d\n", hit, blow);
	}
	return 0;
}

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

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

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int main(){
  string a, b;
  while(cin>>a>>b, a != "0"){
    int ans1 = 0;
    int ans2 = 0;

    REP(i,4){
      REP(j,4){
        if(a[i] == b[j]){
          if(i == j) ans1++;
          else ans2++;
        }
      }
    }

    cout << ans1 << " "
         << ans2 << endl;
  }
  return 0;
}

C++: #include <iostream>
using namespace std;
 
void hitAndBlow(int *n, int *m)
{
  int a[4], b[4], c[4] = {};
 
  for (int i=0; i<4; i++) {
    a[i] = *n % 10;
    *n /= 10;
    b[i] = *m % 10;
    *m /= 10;
  }
 
  for (int i=0; i<4; i++) {
    if (a[i] == b[i]) {
      (*n)++;
      c[i] = 1;
    }
  }
 
  for (int i=0; i<4; i++) {
    if (c[i]) continue;
    for (int j=0; j<4; j++) {
      if (c[j]) continue;
      if (a[i] == b[j])
    (*m)++;
    }
  }
}
 
int main(void)
{
  while (1) {
    int n,m;
    cin >> n >> m;
    if (!n && !m) break;
    hitAndBlow(&n, &m);
    cout << n << " " << m << endl;
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  while(1){
    string a,b;
    int hit=0,brow=0;
    cin>>a>>b;
    if(a == "0" && b == "0"){
      break;
    }
    
    for(int i=0;i<4;i++){
      for(int j=0;j<4;j++){
	if(a[i] == b[j]){
	  if(i == j){
	    hit++;
	  }else{
	    brow++;
	  }
	  break;
	}
      }
    }
    cout<<hit<<" "<<brow<<endl;
  }
}

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

int main()
{
	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++;
			}
			else
			{
				for(int j=0; j<4; j++)
				{
					if(a[i]==b[j])
					{
						blow++;
						break;
					}
				}
			}
		}

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

C++: #include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)

int main(){
	while(1){
		char a[5], b[5];
		cin>>a>>b;
		if(a[1]==0) break;
		int cnt[10];
		REP(i, 10) cnt[i]=0;
		int hit = 0;
		REP(i, 4){
			if(a[i]==b[i]) hit++;
			else{
				cnt[a[i]-'0']++;
				cnt[b[i]-'0']++;
			}
		}
		int blow = 0;
		REP(i, 10){
			if(cnt[i]==2) blow++;
		}
		printf("%d %d\n", hit, blow);
	}
}

C++: #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

char buf[10];
int main() {
	int a[4], b[4];
	while (gets_s(buf), strcmp(buf, "0 0")) {
		char*s = buf;
		rep(i, 4) { sscanf(s, "%1d", &a[i]); s += 1; }s += 1;
		rep(i, 4) { sscanf(s, "%1d", &b[i]); s += 1; }
		int hit = 0, blow = 0;
		rep(i, 4)if (a[i] == b[i])hit++;
		rep(i, 4) if (find(a, a + 4, b[i]) != a + 4)blow++;
		cout << hit << ' ' << blow - hit << endl;
	}
	return 0;
}