Skip to main content
3 of 10
added brief comments to ungolfed version

#Java 8, 715 bytes

Could reduce by another 5 bytes naming the function d instead of divide or another 16 bytes if not counting class-definition.

public class G{int l(String a){return a.length();}int v(String b,int c){return c<l(b)?Character.digit(b.charAt(l(b)-c-1),10):0;}String e(String a){for(int i=0;i<l(a);i++){if(a.charAt(i)!='0'){return a.substring(i);}}return"0";}String divide(String n,String m){int b=l(m),j,k,l,d;String q,t;String[]x=new String[9];x[0]=m;for(j=1;j<9;j++){q="";l=0;t=x[j-1];for(k=0;k<l(t);k++){d=v(t,k)+l+v(m,k);q=(d%10)+q;l=d/10;}if(l>0){q=l+q;}x[j]=q;}q="";f:for(;b<=l(n);b++){for(j=8;j>=0;j--){String y=n.substring(0,b),z=e(y),a=x[j];if((l(z)==l(a)&&a.compareTo(z)<=0)||l(z)>l(a)){t="";l=0;for(k=0;k<l(y);k++){d=v(y,k)-l-v(a,k);d=d<0?d+20:d;t=(d%10)+t;l=d/10;}n=t+n.substring(b);q+=(j+1);continue f;}}q+=0;}return e(q)+","+e(n);}}

Can be used like this:

public static void main(String[] args) {
    G devision = new G();
    System.out.println(devision.divide("20397882081197443358640281739902897356800000000",
            "265252859812191058636308480000000"));
    System.out.println(devision.divide("31035053229546199656252032972759319953190362094566672920420940313",
            "1234567891011121314151617181920"));
    System.out.println(devision.divide(
            "271841734957981007420619769446411009306983931324177095509044302452019682761900886307931759877838550251114468516268739270368160832305944024022562873534438165159941045492295721222833276717171713647977188671055774220331117951120982666270758190446133158400369433755555593913760141099290463039666313245735358982466993720002701605636609796997120000000000000000000000000000000000000000000000000",
            "247"));
}

yielding

76899763100160,0
25138393324103249083146424239449429,62459510197626865203087816633
1100573825740813795225181252819477770473619155158611722708681386445423816849801159141424129060075102231232666057768175183676764503262931271346408394876267875141461722640873365274628650676808557279259873162169126398101692109801549256156915750794061370041981513180387019893765753438422927286098434193260562682052606153857091520795991080960000000000000000000000000000000000000000000000000,0

Ungolfed:

public class ArbitraryPrecisionDivision {

    // Length of String
    int l(String a){return a.length();}

    // int-value of c-th digit from right or 0
    int v(String b, int c) {
        if (c < l(b)) {
            return Character.digit(b.charAt(l(b) - c - 1), 10);
        }
        return 0;
    }

    // add n to m
    //l(n) >= l(m)
    String a(String n, String m) {
        String a = "";int c=0;
        for (int i = 0; i < l(n); i++) {
            int d = v(n, i) + c + v(m, i);
            a = (d % 10) + a;
            c = d / 10;
        }
        if (c > 0) {
            a = c + a;
        }
        return a;
    }

    // substract m of n
    //n >= m
    String s(String n, String m) {
        String a = "";int c=0;
        for (int i = 0; i < l(n); i++) {
            int d = v(n, i) - c - v(m, i);
            d = d < 0 ? d + 20 : d;
            a = (d % 10) + a;
            c = d / 10;
        }
        return a;
    }

    // trim all leading 0s
    String e(String a) {
        for (int i = 0; i < l(a); i++) {
            if (a.charAt(i) != '0') {
                return a.substring(i);
            }
        }
        return "0";
    }

    // divide n by m returning n/m,n%m
    String divide(String n, String m) {
        String[] x = new String[9];
        x[0] = m;
        for (int i = 1; i < 9; i++) {
            x[i] = a(x[i - 1], m);
        }
        String q = "";
        int b = l(m), i;
        z:
        for (;b <= l(n);b++) {
            for (i = 8; i >= 0; i--) {
                String y = n.substring(0, b), z = e(y), a = x[i];
                if ((l(z) == l(a) && a.compareTo(z) <= 0) || l(z) > l(a)) {
                    n = s(y, a) + n.substring(b);
                    q += (i + 1);
                    continue z;
                }
            }
            q += 0;
        }
        return e(q) + "," + e(n);
    }

    public static void main(String[] args) {
        ArbitraryPrecisionDivision devision = new ArbitraryPrecisionDivision();
        System.out.println(devision.divide("20397882081197443358640281739902897356800000000",
                "265252859812191058636308480000000"));
        System.out.println(devision.divide("31035053229546199656252032972759319953190362094566672920420940313",
                "1234567891011121314151617181920"));
        System.out.println(devision.divide(
                "271841734957981007420619769446411009306983931324177095509044302452019682761900886307931759877838550251114468516268739270368160832305944024022562873534438165159941045492295721222833276717171713647977188671055774220331117951120982666270758190446133158400369433755555593913760141099290463039666313245735358982466993720002701605636609796997120000000000000000000000000000000000000000000000000",
                "247"));
    }
}

I guess this will not be the shortest solution, but maybe it gives a good start.