Create new file with increment column based on conditions

Hello,

Using bash script, i need to process the following file:

887,86,,2013-11-06,1,10030,5,2,0,200,,
887,86,,2013-11-05,1,10030,5,2,0,199,,
887,138,,2013-11-06,1,10031,6,2,0,1610612736,,
887,164,,2013-11-06,1,10000,0,2,0,36000,,

and to create a new file such as the below

887,100,200,86
887,101,199,86
887,100,1610612736,138
887,100,36000,164.

The main functionality would be to check whether column 1 and 2 are indentical (in the example that's 887 and 86). If this is the case, then the second field on the new file will be an incremental value starting from 100 for the first match row and 101 for the second and so on. If no more that one matching rows on 1 and 2 are found ,then the value of the new second row would be 100.

Can you please help?

Thanks,
John

Can you post what you have done to solve this problem...

Is this a homework assignment?