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() {
    while (true) {
        int r, a;
        cin >> r >> a;
        
        if (r==0 && a==0) {
            break;
        }
        
        int rn[4], an[4];
        
        rn[0] = r/1000;
        rn[1] = (r/100)%10;
        rn[2] = (r/10)%10;
        rn[3] = r%10;
        
        an[0] = a/1000;
        an[1] = (a/100)%10;
        an[2] = (a/10)%10;
        an[3] = a%10;
        
        int hit = 0;
        int blow = 0;
        
        bool is_hit[4];
        
        for (int i=0; i<4; i++) {
            is_hit[i] = false;
        }
        
        for (int i=0; i<4; i++) {
            if (rn[i]==an[i]) {
                hit++;
                is_hit[i] = true;
            }
        }
        
        for (int i=0; i<4; i++) {
            if (!(is_hit[i])) {
                for (int j=0; j<4; j++) {
                    if (!(is_hit[j]) && rn[i]==an[j]) {
                        blow++;
                    }
                }
            }
        }
        
        cout << hit << " " << blow << endl;
    }
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
  string a, b;
  bool anum[10];
  bool bnum[10];
  while(cin >> a >> b){
    int hit=0, blow=0;
    memset(anum, 0, sizeof(anum));
    memset(bnum, 0, sizeof(bnum));
    if(a == "0" && b == "0") break;
    
    for(int i = 0 ; i < 4 ; i++){
      if(a[i] == b[i]) hit++;
      else{
	anum[a[i]-'0'] = 1;
	bnum[b[i]-'0'] = 1;
      }
    }
    
    for(int i = 0 ; i <= 9 ; i++){
      if(anum[i] == 1 && bnum[i] == 1){
	blow++;
      }
    }
    
    cout << hit << ' ' << blow << endl;
  }
  return 0;
}

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

int hit(string a,string b){
	int res = 0;
	for(int i=0;i<4;i++){
		if(a[i] == b[i]) res++;
	}
	return res;
}

int blow(string a,string b){
	int res = 0;
	for(int i=0;i<4;i++){
		for(int j=0;j<4;j++){
			if(i != j && a[i] == b[j]){
				res++;
				break;
			}
		}
	}
	return res;
}

int main(void){
	string a,b;

	while(cin>>a>>b, a!="0"){
		cout<<hit(a,b)<<" "<<blow(a,b)<<endl;
	}

	return 0;
}

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

int main()
{
    
    int ans,sccs,hit=0,brow=0;
    int success[4] = {0},answer[4] = {0};
    
    while (1) {
        cin >> sccs >> ans;
        if (ans == 0 && sccs == 0) break;
        hit = 0;
        brow = 0;
        
        for (int i = 3; i >= 0; i--) {
            answer[i] = ans % 10;
            ans = ans / 10;
            success[i] = sccs % 10;
            sccs = sccs / 10;
        }
        
        for (int i = 0; i < 4; i++) {
            for (int k = 0; k < 4; k++) {
                if (answer[i] == success[k]) {
                    if (i == k) {
                        hit++;
                        break;
                    }else {
                        brow++;
                        break;
                    }
                }
            }
        }
        
        cout << hit << " " <<  brow << endl;
    }
    return 0;
}

C++: #include<iostream>
#include<cstring>
using namespace std;
int main(){
	char a[10],b[10];
	while(true){
	cin>>a>>b;
	if(strcmp(a,"0")==0&&strcmp(b,"0")==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 <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

string s, t;

int main()
{
	while (cin >> s >> t, s != "0"){
		int a = 0, b = 0;
		rep(i, 4){
			if (s[i] == t[i]){
				a++;
				s[i] = t[i] = '*';
			}
		}
		rep(i, 4){
			int p = t.find(s[i]);
			if (p != -1){
				b++;
				t[p] = '*';
			}
		}
		cout << a << " " << endl;
	}
}

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

int main(){

  string n,m;

  while(true){
    cin >> n >> m;
    if(n == "0" && m == "0") break;

    int hit = 0,blow = 0;

    for(int i=0;i<4;i++){
      if(n[i] == m[i]){
	hit++;
	m[i] = 'A';
      }
    }

    for(int i=0;i<4;i++){
      for(int j=0;j<4;j++){
	if(n[i] == m[j]){
	  blow++;
	  m[j] = 'A';
	}
      }
    }

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

  }

}

C++: #include<iostream>
using namespace std;
int main(void){

    string q,a;
    while(cin>>q>>a){
        if(q==a&&q=="0")break;
        int hit=0,blow=0;

        for(int i=0;i<4;i++){
            if(q[i]!=-1&&q[i]==a[i]){
                hit++;
                q[i]=a[i]=-1;
            }
        }
        for(int i=0;i<4;i++){
            for(int j=0;j<4;j++){
                if(q[i]!=-1&&a[j]!=-1&&q[i]==a[j]){
                    blow++;
                    q[i]=a[j]=-1;
                }
            }
        }
        cout<<hit<<" "<<blow<<endl;
    }

    return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

int main()
{
	char a[10],b[10];
	while(cin>>a>>b,strcmp(a,"0")){
		int h=0,bo=0;
		rep(i,4)rep(j,4)if(a[i]==b[j]){
			if(i==j)h++;
			else bo++;
		}
		cout<<h<<" "<<bo<<endl;
	}
	
	return 0;
}

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

using namespace std;

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

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	int a,r;
	while(true){
		cin>>a>>r;
		if(a==0&&r==0)
			break;
		int h=0,b=0;
		char c[4],d[4];
		c[0]=a/1000+'0';
		c[1]=a/100%10+'0';
		c[2]=a/10%10+'0';
		c[3]=a%10+'0';
		d[0]=r/1000+'0';
		d[1]=r/100%10+'0';
		d[2]=r/10%10+'0';
		d[3]=r%10+'0';
		for(int i=0;i<4;i++){
			for(int j=0;j<4;j++){
				if(c[i]==d[j])
					b++;
			}
		}
		for(int i=0;i<4;i++){
			if(c[i]==d[i])
				h++;
		}
		b-=h;
		cout<<h<<" "<<b<<endl;
	}
    return 0;
}