Array slicing

given an array

anArray = [["a", 1, 1], ["b", 1, 2], ["c", 1, 5], ["z", 1, 1], ["e", 1, 5], ["f", 1, 6], ["g", 1, 1], ["h", 1, 3], ["i", 1, 1], ["j", 1, 2], ["k", 1, 1], ["y", 1, 6], ["m", 1, 1], ["u", 1, 2], ["v", 1, 1], ["p", 1, 4], ["q", 1, 5], ["r", 1, 1], ["n", 1, 1], ["t", 2, 3], ["s", 2, 2], ["o", 2, 1], ["w", 2, 1], ["x", 2, 1], ["l", 2, 1], ["d", 2, 1]]

I would like to get it sliced in groups of element having the same 2nd and 3rd values

sliced_array = [
[ ["a", 1, 1],["g", 1, 1], ["i", 1, 1], ["k", 1, 1], ["m", 1, 1], ["n", 1, 1],["r", 1, 1],["v", 1, 1],["z", 1, 1] ],
[ ["b", 1, 2],["j", 1, 2], ["u", 1, 2] ],
[ ["c", 1, 5],["e", 1, 5],["q", 1, 5] ],
[ ["d", 2, 1],["l", 2, 1], ["l", 2, 1], ["o", 2, 1],["w", 2, 1],["x", 2, 1] ],
[ ["f", 1, 6],["y", 1, 6] ],
[ ["h", 1, 3] ],
[ ["p", 1, 4] ],
[ ["s", 2, 2] ],
[ ["t", 2, 3] ]
]

I believe teh first step is to sort anArray.... then slicing similar groups, but writing
anArray.sort {|a,b| a[1] <=> b[1]}
sorts only on first value... how can I sort on both.. ?

thansk

joss

# anArray.sort {|a,b| a[1] <=> b[1]}
# sorts only on first value... how can I sort on both.. ?

try sort_by

irb(main):020:0> a=[["a", 3, 3], ["c", 1, 5], ["b", 1, 2],["d",3,1]]
=> [["a", 3, 3], ["c", 1, 5], ["b", 1, 2], ["d", 3, 1]]
irb(main):021:0> a.sort_by {|x| [x[1],x[2]]}
=> [["b", 1, 2], ["c", 1, 5], ["d", 3, 1], ["a", 3, 3]]

···

from: Josselin [mailto:josselin@wanadoo.fr] :

Try this

p anArray.sort {|a,b| a.slice(1..2) <=> b.slice(1..2)}

Harry

···

On 5/3/07, Josselin <josselin@wanadoo.fr> wrote:

given an array

anArray = [["a", 1, 1], ["b", 1, 2], ["c", 1, 5], ["z", 1, 1], ["e", 1,
5], ["f", 1, 6], ["g", 1, 1], ["h", 1, 3], ["i", 1, 1], ["j", 1, 2],
["k", 1, 1], ["y", 1, 6], ["m", 1, 1], ["u", 1, 2], ["v", 1, 1], ["p",
1, 4], ["q", 1, 5], ["r", 1, 1], ["n", 1, 1], ["t", 2, 3], ["s", 2, 2],
["o", 2, 1], ["w", 2, 1], ["x", 2, 1], ["l", 2, 1], ["d", 2, 1]]

I would like to get it sliced in groups of element having the same 2nd
and 3rd values

sliced_array = [
[ ["a", 1, 1],["g", 1, 1], ["i", 1, 1], ["k", 1, 1], ["m", 1, 1], ["n",
1, 1],["r", 1, 1],["v", 1, 1],["z", 1, 1] ],
[ ["b", 1, 2],["j", 1, 2], ["u", 1, 2] ],
[ ["c", 1, 5],["e", 1, 5],["q", 1, 5] ],
[ ["d", 2, 1],["l", 2, 1], ["l", 2, 1], ["o", 2, 1],["w", 2, 1],["x", 2, 1] ],
[ ["f", 1, 6],["y", 1, 6] ],
[ ["h", 1, 3] ],
[ ["p", 1, 4] ],
[ ["s", 2, 2] ],
[ ["t", 2, 3] ]
]

I believe teh first step is to sort anArray.... then slicing similar
groups, but writing
anArray.sort {|a,b| a[1] <=> b[1]}
sorts only on first value... how can I sort on both.. ?

thansk

joss

--

A Look into Japanese Ruby List in English

found the sort... but how to slice it now ?
anArray.sort_by {|item| [item[1], item[2] ] }
=> [["a", 1, 1], ["z", 1, 1], ["v", 1, 1], ["r", 1, 1], ["i", 1, 1], ["m", 1, 1], ["g", 1, 1], ["k", 1, 1], ["n", 1, 1], ["j", 1, 2], ["u", 1, 2], ["b", 1, 2], ["h", 1, 3], ["p", 1, 4], ["c", 1, 5], ["e", 1, 5], ["q", 1, 5], ["f", 1, 6], ["y", 1, 6], ["l", 2, 1], ["x", 2, 1], ["o", 2, 1], ["w", 2, 1], ["d", 2, 1], ["s", 2, 2], ["t", 2, 3]]

["a", 1, 1], ["z", 1, 1], ["v", 1, 1], ["r", 1, 1], ["i", 1, 1], ["m", 1, 1], ["g", 1, 1], ["k", 1, 1]
["j", 1, 2], ["u", 1, 2], ["b", 1, 2]
and so on....

??? thanks
joss

···

On 2007-05-03 14:06:44 +0200, Josselin <josselin@wanadoo.fr> said:

given an array

anArray = [["a", 1, 1], ["b", 1, 2], ["c", 1, 5], ["z", 1, 1], ["e", 1, 5], ["f", 1, 6], ["g", 1, 1], ["h", 1, 3], ["i", 1, 1], ["j", 1, 2], ["k", 1, 1], ["y", 1, 6], ["m", 1, 1], ["u", 1, 2], ["v", 1, 1], ["p", 1, 4], ["q", 1, 5], ["r", 1, 1], ["n", 1, 1], ["t", 2, 3], ["s", 2, 2], ["o", 2, 1], ["w", 2, 1], ["x", 2, 1], ["l", 2, 1], ["d", 2, 1]]

I would like to get it sliced in groups of element having the same 2nd and 3rd values

sliced_array = [
[ ["a", 1, 1],["g", 1, 1], ["i", 1, 1], ["k", 1, 1], ["m", 1, 1], ["n", 1, 1],["r", 1, 1],["v", 1, 1],["z", 1, 1] ],
[ ["b", 1, 2],["j", 1, 2], ["u", 1, 2] ],
[ ["c", 1, 5],["e", 1, 5],["q", 1, 5] ],
[ ["d", 2, 1],["l", 2, 1], ["l", 2, 1], ["o", 2, 1],["w", 2, 1],["x", 2, 1] ],
[ ["f", 1, 6],["y", 1, 6] ],
[ ["h", 1, 3] ],
[ ["p", 1, 4] ],
[ ["s", 2, 2] ],
[ ["t", 2, 3] ]
]

I believe teh first step is to sort anArray.... then slicing similar groups, but writing
anArray.sort {|a,b| a[1] <=> b[1]}
sorts only on first value... how can I sort on both.. ?

thansk

joss

given an array

anArray = [["a", 1, 1], ["b", 1, 2], ["c", 1, 5], ["z", 1, 1], ["e", 1,
5], ["f", 1, 6], ["g", 1, 1], ["h", 1, 3], ["i", 1, 1], ["j", 1, 2],
["k", 1, 1], ["y", 1, 6], ["m", 1, 1], ["u", 1, 2], ["v", 1, 1], ["p",
1, 4], ["q", 1, 5], ["r", 1, 1], ["n", 1, 1], ["t", 2, 3], ["s", 2, 2],
["o", 2, 1], ["w", 2, 1], ["x", 2, 1], ["l", 2, 1], ["d", 2, 1]]

I would like to get it sliced in groups of element having the same 2nd
and 3rd values

sliced_array = [
[ ["a", 1, 1],["g", 1, 1], ["i", 1, 1], ["k", 1, 1], ["m", 1, 1], ["n",
1, 1],["r", 1, 1],["v", 1, 1],["z", 1, 1] ],
[ ["b", 1, 2],["j", 1, 2], ["u", 1, 2] ],
[ ["c", 1, 5],["e", 1, 5],["q", 1, 5] ],
[ ["d", 2, 1],["l", 2, 1], ["l", 2, 1], ["o", 2, 1],["w", 2, 1],["x", 2, 1] ],
[ ["f", 1, 6],["y", 1, 6] ],
[ ["h", 1, 3] ],
[ ["p", 1, 4] ],
[ ["s", 2, 2] ],
[ ["t", 2, 3] ]
]

Applying a trick I learned today:

anArray.inject( Hash.new{ |hash, key| hash[key] = } ){ |hash,
subarray> hash[subarray[1, 2]] << subarray; hash }.values

Or if you need a sorted result:

anArray.inject( Hash.new{ |hash, key| hash[key] = } ){ |hash,
subarray> hash[subarray[1, 2]] << subarray; hash }.values.sort_by{

subarray> subarray[0][1,2] }

Best regards,
Raf

···

2007/5/3, Josselin <josselin@wanadoo.fr>:

a lot of tricks .. good ruby day !

···

On 2007-05-03 14:06:44 +0200, Josselin <josselin@wanadoo.fr> said:

given an array

anArray = [["a", 1, 1], ["b", 1, 2], ["c", 1, 5], ["z", 1, 1], ["e", 1, 5], ["f", 1, 6], ["g", 1, 1], ["h", 1, 3], ["i", 1, 1], ["j", 1, 2], ["k", 1, 1], ["y", 1, 6], ["m", 1, 1], ["u", 1, 2], ["v", 1, 1], ["p", 1, 4], ["q", 1, 5], ["r", 1, 1], ["n", 1, 1], ["t", 2, 3], ["s", 2, 2], ["o", 2, 1], ["w", 2, 1], ["x", 2, 1], ["l", 2, 1], ["d", 2, 1]]

I would like to get it sliced in groups of element having the same 2nd and 3rd values

sliced_array = [
[ ["a", 1, 1],["g", 1, 1], ["i", 1, 1], ["k", 1, 1], ["m", 1, 1], ["n", 1, 1],["r", 1, 1],["v", 1, 1],["z", 1, 1] ],
[ ["b", 1, 2],["j", 1, 2], ["u", 1, 2] ],
[ ["c", 1, 5],["e", 1, 5],["q", 1, 5] ],
[ ["d", 2, 1],["l", 2, 1], ["l", 2, 1], ["o", 2, 1],["w", 2, 1],["x", 2, 1] ],
[ ["f", 1, 6],["y", 1, 6] ],
[ ["h", 1, 3] ],
[ ["p", 1, 4] ],
[ ["s", 2, 2] ],
[ ["t", 2, 3] ]
]

I believe teh first step is to sort anArray.... then slicing similar groups, but writing
anArray.sort {|a,b| a[1] <=> b[1]}
sorts only on first value... how can I sort on both.. ?

thansk

joss

Or this :slight_smile:

p anArray.sort_by {|x| [x[1],x[2],x[0]]}

Harry

···

On 5/3/07, Peña, Botp <botp@delmonte-phil.com> wrote:

from: Josselin [mailto:josselin@wanadoo.fr] :
# anArray.sort {|a,b| a[1] <=> b[1]}
# sorts only on first value... how can I sort on both.. ?

try sort_by

irb(main):020:0> a=[["a", 3, 3], ["c", 1, 5], ["b", 1, 2],["d",3,1]]
=> [["a", 3, 3], ["c", 1, 5], ["b", 1, 2], ["d", 3, 1]]
irb(main):021:0> a.sort_by {|x| [x[1],x[2]]}
=> [["b", 1, 2], ["c", 1, 5], ["d", 3, 1], ["a", 3, 3]]

--

A Look into Japanese Ruby List in English

Thanks for sort_by.
I didn't know that.

Harry

···

On 5/3/07, Peña, Botp <botp@delmonte-phil.com> wrote:

from: Josselin [mailto:josselin@wanadoo.fr] :
# anArray.sort {|a,b| a[1] <=> b[1]}
# sorts only on first value... how can I sort on both.. ?

try sort_by

irb(main):020:0> a=[["a", 3, 3], ["c", 1, 5], ["b", 1, 2],["d",3,1]]
=> [["a", 3, 3], ["c", 1, 5], ["b", 1, 2], ["d", 3, 1]]
irb(main):021:0> a.sort_by {|x| [x[1],x[2]]}
=> [["b", 1, 2], ["c", 1, 5], ["d", 3, 1], ["a", 3, 3]]

--

A Look into Japanese Ruby List in English

found a reply from ... (thanks to him...)

module Enumerable
  def partition_by
    r = Hash.new{ |h,k| h[k]= }
    each do |e|
      r[ yield(e) ] << e
    end
    return r
  end
end

And then :

require 'enumerator'
sArray = anArray.sort_by {|item| [item[1], item[2] ] }

sArray.partition_by {|ary| ary[1..2]}.to_enum(:each_value).to_a=> [[["j", 1, 2], ["u", 1, 2], ["b", 1, 2]], [["l", 2, 1], ["x", 2, 1], ["o", 2, 1], ["w", 2, 1], ["d", 2, 1]], [["a", 1, 1], ["z", 1, 1], ["v", 1, 1], ["r", 1, 1], ["i", 1, 1], ["m", 1, 1], ["g", 1, 1], ["k", 1, 1], ["n", 1, 1]], [["f", 1, 6], ["y", 1, 6]], [["t", 2, 3]], [["c", 1, 5], ["e", 1, 5], ["q", 1, 5]], [["s", 2, 2]], [["p", 1, 4]], [["h", 1, 3]]]

and that's it.....

···

On 2007-05-03 14:14:31 +0200, Josselin <josselin@wanadoo.fr> said:

On 2007-05-03 14:06:44 +0200, Josselin <josselin@wanadoo.fr> said:

given an array

anArray = [["a", 1, 1], ["b", 1, 2], ["c", 1, 5], ["z", 1, 1], ["e", 1, 5], ["f", 1, 6], ["g", 1, 1], ["h", 1, 3], ["i", 1, 1], ["j", 1, 2], ["k", 1, 1], ["y", 1, 6], ["m", 1, 1], ["u", 1, 2], ["v", 1, 1], ["p", 1, 4], ["q", 1, 5], ["r", 1, 1], ["n", 1, 1], ["t", 2, 3], ["s", 2, 2], ["o", 2, 1], ["w", 2, 1], ["x", 2, 1], ["l", 2, 1], ["d", 2, 1]]

I would like to get it sliced in groups of element having the same 2nd and 3rd values

sliced_array = [
[ ["a", 1, 1],["g", 1, 1], ["i", 1, 1], ["k", 1, 1], ["m", 1, 1], ["n", 1, 1],["r", 1, 1],["v", 1, 1],["z", 1, 1] ],
[ ["b", 1, 2],["j", 1, 2], ["u", 1, 2] ],
[ ["c", 1, 5],["e", 1, 5],["q", 1, 5] ],
[ ["d", 2, 1],["l", 2, 1], ["l", 2, 1], ["o", 2, 1],["w", 2, 1],["x", 2, 1] ],
[ ["f", 1, 6],["y", 1, 6] ],
[ ["h", 1, 3] ],
[ ["p", 1, 4] ],
[ ["s", 2, 2] ],
[ ["t", 2, 3] ]
]

I believe teh first step is to sort anArray.... then slicing similar groups, but writing
anArray.sort {|a,b| a[1] <=> b[1]}
sorts only on first value... how can I sort on both.. ?

thansk

joss

found the sort... but how to slice it now ?
anArray.sort_by {|item| [item[1], item[2] ] }
=> [["a", 1, 1], ["z", 1, 1], ["v", 1, 1], ["r", 1, 1], ["i", 1, 1], ["m", 1, 1], ["g", 1, 1], ["k", 1, 1], ["n", 1, 1], ["j", 1, 2], ["u", 1, 2], ["b", 1, 2], ["h", 1, 3], ["p", 1, 4], ["c", 1, 5], ["e", 1, 5], ["q", 1, 5], ["f", 1, 6], ["y", 1, 6], ["l", 2, 1], ["x", 2, 1], ["o", 2, 1], ["w", 2, 1], ["d", 2, 1], ["s", 2, 2], ["t", 2, 3]]

["a", 1, 1], ["z", 1, 1], ["v", 1, 1], ["r", 1, 1], ["i", 1, 1], ["m", 1, 1], ["g", 1, 1], ["k", 1, 1]
["j", 1, 2], ["u", 1, 2], ["b", 1, 2]
and so on....

??? thanks
joss

good to know , what about the partition_by , it seems simple ?

module Enumerable
  def partition_by
    r = Hash.new{ |h,k| h[k]= }
    each do |e|
      r[ yield(e) ] << e
    end
    return r
  end
end

And then :

require 'enumerator'
sArray = anArray.sort_by {|item| [item[1], item[2] ] }

sArray.partition_by {|ary| ary[1..2]}.to_enum(:each_value).to_a=> [[["j", 1, 2], ["u", 1, 2], ["b", 1, 2]], [["l", 2, 1], ["x", 2, 1], ["o", 2, 1], ["w", 2, 1], ["d", 2, 1]], [["a", 1, 1], ["z", 1, 1], ["v", 1, 1], ["r", 1, 1], ["i", 1, 1], ["m", 1, 1], ["g", 1, 1], ["k", 1, 1], ["n", 1, 1]], [["f", 1, 6], ["y", 1, 6]], [["t", 2, 3]], [["c", 1, 5], ["e", 1, 5], ["q", 1, 5]], [["s", 2, 2]], [["p", 1, 4]], [["h", 1, 3]]]

and that's it.....

···

On 2007-05-03 17:38:57 +0200, "Raf Coremans" <rrafje@gmail.com> said:

2007/5/3, Josselin <josselin@wanadoo.fr>:

given an array

anArray = [["a", 1, 1], ["b", 1, 2], ["c", 1, 5], ["z", 1, 1], ["e", 1,
5], ["f", 1, 6], ["g", 1, 1], ["h", 1, 3], ["i", 1, 1], ["j", 1, 2],
["k", 1, 1], ["y", 1, 6], ["m", 1, 1], ["u", 1, 2], ["v", 1, 1], ["p",
1, 4], ["q", 1, 5], ["r", 1, 1], ["n", 1, 1], ["t", 2, 3], ["s", 2, 2],
["o", 2, 1], ["w", 2, 1], ["x", 2, 1], ["l", 2, 1], ["d", 2, 1]]

I would like to get it sliced in groups of element having the same 2nd
and 3rd values

sliced_array = [
[ ["a", 1, 1],["g", 1, 1], ["i", 1, 1], ["k", 1, 1], ["m", 1, 1], ["n",
1, 1],["r", 1, 1],["v", 1, 1],["z", 1, 1] ],
[ ["b", 1, 2],["j", 1, 2], ["u", 1, 2] ],
[ ["c", 1, 5],["e", 1, 5],["q", 1, 5] ],
[ ["d", 2, 1],["l", 2, 1], ["l", 2, 1], ["o", 2, 1],["w", 2, 1],["x", 2, 1] ],
[ ["f", 1, 6],["y", 1, 6] ],
[ ["h", 1, 3] ],
[ ["p", 1, 4] ],
[ ["s", 2, 2] ],
[ ["t", 2, 3] ]
]

Applying a trick I learned today:

anArray.inject( Hash.new{ |hash, key| hash[key] = } ){ |hash,
subarray> hash[subarray[1, 2]] << subarray; hash }.values

Or if you need a sorted result:

anArray.inject( Hash.new{ |hash, key| hash[key] = } ){ |hash,
subarray> hash[subarray[1, 2]] << subarray; hash }.values.sort_by{
>subarray> subarray[0][1,2] }

Best regards,
Raf

Harry Kakueki wrote:

···

On 5/3/07, Pe�a, Botp <botp@delmonte-phil.com> wrote:

Thanks for sort_by.
I didn't know that.

Harry

Just using sort won't get the results into nested arrays based on the
groupings. For this, you need group_by:

anArray.group_by { |a| a[1..2] }.sort.transpose[1]

--
Posted via http://www.ruby-forum.com/\.

Yes. I think it could be improved though:

module Enumerable
def partition_by
   inject( Hash.new{ |h,k| h[k]= } ){ |h, e| h[ yield( e)] << e; h }.values
end
end

p anArray.partition_by { |e| e[1, 2] } =>
[[["b", 1, 2], ["j", 1, 2], ["u", 1, 2]], [["o", 2, 1], ["w", 2, 1],
["x", 2, 1], ["l", 2, 1], ["d", 2, 1]], [["a", 1, 1], ["z", 1, 1],
["g", 1, 1], ["i", 1, 1], ["k", 1, 1], ["m", 1, 1], ["v", 1, 1], ["r",
1, 1], ["n", 1, 1]], [["f", 1, 6], ["y", 1, 6]], [["t", 2, 3]], [["c",
1, 5], ["e", 1, 5], ["q", 1, 5]], [["s", 2, 2]], [["p", 1, 4]], [["h",
1, 3]]]

Or if you want it sorted:
p anArray.sort.partition_by{ |subarray| subarray[1, 2] }.sort_by{ |e|
e[0][1,2] } => [[["a", 1, 1], ["g", 1, 1], ["i", 1, 1], ["k", 1, 1],
["m", 1, 1], ["n", 1, 1], ["r", 1, 1], ["v", 1, 1], ["z", 1, 1]],
[["b", 1, 2], ["j", 1, 2], ["u", 1, 2]], [["h", 1, 3]], [["p", 1, 4]],
[["c", 1, 5], ["e", 1, 5], ["q", 1, 5]], [["f", 1, 6], ["y", 1, 6]],
[["d", 2, 1], ["l", 2, 1], ["o", 2, 1], ["w", 2, 1], ["x", 2, 1]],
[["s", 2, 2]], [["t", 2, 3]]]

Regards,
Raf

···

2007/5/3, Josselin <josselin@wanadoo.fr>:

On 2007-05-03 17:38:57 +0200, "Raf Coremans" <rrafje@gmail.com> said:

> 2007/5/3, Josselin <josselin@wanadoo.fr>:
>> given an array
>>
>> anArray = [["a", 1, 1], ["b", 1, 2], ["c", 1, 5], ["z", 1, 1], ["e", 1,
>> 5], ["f", 1, 6], ["g", 1, 1], ["h", 1, 3], ["i", 1, 1], ["j", 1, 2],
>> ["k", 1, 1], ["y", 1, 6], ["m", 1, 1], ["u", 1, 2], ["v", 1, 1], ["p",
>> 1, 4], ["q", 1, 5], ["r", 1, 1], ["n", 1, 1], ["t", 2, 3], ["s", 2, 2],
>> ["o", 2, 1], ["w", 2, 1], ["x", 2, 1], ["l", 2, 1], ["d", 2, 1]]
>>
>> I would like to get it sliced in groups of element having the same 2nd
>> and 3rd values
>>
>> sliced_array = [
>> [ ["a", 1, 1],["g", 1, 1], ["i", 1, 1], ["k", 1, 1], ["m", 1, 1], ["n",
>> 1, 1],["r", 1, 1],["v", 1, 1],["z", 1, 1] ],
>> [ ["b", 1, 2],["j", 1, 2], ["u", 1, 2] ],
>> [ ["c", 1, 5],["e", 1, 5],["q", 1, 5] ],
>> [ ["d", 2, 1],["l", 2, 1], ["l", 2, 1], ["o", 2, 1],["w", 2, 1],["x", 2, 1] ],
>> [ ["f", 1, 6],["y", 1, 6] ],
>> [ ["h", 1, 3] ],
>> [ ["p", 1, 4] ],
>> [ ["s", 2, 2] ],
>> [ ["t", 2, 3] ]
>> ]
>
> Applying a trick I learned today:
>
> anArray.inject( Hash.new{ |hash, key| hash[key] = } ){ |hash,
> subarray> hash[subarray[1, 2]] << subarray; hash }.values
>
> Or if you need a sorted result:
>
> anArray.inject( Hash.new{ |hash, key| hash[key] = } ){ |hash,
> subarray> hash[subarray[1, 2]] << subarray; hash }.values.sort_by{
> >subarray> subarray[0][1,2] }
>
> Best regards,
> Raf

good to know , what about the partition_by , it seems simple ?

module Enumerable
  def partition_by
    r = Hash.new{ |h,k| h[k]= }
    each do |e|
      r[ yield(e) ] << e
    end
    return r
  end
end

And then :

require 'enumerator'
sArray = anArray.sort_by {|item| [item[1], item[2] ] }

sArray.partition_by {|ary| ary[1..2]}.to_enum(:each_value).to_a=>
[[["j", 1, 2], ["u", 1, 2], ["b", 1, 2]], [["l", 2, 1], ["x", 2, 1],
["o", 2, 1], ["w", 2, 1], ["d", 2, 1]], [["a", 1, 1], ["z", 1, 1],
["v", 1, 1], ["r", 1, 1], ["i", 1, 1], ["m", 1, 1], ["g", 1, 1], ["k",
1, 1], ["n", 1, 1]], [["f", 1, 6], ["y", 1, 6]], [["t", 2, 3]], [["c",
1, 5], ["e", 1, 5], ["q", 1, 5]], [["s", 2, 2]], [["p", 1, 4]], [["h",
1, 3]]]

and that's it.....