Code issue to count recurring letters in a word

Hi,

My scenario is : The bot needs to read all the letters in a word and return the number of times each letter appears in the word. e.g., If the word is Alankrita singh. The output should be A - 3, L - 1, N - 2, K - 1, R -1, I - 2, T - 1, S - 1, G - 1, H - 1. The code should be dynamic. It should be able to perform this operation on any word. Please suggest how can i do this ?

Thanks.

Hi,

How about the following?

Sequence1.xaml (6.8 KB)

Regards,

4 Likes

yes. this is working. :slight_smile: Can you explain me the function that you have use. How it is working in this case?

Hi,

Can you explain me the function that you have use. How it is working in this case?

yourString.Distinct() returns list of non-duplicated items. in this case it’s {"A","B","C","D"}
Next, ToDictionary method returns dictionary which has the following key and value.
Key: Function(c) c returns each item of the above list, like "A","B","C"....
Value: yourString.Count(Function(s) s=c) returns count of characters which match each item and characters of yourString variable, like Count "A" in "ABCDABCA" , Count "B" in "ABCDABCA"

Regards,

1 Like

Thank you for explaining. Are all these .net functions?

Hi,

Yes. They are .net methods.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.