In reply to rahulcodesinverilog:
You have not explained your algorithm very well. Are you using the words slot, input, position interchangeably? How does 100,50, 50, 0 turn into 2,1,1,0. I see there is a relationship, but you never defined it. What defines the output you are expecting.