# Isolating non-unique items in an array

**URL:** <https://rubytalk.org/t/isolating-non-unique-items-in-an-array/31829>\
**Category:** ruby-talk\
**Created:** [12 October 2006 15:24 UTC](https://rubytalk.org/t/isolating-non-unique-items-in-an-array/31829 "2006-10-12T15:24:48Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jason](https://avatars.discourse-cdn.com/v4/letter/j/dc4da7/32.png) [@Jason](https://rubytalk.org/u/Jason)\
**Post date:** [12 October 2006 15:24 UTC](https://rubytalk.org/t/isolating-non-unique-items-in-an-array/31829/1 "2006-10-12T15:24:48Z")

</div>

I'm basically trying to the opposite of .uniq Let's say I have an array:

["a", "a", "a", "b", "c", "d", "d"]

I would like to boil this down by first tossing the values that only  
appear once. Which leaves me with:

["a", "a", "a", "d", "d"]

Then I need to somehow determine that "a" appears 3 times and "d"  
appears 2 times. Any help would be great. Thanks.

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Tim\_Pease](https://avatars.discourse-cdn.com/v4/letter/t/3e96dc/32.png) [@Tim\_Pease](https://rubytalk.org/u/Tim_Pease)\
**Post date:** [12 October 2006 15:41 UTC](https://rubytalk.org/t/isolating-non-unique-items-in-an-array/31829/2 "2006-10-12T15:41:42Z")

</div>

class Array  
&nbsp;&nbsp;def count( item )  
&nbsp;&nbsp;&nbsp;&nbsp;return 0 unless self.include? item

&nbsp;&nbsp;&nbsp;&nbsp;c = 0  
&nbsp;&nbsp;&nbsp;&nbsp;self.each {|i| c += 1 if i == item}  
&nbsp;&nbsp;&nbsp;&nbsp;return c  
&nbsp;&nbsp;end  
end

ary = %w(a a a b c d d)  
new\_ary = ary.select {|item| ary.count(item) \> 1}

counts = Hash.new {|h,k| h[k] = new\_ary.count(k)}

It's not going to be fast, but it should work.

Blessings,  
TwP

> **···**
>
> On 10/12/06, Jason Burgett \<jasbur@gmail.com\> wrote:
> 
> > I'm basically trying to the opposite of .uniq Let's say I have an array:
> > 
> > ["a", "a", "a", "b", "c", "d", "d"]
> > 
> > I would like to boil this down by first tossing the values that only  
> > appear once. Which leaves me with:
> > 
> > ["a", "a", "a", "d", "d"]
> > 
> > Then I need to somehow determine that "a" appears 3 times and "d"  
> > appears 2 times. Any help would be great. Thanks.
> > 
> > --  
> > Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Jeff\_Schwab](https://avatars.discourse-cdn.com/v4/letter/j/b5ac83/32.png) [@Jeff\_Schwab](https://rubytalk.org/u/Jeff_Schwab)\
**Post date:** [12 October 2006 15:50 UTC](https://rubytalk.org/t/isolating-non-unique-items-in-an-array/31829/3 "2006-10-12T15:50:14Z")

</div>

Jason Burgett wrote:

> I'm basically trying to the opposite of .uniq Let's say I have an array:
> 
> ["a", "a", "a", "b", "c", "d", "d"]
> 
> I would like to boil this down by first tossing the values that only appear once. Which leaves me with:
> 
> ["a", "a", "a", "d", "d"]
> 
> Then I need to somehow determine that "a" appears 3 times and "d" appears 2 times. Any help would be great. Thanks.

# Output:  
# ["a", "a", "a", "d", "d"]  
# {"a"=\>3, "d"=\>2}

def get\_counts(keys)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;counts = Hash.new(0)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;keys.each {|k| counts[k] += 1 }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;counts  
end

def non\_uniq(elements)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;counts = get\_counts(elements)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;counts.delete\_if {|k, v| v \< 2 }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elements.select {|e| counts.key?(e) }  
end

elements = ["a", "a", "a", "b", "c", "d", "d"]

p non\_uniq(elements)  
p get\_counts(elements).delete\_if {|k, v| v \< 2 }

---

<div class="post-metadata">

**Author:** ![Drew\_Olson](https://avatars.discourse-cdn.com/v4/letter/d/c67d28/32.png) [@Drew\_Olson](https://rubytalk.org/u/Drew_Olson)\
**Post date:** [12 October 2006 16:02 UTC](https://rubytalk.org/t/isolating-non-unique-items-in-an-array/31829/4 "2006-10-12T16:02:39Z")

</div>

Jason Burgett wrote:

> I'm basically trying to the opposite of .uniq Let's say I have an array:
> 
> ["a", "a", "a", "b", "c", "d", "d"]
> 
> I would like to boil this down by first tossing the values that only  
> appear once. Which leaves me with:
> 
> ["a", "a", "a", "d", "d"]
> 
> Then I need to somehow determine that "a" appears 3 times and "d"  
> appears 2 times. Any help would be great. Thanks

This should work:

a = ["a", "a", "a", "b", "c", "d", "d"]  
a.uniq.map{|i| i if (a.map{|j| j if j==i}.length \> 1)}

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Ross\_Bamford4](https://avatars.discourse-cdn.com/v4/letter/r/ea666f/32.png) [@Ross\_Bamford4](https://rubytalk.org/u/Ross_Bamford4)\
**Post date:** [12 October 2006 16:04 UTC](https://rubytalk.org/t/isolating-non-unique-items-in-an-array/31829/5 "2006-10-12T16:04:02Z")

</div>

There are bound to be better ways, but you could try something like:

a = ["a", "a", "a", "b", "c", "d", "d"]  
# =\> ["a", "a", "a", "b", "c", "d", "d"]

hsh = a.inject(Hash.new{|h,k| h[k] = 0}) {|h,v| h[v] += 1 ; h}.reject!  
{|k,v| v == 1}  
# =\> {"a"=\>3, "d"=\>2}

hsh['a']  
# =\> 3  
hsh['d']  
# =\> 2

Depending on how you're using the results, You could also run a second  
inject to reverse the lookup:

rhsh = hsh.inject(Hash.new { |h,k| h[k] = }) { |h,(k,v)| h[v] \<\< k ;  
h }  
# =\> {2=\>["d"], 3=\>["a"]}

(2..rhsh.keys.max).each { |i| puts "count #{i}: #{rhsh[i]}" }  
# count 2: d  
# count 3: a

If you went with this way, I guess you could forget about getting rid of  
the 1s with reject!, since you could just ignore the 1 key in the  
rhsh...

> **···**
>
> On Fri, 2006-10-13 at 00:24 +0900, Jason Burgett wrote:
> 
> > I'm basically trying to the opposite of .uniq Let's say I have an array:
> > 
> > ["a", "a", "a", "b", "c", "d", "d"]
> > 
> > I would like to boil this down by first tossing the values that only  
> > appear once. Which leaves me with:
> > 
> > ["a", "a", "a", "d", "d"]
> > 
> > Then I need to somehow determine that "a" appears 3 times and "d"  
> > appears 2 times. Any help would be great. Thanks.
> 
> --  
> Ross Bamford - rosco@roscopeco.REMOVE.co.uk

---

<div class="post-metadata">

**Author:** ![James\_Cribbs](https://avatars.discourse-cdn.com/v4/letter/j/a88e57/32.png) [@James\_Cribbs](https://rubytalk.org/u/James_Cribbs)\
**Post date:** [12 October 2006 16:22 UTC](https://rubytalk.org/t/isolating-non-unique-items-in-an-array/31829/6 "2006-10-12T16:22:06Z")

</div>

Jason Burgett wrote:

> I'm basically trying to the opposite of .uniq Let's say I have an array:
> 
> ["a", "a", "a", "b", "c", "d", "d"]
> 
> I would like to boil this down by first tossing the values that only appear once. Which leaves me with:
> 
> ["a", "a", "a", "d", "d"]
> 
> Then I need to somehow determine that "a" appears 3 times and "d" appears 2 times. Any help would be great. Thanks.

Here's what I whipped up:

letters = ['a','a','a','b','c','d','d']  
counts = {}

letters.each do |letter|  
&nbsp;&nbsp;count = letters.find\_all { |x| x == letter }.size  
&nbsp;&nbsp;counts[letter] = count if count \> 1  
end

non\_unique\_letters = letters.find\_all { |x| counts.has\_key?(x) }

p counts  
p non\_unique\_letters

Jamey

Confidentiality Notice: This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and/or privileged information. If you are not the intended recipient(s), you are hereby notified that any dissemination, unauthorized review, use, disclosure or distribution of this email and any materials contained in any attachments is prohibited. If you receive this message in error, or are not the intended recipient(s), please immediately notify the sender by email and destroy all copies of the original message, including attachments.

---

<div class="post-metadata">

**Author:** ![WATANABE\_Hirofumi1](https://avatars.discourse-cdn.com/v4/letter/w/c2a13f/32.png) [@WATANABE\_Hirofumi1](https://rubytalk.org/u/WATANABE_Hirofumi1)\
**Post date:** [12 October 2006 16:25 UTC](https://rubytalk.org/t/isolating-non-unique-items-in-an-array/31829/7 "2006-10-12T16:25:15Z")

</div>

Hi,

Jason Burgett \<jasbur@gmail.com\> writes:

> I'm basically trying to the opposite of .uniq Let's say I have an array:
> 
> ["a", "a", "a", "b", "c", "d", "d"]
> 
> I would like to boil this down by first tossing the values that only  
> appear once. Which leaves me with:
> 
> ["a", "a", "a", "d", "d"]
> 
> Then I need to somehow determine that "a" appears 3 times and "d"  
> appears 2 times. Any help would be great. Thanks.

% irb

> > a = ["a", "a", "a", "b", "c", "d", "d"]

=\> ["a", "a", "a", "b", "c", "d", "d"]

> > a.select{|i| a.grep(i).size \> 1}

=\> ["a", "a", "a", "d", "d"]

> **···**
>
> --  
> eban

---

<div class="post-metadata">

**Author:** ![Mike\_Fletcher](https://avatars.discourse-cdn.com/v4/letter/m/ba8739/32.png) [@Mike\_Fletcher](https://rubytalk.org/u/Mike_Fletcher)\
**Post date:** [12 October 2006 18:42 UTC](https://rubytalk.org/t/isolating-non-unique-items-in-an-array/31829/8 "2006-10-12T18:42:32Z")

</div>

Jason Burgett wrote:

> I'm basically trying to the opposite of .uniq Let's say I have an array:
> 
> ["a", "a", "a", "b", "c", "d", "d"]
> 
> I would like to boil this down by first tossing the values that only  
> appear once. Which leaves me with:
> 
> ["a", "a", "a", "d", "d"]
> 
> Then I need to somehow determine that "a" appears 3 times and "d"  
> appears 2 times. Any help would be great. Thanks.

a = %w( a a a b c d d )  
want\_and\_counts = a.inject( Hash.new(0) ) { |h,x| h+=1; h }.reject {

> **···**
>
> > k,v| v == 1 }
> 
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Robert\_K1](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/robert_k1/32/1830_2.png) [@Robert\_K1](https://rubytalk.org/u/Robert_K1)\
**Post date:** [13 October 2006 14:05 UTC](https://rubytalk.org/t/isolating-non-unique-items-in-an-array/31829/9 "2006-10-13T14:05:35Z")

</div>

Did anyone suggest inject + partition yet? If not:

irb(main):001:0\> a = ["a", "a", "a", "b", "c", "d", "d"]  
=\> ["a", "a", "a", "b", "c", "d", "d"]  
irb(main):002:0\> stat = a.inject(Hash.new(0)) do |h, e|  
irb(main):003:1\* h[e] += 1  
irb(main):004:1\> h  
irb(main):005:1\> end  
=\> {"a"=\>3, "b"=\>1, "c"=\>1, "d"=\>2}  
irb(main):006:0\> one, multi = stat.partition {|e,c| c == 1}  
=\> [[["b", 1], ["c", 1]], [["a", 3], ["d", 2]]]  
irb(main):007:0\> one  
=\> [["b", 1], ["c", 1]]  
irb(main):008:0\> multi  
=\> [["a", 3], ["d", 2]]  
irb(main):009:0\> one.map! {|e,c| e}  
=\> ["b", "c"]

Kind regards

&nbsp;&nbsp;robert

> **···**
>
> On 12.10.2006 17:24, Jason Burgett wrote:
> 
> > I'm basically trying to the opposite of .uniq Let's say I have an array:
> > 
> > ["a", "a", "a", "b", "c", "d", "d"]
> > 
> > I would like to boil this down by first tossing the values that only appear once. Which leaves me with:
> > 
> > ["a", "a", "a", "d", "d"]
> > 
> > Then I need to somehow determine that "a" appears 3 times and "d" appears 2 times. Any help would be great. Thanks.

---

<div class="post-metadata">

**Author:** ![Alex\_Young](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@Alex\_Young](https://rubytalk.org/u/Alex_Young)\
**Post date:** [12 October 2006 15:52 UTC](https://rubytalk.org/t/isolating-non-unique-items-in-an-array/31829/10 "2006-10-12T15:52:19Z")

</div>

Tim Pease wrote:

> > I'm basically trying to the opposite of .uniq Let's say I have an array:
> > 
> > ["a", "a", "a", "b", "c", "d", "d"]
> > 
> > I would like to boil this down by first tossing the values that only  
> > appear once. Which leaves me with:
> > 
> > ["a", "a", "a", "d", "d"]
> > 
> > Then I need to somehow determine that "a" appears 3 times and "d"  
> > appears 2 times. Any help would be great. Thanks.
> > 
> > --  
> > Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).
> 
> class Array  
> def count( item )  
> &nbsp;&nbsp;&nbsp;return 0 unless self.include? item
> 
> &nbsp;&nbsp;&nbsp;c = 0  
> &nbsp;&nbsp;&nbsp;self.each {|i| c += 1 if i == item}  
> &nbsp;&nbsp;&nbsp;return c  
> end  
> end
> 
> ary = %w(a a a b c d d)  
> new\_ary = ary.select {|item| ary.count(item) \> 1}

Better:

class Array  
&nbsp;&nbsp;&nbsp;def counts # could be golfed, but clarity is king  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result = Hash.new{0}  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.each {|a| result[a] += 1}  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result  
&nbsp;&nbsp;&nbsp;end  
end

a = ["a", "a", "a", "b", "c", "d", "d"]  
c = a.counts  
a.reject{|b| c[b] == 1} # =\> ["a", "a", "a", "d", "d"]

> **···**
>
> > On 10/12/06, Jason Burgett \<jasbur@gmail.com\> wrote:
> 
> --  
> Alex

---

<div class="post-metadata">

**Author:** ![Jeff\_Schwab](https://avatars.discourse-cdn.com/v4/letter/j/b5ac83/32.png) [@Jeff\_Schwab](https://rubytalk.org/u/Jeff_Schwab)\
**Post date:** [12 October 2006 16:00 UTC](https://rubytalk.org/t/isolating-non-unique-items-in-an-array/31829/11 "2006-10-12T16:00:14Z")

</div>

Jeffrey Schwab wrote:

> Jason Burgett wrote:
> 
> > I'm basically trying to the opposite of .uniq Let's say I have an array:
> > 
> > ["a", "a", "a", "b", "c", "d", "d"]
> > 
> > I would like to boil this down by first tossing the values that only appear once. Which leaves me with:
> > 
> > ["a", "a", "a", "d", "d"]
> > 
> > Then I need to somehow determine that "a" appears 3 times and "d" appears 2 times. Any help would be great. Thanks.
> 
> # Output:  
> # ["a", "a", "a", "d", "d"]  
> # {"a"=\>3, "d"=\>2}
> 
> def get\_counts(keys)  
> &nbsp;&nbsp;&nbsp;&nbsp;counts = Hash.new(0)  
> &nbsp;&nbsp;&nbsp;&nbsp;keys.each {|k| counts[k] += 1 }  
> &nbsp;&nbsp;&nbsp;&nbsp;counts  
> end
> 
> def non\_uniq(elements)  
> &nbsp;&nbsp;&nbsp;&nbsp;counts = get\_counts(elements)  
> &nbsp;&nbsp;&nbsp;&nbsp;counts.delete\_if {|k, v| v \< 2 }  
> &nbsp;&nbsp;&nbsp;&nbsp;elements.select {|e| counts.key?(e) }  
> end

# Better:  
def non\_uniq(elements)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;counts = get\_counts(elements)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elements.select {|e| counts[e] \> 1 }  
end

> **···**
>
> > elements = ["a", "a", "a", "b", "c", "d", "d"]
> > 
> > p non\_uniq(elements)  
> > p get\_counts(elements).delete\_if {|k, v| v \< 2 }

---

<div class="post-metadata">

**Author:** ![Drew\_Olson](https://avatars.discourse-cdn.com/v4/letter/d/c67d28/32.png) [@Drew\_Olson](https://rubytalk.org/u/Drew_Olson)\
**Post date:** [12 October 2006 16:05 UTC](https://rubytalk.org/t/isolating-non-unique-items-in-an-array/31829/12 "2006-10-12T16:05:09Z")

</div>

Drew Olson wrote:

> Jason Burgett wrote:
> 
> > I'm basically trying to the opposite of .uniq Let's say I have an array:
> > 
> > ["a", "a", "a", "b", "c", "d", "d"]
> > 
> > I would like to boil this down by first tossing the values that only  
> > appear once. Which leaves me with:
> > 
> > ["a", "a", "a", "d", "d"]
> > 
> > Then I need to somehow determine that "a" appears 3 times and "d"  
> > appears 2 times. Any help would be great. Thanks
> 
> This should work:
> 
> a = ["a", "a", "a", "b", "c", "d", "d"]  
> a.uniq.map{|i| i if (a.map{|j| j if j==i}.length \> 1)}

Actually, so that you have them appear more than once you'd need to do:

a = ["a", "a", "a", "b", "c", "d", "d"]  
a.map{|i| i if (a.map{|j| j if j==i}.length \> 1)}

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Drew\_Olson](https://avatars.discourse-cdn.com/v4/letter/d/c67d28/32.png) [@Drew\_Olson](https://rubytalk.org/u/Drew_Olson)\
**Post date:** [12 October 2006 16:28 UTC](https://rubytalk.org/t/isolating-non-unique-items-in-an-array/31829/13 "2006-10-12T16:28:19Z")

</div>

Tested, and it doesn't work, so scratch that...

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Gavin\_Kistner2](https://avatars.discourse-cdn.com/v4/letter/g/b9e5f3/32.png) [@Gavin\_Kistner2](https://rubytalk.org/u/Gavin_Kistner2)\
**Post date:** [12 October 2006 19:35 UTC](https://rubytalk.org/t/isolating-non-unique-items-in-an-array/31829/14 "2006-10-12T19:35:20Z")

</div>

WATANABE Hirofumi wrote:

> Jason Burgett \<jasbur@gmail.com\> writes:  
> \> ["a", "a", "a", "d", "d"]  
> \>  
> \> Then I need to somehow determine that "a" appears 3 times and "d"  
> \> appears 2 times. Any help would be great. Thanks.
> 
> % irb  
> \>\> a = ["a", "a", "a", "b", "c", "d", "d"]  
> =\> ["a", "a", "a", "b", "c", "d", "d"]  
> \>\> a.select{|i| a.grep(i).size \> 1}  
> =\> ["a", "a", "a", "d", "d"]

Taking that one step further to meet his second need:

class Array  
&nbsp;&nbsp;def duplicates\_count  
&nbsp;&nbsp;&nbsp;&nbsp;uniq.map{ |e|  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ( count = grep(e).size ) \> 1  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ e =\> count }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end  
&nbsp;&nbsp;&nbsp;&nbsp;}.compact  
&nbsp;&nbsp;end  
end

a = ["a", "a", "a", "b", "c", "d", "d"]  
p a.duplicates\_count  
#=\> [{"a"=\>3}, {"d"=\>2}]

---

<div class="post-metadata">

**Author:** ![Roseanne\_Zhang](https://avatars.discourse-cdn.com/v4/letter/r/f07891/32.png) [@Roseanne\_Zhang](https://rubytalk.org/u/Roseanne_Zhang)\
**Post date:** [12 October 2006 19:16 UTC](https://rubytalk.org/t/isolating-non-unique-items-in-an-array/31829/15 "2006-10-12T19:16:12Z")

</div>

a = ["a", "a", "a", "b", "c", "d", "d"]  
puts a.uniq

Try it, it works!

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Ara.T.Howard6](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@Ara.T.Howard6](https://rubytalk.org/u/Ara.T.Howard6)\
**Post date:** [12 October 2006 20:53 UTC](https://rubytalk.org/t/isolating-non-unique-items-in-an-array/31829/16 "2006-10-12T20:53:27Z")

</div>

that's O(n^2) though... the others are O(n)

-a

> **···**
>
> On Fri, 13 Oct 2006, Phrogz wrote:
> 
> > WATANABE Hirofumi wrote:
> > 
> > > Jason Burgett \<jasbur@gmail.com\> writes:
> > > 
> > > > ["a", "a", "a", "d", "d"]
> > > > 
> > > > Then I need to somehow determine that "a" appears 3 times and "d"  
> > > > appears 2 times. Any help would be great. Thanks.
> > > 
> > > % irb
> > > 
> > > > > a = ["a", "a", "a", "b", "c", "d", "d"]
> > > 
> > > =\> ["a", "a", "a", "b", "c", "d", "d"]
> > > 
> > > > > a.select{|i| a.grep(i).size \> 1}
> > > 
> > > =\> ["a", "a", "a", "d", "d"]
> > 
> > Taking that one step further to meet his second need:
> > 
> > class Array  
> > def duplicates\_count  
> > &nbsp;&nbsp;&nbsp;uniq.map{ |e|  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ( count = grep(e).size ) \> 1  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ e =\> count }  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end  
> > &nbsp;&nbsp;&nbsp;}.compact  
> > end  
> > end
> > 
> > a = ["a", "a", "a", "b", "c", "d", "d"]  
> > p a.duplicates\_count  
> > #=\> [{"a"=\>3}, {"d"=\>2}]
> 
> --  
> my religion is very simple. my religion is kindness. -- the dalai lama
