Yeah it seems to want to group letters together and treat the second one as “another” of the one before it… somehow counting that as just one with that logic. If you force it to not consider that sort of grouping… generates right number?
Crikey there are so many complex ways people are getting it to count and keep a count of each letter as it goes along!
What’s wrong with just saying :
“Take the word strawberry and split it into its individual letters and then tell me how many letter R’s are in the word?”
Seems to work fine?
Interesting enough, this was still breaking for me today with 4o.
When I ran your code locally it counted correctly. When I asked it to verify with code it actually used a much cleaner approach using the count function.
# Counting the number of 'r's in the word "strawberry"
word = "strawberry"
count_r = word.count('r')
count_r
This is the double R’s problem. I tried the word error and it told me 2 and not 3 too.
Hey, welcome to the community!
Have you read this thread above because several members explained why AI counts wrongly.
AI processes text differently from how a human visually scans a word. Instead of “seeing” the word and counting in real-time, AI relies on language prediction kind of like autocomplete on steroids. Sometimes AIs infer or guess based on patterns instead of calculating.
AI see tokens:
https://platform.openai.com/tokenizer
You see the sample here how tokens look:
When AI first says 4 o’s, It does not double-check the count logically. It is a quick, predicted answer, not a step-by-step count.
But, it is possible to get better result from reasoning models.
You should use a kind of prompt technique for breaking small parts and count:
Another technique ask positions:
This is sample how it does sum up, it is very close to correct answer, but wrong:
And a prompt technique for breaking small groups:
Or using a python code:
Thank you for the detailed responses—I learned a lot from them. ChatGPT struck a great balance between computational efficiency and accuracy. While other models I tried provided correct answers, they indeed required more computation time.
One answer example in case you are interested:
To determine how many "o"s are in the word “coconutocean” , let’s carefully count each occurrence of the letter “o.”
The word is: c o c o n u t o c e a n
Now, let’s go through it step by step:
- The first “o” is in position 2.
- The second “o” is in position 4.
- The third “o” is in position 8.
Thus, there are 3 "o"s in the word “coconutocean.”
Final Answer: 3
I made a thingy called SPStrict that bypasses a whole list of models for theological research in Hebrew. It solves the counting r’s problem.
See a white paper here: 2ndbook org/wiki/SPStrict
well chatGPT says there are 3 n’s in the word banana











