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

int main() {
	int r, a;
	
	while(1){
		cin >> r >> a;
		if(r == 0 && a == 0)
			break;
		
		int right[4], ans[4], hit = 0, blow = 0;
		for(int i = 0; i < 4; ++i){
			right[i] = r % 10;
			r /= 10;
			ans[i] = a % 10;
			a /= 10;
		}
		for(int i = 0; i < 4; ++i){
			for(int j = 0; j < 4; ++j){
				if(right[i] == ans[j]){
					if(i == j)
						hit++;
					else
						blow++;
				}
			}
		}
		cout << hit << " " << blow << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int r,a;
    while(cin>>r>>a,r||a){
        int h,b;
        h=b=0;
        int t[4],w[4];
        for(int i=0,er=1000;i<4;i++,er/=10){
            t[i]=r/er;
            r-=t[i]*er;
            w[i]=a/er;
            a-=w[i]*er;
        }

        for(int i=0;i<4;i++){
            for(int j=0;j<4;j++){
                if(t[i]==w[j]){
                    if(i==j)h++;
                    else b++;
                    break;
                }
            }
        }
        cout<<h<<" "<<b<<endl;
    }
}

C++: #include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define itrep(it, a) for(it = (a).begin(); it != (a).end; it++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
#define INF (1 << 30)
using namespace std;

int main(){
    string a, b;
    while(cin >> a >> b, a[0] - '0'|| b[0] - '0'){
        int result[2] = {0};
        map<char, int> blow;
        rep(i,4){
            blow[a[i]]++;
        }
        rep(i,4){
            result[0]+=blow[b[i]];
            if(a[i] == b[i]) result[1]++;
        }
        cout << result[1] << ' ' << result[0] - result[1] << endl;
    }
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main()
{
while(;;){
int a,b;
cin >> a >> b;
if(a==0&&b==0)return 0;
int x[4],y[4];
for(int i=0;i<4;i++){
x[i]=a%10;
a/=10;
y[i]=b%10;
b/=10;
}

int hit=0,blow=0;
for(int i=0;i<4;i++)if(x[i]==y[i])hit++;

for(int i=0;i<4;i++){
for(int j=0;j<4;j++)if(x[i]==y[j])blow++;
}
blow-=hit;

printf("%d %d\n",hit,blow);
}
}

C++: #include<iostream>
#include<string>
using namespace std;
int main() {
	string n, m;
	while (cin >> n >> m&&n != "0"&&m != "0") {
		int h = 0, b = 0;
		bool w[4];
		fill(w, w + 4, false);
		for (int i = 0; i < 4; i++) {
			if (n[i] == m[i]) {
				h++;
				w[i] = true;
			}
		}
		for (int i = 0; i < 4; i++) {
			if (!w[i]) {
				for (int j = 0; j < 4; j++) {
					if (!w[i] && n[i] == m[j])
						b++;
				}
			}
		}
		cout << h << " " << b << endl;
	}
}

C++: #include <cstdio>

#define SE(a, b) ((a == '\0') && (b == '\0')) ? 1 : 0

int main(void)
{
    char r[5], a[5];
    while (1){
        scanf("%s %s", r, a);
        if (r[0] == '0' && a[0] == '0' && SE(r[1], a[1])) break;
        int hit = 0, 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 (r[i] == a[j]) blow++;
            }
        }
        printf("%d %d\n", hit, blow - hit);
    }
    
    return (0);
}

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

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

string lh, rh;

void solve() {
  int h = 0, b = 0;
  rep(i,4) {
    if (lh[i] == rh[i]) {h++; continue;}
    if (lh.find(rh[i]) != -1) b++;
  }
  cout<<h<<" "<<b<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>lh>>rh) {
    if (lh == "0" && rh == "0") {
      break;
    } else {
      solve();
    }
  }
  return 0;
}

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

int main() {
    string s, t;
    while (cin >> s >> t) {
        if (s == "0" && t == "0") break;
        int hit = 0, blow = 0;
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4; j++) {
                if (s[i] == t[j]) {
                    blow++;
                }
            }
        }
        for (int i = 0; i < 4; i++) {
            if (s[i] == t[i]) {
                blow--;
                hit++;
            }
        }
        cout << hit << ' ' << blow << endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main(){
	string r,a;
	while(1){
		int h=0,b=0;
		cin>>r>>a;
		if(r=="0" && a=="0") break;
		rep(i,0,4){
			if(r.find(a[i])!=string::npos) b++;
		}
		rep(i,0,4){
			if(r[i]==a[i]){
				b--; h++;
			}
		}
		o(h<<" "<<b);
	}
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(void)
{
    int Hit,bro;
    string r,n;
    while(1){
        Hit=0;bro=0;
        cin>>r>>n;
        if(r[0]=='0'&&n[0]=='0')break;
        for(int i=0;i<4;i++){
            for(int j=0;j<4;j++){
                if(r[i]==n[i]){
                Hit++;
                break;
            }else if(r[i]==n[j]){
                bro++;
                break;
            }
        }
    }
        cout<<Hit<<" "<<bro<<"\n";
}
}

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

using namespace std;

int main(){
for(int x=0;x>=0;x++){
	char r[5];
	char a[5];
	char z[2]="0";
	cin>>r>>a;
	if((strcmp(r,z)==0)&&(strcmp(a,z)==0)){
		break;
	}
	int h=0,b=0;
	for(int i=0;i<=3;i++){
			for(int j=0;j<=3;j++){
				if(r[i]==a[j]){
					b++;
					if(i==j){
						h++;
					}
				}
			}
	}
	b=b-h;
	cout<<h<<' '<<b<<'\n';
}
	return 0;
}

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



int main()
{
while(1){
	char r[10]; char a[10];
	int h=0,v=0,i,j;

	cin >> r;
	cin >> a;
if(r[0]=='0'&&r[1]=='\0')break;
	for(i=0;i<4;i++){
		if(r[i]==a[i])h=h+1;
	for(j=0;j<4;j++){
		if(r[i]==a[j])v=v+1;
		if(r[i]==a[i]&&r[i]==a[j])v=v-1;
		
		}
	}
cout<<h<<" "<<v<<endl;

}
return 0;

}

C++: #include<iostream>
#include<string>
#include<cstdio>
using namespace std;
 
#define rep(i,x) for(int i=0;i<x;i++)
 
int main(){
	while(1){
		string s,t;
		cin>>s>>t; if(s=="0"&&t=="0")break;
		int r[5],a[5];
		rep(i,4){
			r[i]=s[i]-48;
			a[i]=t[i]-48;
		}
		int c=0,d=0;
		rep(i,4){
			if(r[i]==a[i])c++;
			else {
				rep(j,4)if(r[i]==a[j])d++;
			}
		}
 
		printf("%d %d\n",c,d);
	}
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	/*string s,b;
	cin>>s>>b;
	if(s[0]==b[1])cout<<"!"<<endl;*/
	string a,b;
	while(cin>>a>>b,a!="0"||b!="0"){
		int h=0,br=0;
		rep(i,4)rep(j,4){
			if(a[i]==b[j]){
				if(i==j)h++;
				else br++;
			}
		}
		cout<<h<<" "<<br<<endl;
	}
}