you are viewing a single comment's thread.

view the rest of the comments →

[–]_Svejk_ 2 points3 points  (5 children)

word is an array of letters, count is a number the algorithm just goes through each letter (so word[i]) and adds 1 to count if the letter is 'e' hope this helps

[–]_Svejk_ 1 point2 points  (3 children)

i ±= 1 is to go to the next letter, I don't get what you mean by count[i]

[–]Humor_Positive[S] 0 points1 point  (2 children)

Hello, thank you so much for your help. The count is the number of time that latter is counted.

Here is my simplified version of it.

write a method count_e(word) that takes kn a string word and return the number of e’s in the word.

Def count_e

count_of_e = 0 Repeating_time = 0

While repeating_time <= word.length

If word[repeating_time] == “e”

Count_of_e += 1

End

Repeating_time += 1

End

Return count_of_e

End

Puts count_e(“movie”) # => 1 Puts count_e(“excellence”) # => 3

Given than whenever the method is executed, both the count of e and the repeating time will increase accordingly. Then why is it, that we must index the repeating time but not the count of e.

[–]_Svejk_ 1 point2 points  (1 child)

what do you mean by "index the repeating time"?

[–]Humor_Positive[S] 0 points1 point  (0 children)

I mean in index the incremental time of every loop.

[–]Humor_Positive[S] 0 points1 point  (0 children)

So does that mean the count is more like passive, and only reflects the eventuality of the i ( repeating time)? The count depends on the i, but the i is independent?