import java.io.*;
import java.util.*;

public class Tester {
    public static void main(String[] args) {
        int cnt = 0;
        for (int length = 1, limit = 10; length <= 5; ++length, limit *= 10) {
            String fmt = "%0" + length + "d";
            for (int value = 0; value < limit; ++value) {
                String test = String.format(fmt, value);
                for (int k = 1; k <= 7 * length; ++k) {
                    long t0 = System.currentTimeMillis();
                    String correct = digits_mb_brute.solve(k, test);
                    long t1 = System.currentTimeMillis();
                    String nkk = digits_mb_nkk.solve(k, test);
                    long t2 = System.currentTimeMillis();
                    String nk = digits_mb.solve(k, test);
                    long t3 = System.currentTimeMillis();
                    if (++cnt % 1000 == 0) {
                        System.out.printf(
                            "s = %8s k = %3d t(brute) = %3d t(nkk) = %3d t(nk) = %3d%n",
                            test, k,
                            t1 - t0, t2 - t1, t3 - t2
                        );
                    }
                    if (!correct.equals(nkk) || !correct.equals(nk)) {
                        System.out.printf(
                            "s = %8s k = %3d t(brute) = %3d t(nkk) = %3d t(nk) = %3d%n",
                            test, k,
                            t1 - t0, t2 - t1, t3 - t2
                        );
                        System.out.println("Correct: " + correct + " NKK: " + nkk + " NK: " + nk);
                        return;
                    }
                }
            }
        }
    }
}
