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<cstdio>
using namespace std;
int main(void)
{
	int a,b,i,j,hit,brow,p;
	char x[5],kaitou[5];
	scanf("%s %s",x,kaitou);
	while(!(x[0]=='0' && kaitou[0]=='0')){
		hit=0;
		brow=0;
		for(i=0;i<4;i++){
			if(x[i]==kaitou[i]){
				hit++;
			}
			else {
				for(j=0;j<4;j++){
					if(kaitou[j]==x[i]){
					brow++;
					}
				}
			}
		}
		
		printf("%d %d\n",hit,brow);
		scanf("%s %s",x,kaitou);
	}
	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    int hit,brow;
    char a[5],b[5];
    for(;;){
        hit=0,brow=0;
        cin>>a>>b;
        if(a[0]=='0'&&a[1]=='\0')break;
        for(int i=0;i<3;i++){
            for(int j=i+1;j<4;j++){
                if(a[i]==b[j]||b[i]==a[j])brow++;
            }
        }
        for(int i=0;i<4;i++){
            if(a[i]==b[i])hit++;
        }
        cout<<hit<<" "<<brow<<endl;
    }

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<iostream>
#include<string>

using namespace std;

int main(){
	string str1,str2;
	
	while(cin>>str1>>str2 && str1!="0" &&str2!="0"){
		int h=0,b=0;
		for(int i=0;i<str1.size();i++){
			int tmp=str2.find(str1[i]);
			if(tmp==i)h++;
			else if(tmp!=string::npos)b++;
		}
		cout<<h<<" "<<b<<endl;
	}
}

C++: #include <stdio.h>
#include <string.h>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
char a[4], b[4]; int  hit, blow;
int main() {
	while (true) {
		scanf("%s %s", a, b);
		if (strlen(a) == 1 && strlen(b) == 1) break;
		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++; break;
				}
			}
		}
		printf("%d %d\n", hit, blow);
	}
	return 0;
}

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

int main(){
	string la,lb;
	int a[4],b[4];
	int hit,blow;
	while(cin>>la>>lb,la!="0"&&lb!="0"){
	hit=blow=0;
	for(int i=0;i<4;i++){
		if(la[i]==lb[i]){hit++;}
		a[i]=la[i]-'0';
		b[i]=lb[i]-'0';
	}
	sort(a,a+4);sort(b,b+4);
	for(int i=0;i<4;i++){
		for(int j=0;j<4;j++){
			if(a[i]==b[j])blow++;
			if(a[i]<b[j])break;
		}
	}
	
	cout<< hit<<" "<<blow-hit<<endl;
	}
	
}

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

int main(){
   int x,y,n[4],m[4];
   int h,b,i,j;
   
   while(1){
      cin >> x >> y;
      if(x+y==0) break;
      
      h=0; b=0;
      
      for(i=3; i>0; i--){
         n[i]=x/pow(10,i);
         x-=n[i]*pow(10,i);
         m[i]=y/pow(10,i);
         y-=m[i]*pow(10,i);
      }
      n[0]=x; m[0]=y;
      
      for(i=0;i<4;i++){
         if(n[i]==m[i]) h++;
         else for(j=0;j<4;j++){
            if(n[i]==m[j]) b++;
         }
      }
      
      cout << h << " " << b << endl;
   }
   
   return 0;
}

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

int main()
{
  string a, b;
  int hit, blow;

  while( cin >> a >> b, a != "0" ) {
    hit = blow = 0;
    for(int i=0; i<4; i++) {
      if( a[i] == b[i] ) hit++;
    }

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

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

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  string a, b;
  while (cin >> a >> b, a != "0") {
    int hit = 0, blow = 0;
    for (int i = 0; i < 4; i++) {
      hit += a[i] == b[i];
    }
    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 4; j++) {
        blow += a[i] == b[j];
      }
    }
    blow -= hit;
    cout << hit << " " << blow << endl;
  }

  return 0;
}

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

int main() {
    while (true) {
        char r[5], a[5];
        cin >> r >> a;
        if (r[0] == '0' && a[0] == '0' && !isdigit(r[1])) {
            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;
    }
}

C++: #include <iostream>

using namespace std;

int main()
{
    int r, a;

    while (cin >> r >> a, r || a) {
        int hit, blow;
        bool rf[10], af[10];

        for (int i = 0; i < 10; i++)
            rf[i] = af[i] = false;
        
        hit = blow = 0;
        for (int i = 0; i < 4; i++) {
            if (r % 10 == a % 10)
                hit++;
            else {
                rf[r % 10] = true;
                af[a % 10] = true;
            }
            r /= 10;
            a /= 10;
        }
        for (int i = 0; i < 10; i++)
            if (rf[i] && af[i])
                blow++;
        cout << hit << " " << blow << endl;
    }

    return 0;
}

C++: #include <cstdio>

int main(void)
{
    char r[5], a[5];
    while (1){
        scanf("%s %s", r, a);
        if (r[1] == '\0' && a[1] == '\0') 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 <stdio.h>
int main(){
    int l,r,a,b,dl[4],dr[4],m[100];
    while(1){
        scanf("%d%d",&l,&r);
        if(l==0&&r==0)return 0;
        a=b=0;
        for(int i=0;i<10;i++)m[i]=0;
        for(int i=0;i<4;i++){
            dl[i]=l%10;
            dr[i]=r%10;
            l/=10;
            r/=10;
            if(dl[i]==dr[i])a++;
            else {
                m[dl[i]]++;
                m[dr[i]]++;
            }
        }
        for(int i=0;i<10;i++)if(m[i]>1)b++;
        printf("%d %d\n",a,b);
    }
    
}

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

int main(){
	vector<int> r,a;
	int tr,ta,hit=0,blow=0;

	while(true){
		cin>>tr>>ta;
		if(tr==0 && ta==0) break;

		for(int i=1000;i>=1;i/=10){
			r.push_back(tr/i-tr/(i*10)*10);
			a.push_back(ta/i-ta/(i*10)*10);
		}

		for(int i=0;i<r.size();++i){
			if(r[i]==a[i]){
				hit++;
				continue;
			}
			for(int j=0;j<r.size();++j){
				if(i==j) continue;
				if(r[i]==a[j]){
					blow++;
					break;
				}
			}
		}

		cout<<hit<<" "<<blow<<endl;
		r.clear();a.clear();hit=blow=0;
	}

	return 0;
}