Scoring the postal code mismatch I have two postal codes (fixed size of 6 digits) to compare and return the mismatch score.
where the mismatch weight of initial indexes is higher, then keep reducing.

Example postal code 123456, with index[0] ==&gt; 1 is northern region, and if index[0] ==&gt; 2 is southern region. so it should have very high mismatch score 123456 and 223456. index[1] represents sub-region like state, index[3] is like county/district, and so on..
But maybe 111156 and 111160 are nearer sub locality should be having less mismatch score.

The output of my result should match the score in the percentile.

To achieve this, if I take weights like this Sum[0.45, 0.15, 0.1, 0.1, 0.1, 0.1] == 100% but fixed weights cannot differentiate index base, e.g. for input source postal 111111 than searching with 111152 is greater mismatch than searching with 111125 as if we sum the mismatch scores. Mismatch weights percentile [0.45, 0.15, 0.1, 0.1, 0.1, 0.1] states, if there is a mismatch, happens at index 2, 3, 4, 5 all has a penalty of 10%, but this results in 111152 and 111125 will have same mismatch score for actual postal code 11111. So we cannot differentiate between 111152 and 111125. But you see 111125 is closer to 111111.
This makes me think of cumulative percentile index percentile like [1, 0.55, 0.4, 0.3, 0.2, 0.1] but this also doesn't work. As the sum of mismatch score going more than 1.

Also, it is not worthy to rely on the difference of postal code, like `111000 - 110999`, though it has a difference of 1, this difference same for `111000 - 111001`. 
Hence `(((double)diff/Math.pow(10, diff.length()))` is also not working to compute.
So taking diff between two postal code as 123 then
123/1000 * (penalty[diff.length()]) wont work, as we cannot directly rely on difference.

Examples: 
If i prefer mismatch penalty like { 0.8d, 0.7d, 0.6d, 0.3d, 0.15d, .05d }
0.05% penalty if the last char is not matched.
0.80% penalty if the first char is not matched.
Apply some minor penalty for every mismatch; after the first mismatch.

{&quot;input&quot; , &quot;toBeCompared&quot;, &quot;matchScore&quot;}
{&quot;999999&quot;, &quot;989999&quot;, 0.29}, //71% mismatched, 29% matched
{&quot;999999&quot;, &quot;998999&quot;, 0.39}, 
{&quot;999999&quot;, &quot;999899&quot;, 0.7 }, 
{&quot;999999&quot;, &quot;999989&quot;, 0.85}, 
{&quot;999999&quot;, &quot;999998&quot;, 0.95}, //95% matched

Also should be able to differentiate scores between varying numbers.
{&quot;111225&quot;, &quot;111223&quot;, 0.949}, 
{&quot;111225&quot;, &quot;111229&quot;, 0.948}, 

How to achieve this? Kindly help.
If I understand you correctly, a minor modification of the absolute value should work, where you do digit-wise absolute difference and keep the magnitude:
$$
\sum_i \left| x[i] - y[i] \right| \cdot 10^{i}
$$
or in Python:
def dist(x, y):
    xs, ys = str(x), str(y)
    l = len(xs)
    diff = lambda a, b, i: abs(int(a[i]) - int(b[i])) * 10**(l-i-1)
    return sum(diff(xs,ys,i) for i in range(len(xs)))

To illustrate with your examples:
dist(111111, 111152) = 41 &gt; dist(111111, 111125) = 14

dist(111000, 110999) = 1999 &gt; dist(111000, 111001) = 1

You say (south v north) that this should be a very large diff, and that it is:
dist(123456, 223456) = 100000