[Tutor] question on array Operation

Alan Gauld alan.gauld at btinternet.com
Wed Oct 29 18:29:12 CET 2014


On 29/10/14 16:08, jarod_v6 at libero.it wrote:

> I have a long matrix where I have the samples (1to n) and then I have
> (1to j )elements.
> I would like to count how many times  each j element are present on each
> samples.

That probably makes sense to you but it doesn't to me.
Lets assuyme you have n=10 and j=5.
That would suggest you have a 10x5 matrix of values?

Now what do you mean by 'each j' element? The last one in the row?

So for this small example:

1,2,3,4,5,   -> count = 1 - there is only one 5
1,2,1,2,1,   -> count = 3 - there are 3 ones
A,3,B,2,A    -> count = 2 - there are 2 As

Is that what you want?

> So the question is which is the best algoritm for obtain the results.
> The result I want is a table like that.
>
> A,B,D,E,F
> AA,1,0,1,0
> BB1,1,1,1
> CC0,0,1,0
> DD01,0,1,0

That doesn';t senm to match your description above. You will
need to show us both input and output data before we can
understand the transformation you are looking for.

> Do you have any suggestion on how to do this?

Not until I understand what you want.


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos



More information about the Tutor mailing list