Dear Arup,

Sorry if I misunderstood the requirements.
But, I think there is two "FIRST THREE" in play over here.

For [ 3, 4, 5, 3, 3, 4, 4, 4, 5 ] what do you expect to get in return?

Because the line

num_to_del = a.find { |e| a.count(e) >= 3 }

Finds the only the first number in array that has three duplicates.
So it will find 3 and not 4. ( I misunderstood this as being a "First
Three Duplicate Number" )

After that, do you want do delete the first 3 occurrences of the number 3 ?
So, if there's only 3 number 3s. It will rest none of them?
But, with the number five that has only 2 elements. it will rest the
two of them? (more than the 3 number)
And the 4 number, that has more than three duplicates, it rest all the
Or it will rest 1 element of them, so that it has 4 and 4-3 = 1?
The sorting order of the elements are important?
If you have one more triplet like in [3, 4, 5, 3, 3, 3, 3, 3] with 6 number 3s?
Do you want the second triplet to be deleted also?

Could you state more clearly your requirements?

Best regards,
Abinoam Jr.

On Sun, Feb 9, 2014 at 7:47 AM, Arup Rakshit <lists / ruby-forum.com> wrote:
> Abinoam Jr. wrote in post #1136118:
>> Dear Arup,
>
>>
>> # All the part from 3.times do block on got substituted.
>> # Now is easy to figure out that the first return is also redundant
>>
>> def del_first_three(a)
>>   num_to_del = a.find { |e| a.count(e) >= 3 }
>>   a.delete_if { |e| e == num_to_del }
>> end
>>
>
> Nice re-factoring. But the point is, I want to delete first 3
> duplicates. But `a.delete_if { |e| e == num_to_del }` will delete all
> the elements, which has occurrence 3 or more than 3.
>
> My point is if any element occurs 4 times, I would delete only first 3
> occurrence.
>
> --
> Posted via http://www.ruby-forum.com/.